标签:arm 定时 nohup pos runner chm val 查看 权限
1.二进制包安装
mkdir -p /opt/exporter
下载地址:
wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-arm64.tar.gz
下载到/opt/exporter
1)用 tar 解压缩 node_exporter-0.14.0.linux-amd64.tar.gz
tar -xvzf node_exporter-0.14.0.linux-amd64.tar.gz
mv node_exporter-0.14.0.linux-amd64
node_exporter
cd /opt/exporter/node_exporter
修改权限 chmod 777 node_exporter
启动:
nohup /opt/exporter/node_exporter/node_exporter &
访问:curl http://IP:9100/metrics
2.docker化安装
前提是当前环境已安装docker环境
docker -v 执行显示docker版本信息,则说明已安装docker
1)node_exporter镜像下载
查看镜像: docker search node-exporter
拉取镜像: docker pull prom/node-exporter
查看拉取的镜像:docker images
启动镜像: docker images|grep node-exporter
根据对应的镜像id启动:
docker start 3a6e851e4dc2
查看监听端口:netstat -nlp|grep 9100
访问:curl http://IP:9100/metrics
3.node_exporter自定义exporter 监控key
创建目录: mkdir -p /opt/exporter/node_exporter/key
cd /opt/exporter/node_exporter/key
创建脚本:
vim key_runner
#! /bin/bash prom_file=/opt/exporter/node_exporter/key/key.prom IFS=";" export TERM=vt100 key_value=" Logical_CPU_core_total `cat /proc/cpuinfo| grep "processor"| wc -l`; logined_users_total `who | wc -l`; procs_total `/bin/top -b -n 1|grep Tasks|sed ‘s/,/\n/g‘|grep total|awk ‘{ print $(NF-1) }‘`; procs_zombie `/bin/top -b -n 1|grep Tasks|sed ‘s/,/\n/g‘|grep zombie|awk ‘{ print $(NF-1) }‘`" for i in $key_value do IFS=" " j=(`echo $i`) key=${j[0]} value=${j[1]} echo $key $value >> "$prom_file".tmp done cat "$prom_file".tmp > $prom_file rm -rf "$prom_file".tmp IFS=$OLD_IFS
#*****************
2)添加权限
chmod 755 /opt/exporter/node_exporter/key/*
vim /etc/cron.d/node-exporter
*/5 * * * * sh /opt/exporter/node_exporter/key/key_runner
启动node_exporter,指定新加key值的prom路径
nohup /opt/exporter/node_exporter/node_exporter --collector.textfile.directory=/opt/exporter/node_exporter/key &
访问:curl http://ip:9100/metrics > metrics.txt
cat metrics.txt
标签:arm 定时 nohup pos runner chm val 查看 权限
原文地址:https://www.cnblogs.com/momoyan/p/11520676.html