# PING #/bin/bash ping -c 50 -W 1 myhost.lan > /tmp/ping.txt cat /tmp/ping.txt | grep 'packet loss' | awk '{print "ping {type=\"loss\",dst=\"myhost.lan\"} "$6}' | sed 's/%//g' > /tmp/ping_result.txt cat /tmp/ping.txt | grep rtt | awk -F '/' '{print "ping {type=\"rtt\",dst=\"myhost.lan\"} "$6}' >> /tmp/ping_result.txt mv /tmp/ping_result.txt /tmp/prom/ping.prom # prometheus jstat exporter - java monitoring #!/bin/bash jstat -gc `ps ax | grep java | grep -v grep | awk '{print $1}'` | tail -n 1 | awk '{print "jstat {field=\"s0c\"} "$1"\n""jstat {field=\"s1c\"} "$2"\n""jstat {field=\"s0u\"} "$3"\n""jstat {field=\"s1u\"} "$4"\n""jstat {field=\"ec\"} "$5"\n""jstat {field=\"eu\"} "$6"\n""jstat {field=\"oc\"} "$7"\n""jstat {field=\"ou\"} "$8"\n""jstat {field=\"mc\"} "$9"\n""jstat {field=\"mu\"} "$10"\n""jstat {field=\"ccsc\"} "$11"\n""jstat {field=\"ccsu\"} "$12"\n""jstat {field=\"ygc\"} "$13"\n""jstat {field=\"ygct\"} "$14"\n""jstat {field=\"fgc\"} "$15"\n""jstat {field=\"fgct\"} "$16"\n""jstat {field=\"gct\"} "$17}' > /tmp.jstat.txt mv /tmp.jstat.txt /tmp/prom/jstat.prom