点击查看代码
#!/bin/bash
#date: 20220621
#author:bin
>/tmp/node_dmz.txt
>/tmp/node_err.txt
>/tmp/devicecheck.txt
[ -f /tmp/node_dmz.txt ]||touch /tmp/node_dmz.txt
[ -f /tmp/node_err.txt ]||touch /tmp/node_err.txt
[ -f /tmp/devicecheck.txt ]||touch /tmp/devicecheck.txt
while read line
do
{
ping -c1 -W1 $line &>/dev/null
if [ $? -ne 0 ];then
echo $line >>/tmp/node_err.txt
continue
fi
curl -s --continue-timeout 1 $line:49999/metrics &>/dev/null #49999 是服务器prometheus监听的端口
if [ $? -eq 28 ];then
echo $line >>/tmp/node_dmz.txt
continue
fi
curl $line:49999/metrics |grep node_filesystem_size_bytes |grep /bankapp &>/dev/null
if [ $? -ne 0 ];then
continue
fi
capacity=curl $line:49999/metrics |grep node_filesystem_size_bytes |grep /bankapp|awk '{print $NF}'
echo '主机 $line 磁盘分区异常... /bankapp 磁盘容量为: $ capacity' >>/tmp/devicecheck.txt
}&
sleep 0.1
done
Original: https://www.cnblogs.com/zbzSH/p/16399434.html
Author: zbzSH
Title: 利用prometheus 客户端采集磁盘容量脚本
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/612751/
转载文章受原作者版权保护。转载请注明原作者出处!