启动nodeExport前增加参加:textfile
root@wangwei830:/tmp/nodeExporter
[Unit]
Description=node_exporter
After=network.target
[Service]
Type=simple
User=prometheus_node
ExecStart=/usr/local/node_exporter/node_exporter --collector.textfile.directory=/tmp/nodeExporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
root@wangwei830:/tmp/nodeExporter
复制代码
新建目录,部署corntab生产.prom文件
root@wangwei830:/tmp/nodeExporter
/tmp/nodeExporter
root@wangwei830:/tmp/nodeExporter
root@wangwei830:/tmp/nodeExporter
cd /tmp/nodeExporter/
zhiBiao=http_requests_total
intzhiBiaoCode200=1200
intzhiBiaoCode400=400
intTime=`date +%s`
SN=AAA
cat > ${zhiBiao}_metrics.prom.$$ <<EOF
# HELP $zhiBiao The total number of xxxxxxx.
# TYPE $zhiBiao counter
http_requests_total{method="post",code="200"} $intzhiBiaoCode200
http_requests_total{method="post",code="400"} $intzhiBiaoCode400
http_requests_time{SN="$SN"} $intTime
EOF
mv ${zhiBiao}_metrics.prom.$$ ${zhiBiao}_metrics.prom
root@wangwei830:/tmp/nodeExporter