#!/bin/bash
instance_name=`hostname`
#jms服务端口监听状态
/sbin/ss -ntlp |grep -q 2222
if $? == 0 ];then
echo "jms_port 0" | curl --data-binary @- http://1.1.1.1:9091/metrics/job/pushgateway_jms/instance/$instance_name
else
echo "jms_port 1" | curl --data-binary @- http://1.1.1.1:9091/metrics/job/pushgateway_jms/instance/$instance_name
fi
#磁盘占用情况
disk_occupy=`df -h |grep -m1 / |awk '{ print $5 }' | awk -F% '{ print $1 }'`
echo "disk_occupy $disk_occupy" | curl --data-binary @- http://1.1.1.1:9091/metrics/job/pushgateway_jms/instance/$instance_name
#内存剩余情况
memory_occupy=`free -m | sed -n '2p' | awk '{print $3/$2*100}'`
echo "memory_occupy $memory_occupy" | curl --data-binary @- http://1.1.1.1:9091/metrics/job/pushgateway_jms/instance/$instance_name
#cpu使用情况
cpu_ues=`sar 1 1 |grep "Average" |awk '{ print $3+$4+$5+$6+$7 }'`
echo "cpu_ues $cpu_ues" | curl --data-binary @- http://1.1.1.1:9091/metrics/job/pushgateway_jms/instance/$instance_name