Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rchakode/f2b61d21224511c6f0b8ef5c27637eae to your computer and use it in GitHub Desktop.
Save rchakode/f2b61d21224511c6f0b8ef5c27637eae to your computer and use it in GitHub Desktop.
Script that periodically monitor system disks counters using sar utility, samples are outputted to stdin
#!/bin/bash
SAMPLING_INTERVAL=5
GRAPHITE_SERVER="127.0.0.1"
GRAPHITE_CARBON_PAINTEXT_PORT=2003
LC_ALL=C \
sar -d $SAMPLING_INTERVAL | \
gawk -vhostname="$(hostname)" '{
if (NF == 10 && $2 != "DEV") {
timestamp = systime();
printf("%s.%s.rd_sec %s %d\n", hostname, $2, $4, timestamp);
printf("%s.%s.wr_sec %s %d\n", hostname, $2, $5, timestamp);
printf("%s.%s.await %s %d\n", hostname, $2, $8, timestamp);
printf("%s.%s.util %s %d\n", hostname, $2, $10, timestamp);
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment