Created
July 4, 2013 06:06
-
-
Save darkone23/5925242 to your computer and use it in GitHub Desktop.
send load average to graphite using simple shell utilities
This file contains hidden or 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
| #!/bin/sh | |
| # set up our graphite namespace | |
| graphite_host="localhost" | |
| graphite_port=2003 | |
| namespace="system.$(hostname).loadavg" | |
| # get current time and loadavg | |
| time=$(date +'%s') | |
| load=$(cat /proc/loadavg) | |
| # map describing loadavg format | |
| # "metric_name:field_number" | |
| one="1:1minute" | |
| five="2:5minute" | |
| fifteen="3:15minute" | |
| for avg in $one $five $fifteen; do | |
| index=$(echo $avg | cut -d ':' -f 1) | |
| value=$(echo $load | cut -d ' ' -f $index) | |
| metric=$(echo $avg | cut -d ':' -f 2) | |
| echo "${namespace}.${metric} ${value} ${time}" | | |
| nc $graphite_host $graphite_port | |
| done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment