Created
March 3, 2015 13:01
-
-
Save ccoenen/cfdefd7235926f6d559d to your computer and use it in GitHub Desktop.
Simple Monitoring with statsd, shell and netcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX=any.prefix.will.do | |
STATSD_HOSTNAME=your.server.name | |
STATSD_PORT=8125 | |
while true; do | |
echo "$PREFIX.systemload1:`cut -f1 -d " " /proc/loadavg`|g" | ./nc -u -q 0 $STATSD_HOSTNAME $STATSD_PORT | |
cat /proc/stat | grep "cpu " | \ | |
while read -r cpu user nice system idle iowait irq softirq steal guest guestnice | |
do | |
echo -e \ | |
"$PREFIX.cpu.user:$user|g | |
$PREFIX.cpu.nice:$nice|g | |
$PREFIX.cpu.system:$system|g | |
$PREFIX.cpu.idle:$idle|g | |
$PREFIX.cpu.iowait:$iowait|g | |
$PREFIX.cpu.irq:$irq|g | |
$PREFIX.cpu.softirq:$softirq|g | |
$PREFIX.cpu.steal:$steal|g | |
$PREFIX.cpu.guest:$guest|g | |
$PREFIX.cpu.guestnice:$guestnice|g" \ | |
| ./nc -u -q 0 $STATSD_HOSTNAME $STATSD_PORT | |
done | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment