Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
metrics-graphite for sensu on centos/redhat
cpu () {
echo $HOSTNAME.cpu $(mpstat 1 1 | awk '$13 ~ /[0-9.]+/ { print 100 - $13 }') $(date +%s)
}
disk_io () {
echo $HOSTNAME.disk_io $(iostat -d -z ALL | awk 'NF==6 {s+=$2} END {print s}') $(date +%s)
}
disk_usage () {
echo $HOSTNAME.disk_usage $(df -k / | awk 'NR > 1 {print $5}' | cut -d "%" -f 1) $(date +%s)
}
heartbeat () {
echo $HOSTNAME.heartbeat 1 $(date +%s)
}
memory () {
echo $HOSTNAME.memory $(free -m | awk 'NR==2{printf "%.2f", $3*100/$2 }') $(date +%s)
}
network_io () {
echo $HOSTNAME.network_in $(($((`date "+%s"`)) % 60)) $(date +%s)
echo $HOSTNAME.network_out $(($((`date "+%s"`+ 30 )) % 60)) $(date +%s)
}
ping_ok () {
ping -c 1 $PING_REMOTE_HOST > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo $HOSTNAME.ping_ok 1 $(date +%s)
else
echo $HOSTNAME.ping_ok 0 $(date +%s)
fi
}
HOSTNAME=$(hostname)
cpu
disk_io
disk_usage
heartbeat
memory
network_io
ping_ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment