虚拟化容器,大数据,DBA,中间件,监控。

Prometheus Node Export 监控系统服务运行状态

21 12月
作者:admin|分类:容器虚拟化

监控系统服务运行状态,监控的是指被systemd管理的系统服务都可以被普罗米修斯采集到其状态,比如node_port  ssh docker

[root@localhost ~]# pstree
systemd─┬─NetworkManager───2*[{NetworkManager}]
        ├─VGAuthService
        ├─abrt-watch-log
        ├─abrtd
        ├─agetty
        ├─auditd───{auditd}
        ├─containerd───17*[{containerd}]
        ├─crond
        ├─dbus-daemon
        ├─grafana-server───11*[{grafana-server}]
        ├─irqbalance
        ├─master─┬─pickup
        │        └─qmgr
        ├─node_exporter───4*[{node_exporter}]
        ├─polkitd───5*[{polkitd}]
        ├─prometheus───7*[{prometheus}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sshd─┬─4*[sshd───bash]
        │      └─sshd───bash───pstree
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        ├─tuned───4*[{tuned}]
        └─vmtoolsd───{vmtoolsd}

监控系统服务运行状态

/usr/local/node_exporter/node_exporter --web.config=/usr/local/node_exporter/config.yml --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service

这样就是给系统服务给监控起来

可以看到有很多采集器,启动采集systemd服务

[root@localhost node_exporter]# ./node_exporter --help 
     --web.config=""           [EXPERIMENTAL] Path to config yaml file that can enable TLS or authentication.
      --collector.systemd       Enable the systemd collector (default: disabled).
      --collector.systemd.unit-whitelist=".+"  
                                Regexp of systemd units to whitelist. Units must both match whitelist and not match blacklist to be included.

被采集的白名单 要采集谁

[root@localhost ~]# cat /usr/lib/systemd/system/node_exporter.service 
[Unit]
Description=node_exporter

[Service]
ExecStart=/usr/local/node_exporter/node_exporter --web.config=/usr/local/node_exporter/config.yml --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart node_port
node_systemd_unit_state

这里面可以通过状态来查看服务是否起来

可以看到docker的服务是启动的,如果这个值为0那么就可以通过告警规则来引用这个表达式node_systemd_unit_state{name="docker.service",state="active"}来判断是否等于1还是0.通过这个值来监控系统服务的运行状态,挂了就可以及时的发送告警

浏览361 评论0
返回
目录
返回
首页
ETCD 集群的部署 Prometheus 基于Consul的服务发现