Prometheus node_exporter
安装包下载
Prometheus 官网下载地址
包含Prometheus软件及各种exporter插件
node_exporter1.4.0安装包
解压安装
tar -xvf node_exporter-1.4.0.linux-amd64.tar.gz
注册服务
可参考
linux 自定义服务
vi /etc/init.d/promethues
#!/bin/bash
#Create by:zhangyongze
#为什么不问问神奇的海螺呢丶
# chkconfig: 2345 55 25
# description: Prometheus exporter for hardware and OS metrics
#
RETVAL=0
PROG="node_exporter"
EXEC="/monitor/node_exporter-1.4.0.linux-amd64/node_exporter"
LOCKFILE="/var/lock/subsys/$PROG"
OPTIONS="--web.listen-address=:9100"
# Source function library.
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo "/etc/rc.d/init.d/functions does not exist"
exit 0
fi
start() {
if [ -f $LOCKFILE ]
then
echo "$PROG is already running!"
else
echo -n "Starting $PROG: "
nohup $EXEC $OPTIONS >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE && success || failure
echo
return $RETVAL
fi
}
stop() {
echo -n "Stopping $PROG: "
killproc $EXEC
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure
echo
}
restart ()
{
stop
sleep 1
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $PROG
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
修改执行权限
chmod 775 /etc/init.d/node_exporter
设置chkconfig 管理服务
根据服务文件中 # chkconfig: 2345 55 25 设置启动级别
chkconfig --add node_exporter
检查现有服务启动级别
chkconfig --list
运行node_exporter服务
service node_exporterstart
web页面查看
浏览器访问 服务器地址+端口号(服务中配置的)
例如 http://192.168.1.21:9100/
Metrics可查看所有指标数据