Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script that periodically monitor system disks counters using sar utility, samples are pushed to a Graphite's carbon-cache instance.
#!/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);
}
}' | \
nc ${GRAPHITE_SERVER} ${GRAPHITE_CARBON_PAINTEXT_PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment