主要用于 *nix 系统监控,用golang编写,无需第三方依赖,下载解压运行即可
shell#cd到项目文件夹
cd /data
#wget拉取文件
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz
#解压文件
tar -zxvf node_exporter-1.6.0.linux-amd64.tar.gz && mv node_exporter-1.6.0.linux-amd64/ node_exporter-1.6/
#封装service(创建并配置service文件)
touch /usr/lib/systemd/system/node_exporter.service
vim /usr/lib/systemd/system/node_exporter.service
#重置systemctl,启动服务
systemctl daemon-reload
systemctl enable node_exporter && systemctl is-enabled node_exporter
systemctl start node_exporter && systemctl status node_exporter.service
service文件[Unit] Description=node_exporter Documentation=https://prometheus.io/docs/introduction/overview/ Wants=network-online.target After=network-online.targer [Service] User=centos Type=simple ExecStart=/data/node_exporter-1.6/node_exporter --web.listen-address=:9100 [Install] WantedBy=multi-user.target
使用 ./node_exporter -h
查看运行选项
访问http://localhost:9100/可以查看其指标信息
** 注意 : **
9100需要做防火墙规则
100 - (avg by (instance) (irate(node_cpu{instance="xxx", mode="idle"}[5m])) * 100)
node_load1{instance="xxx"} // 1分钟负载
node_load5{instance="xxx"} // 5分钟负载
node_load15{instance="xxx"} // 15分钟负载
100 - ((node_memory_MemFree{instance="xxx"}+node_memory_Cached{instance="xxx"}+node_memory_Buffers{instance="xxx"})/node_memory_MemTotal) * 100
100 - node_filesystem_free{instance="xxx",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs|udev|none|devpts|sysfs|debugfs|fuse.*"} / node_filesystem_size{instance="xxx",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs|udev|none|devpts|sysfs|debugfs|fuse.*"} * 100
// 上行带宽
sum by (instance) (irate(node_network_receive_bytes{instance="xxx",device!~"bond.*?|lo"}[5m])/128)
// 下行带宽
sum by (instance) (irate(node_network_transmit_bytes{instance="xxx",device!~"bond.*?|lo"}[5m])/128)
// 入包量
sum by (instance) (rate(node_network_receive_bytes{instance="xxx",device!="lo"}[5m]))
// 出包量
sum by (instance) (rate(node_network_transmit_bytes{instance="xxx",device!="lo"}[5m]))