Skip to content

Instantly share code, notes, and snippets.

@daniel-garcia
Last active August 29, 2015 14:01
Show Gist options
  • Save daniel-garcia/c10ba959eb76764f0a77 to your computer and use it in GitHub Desktop.
Save daniel-garcia/c10ba959eb76764f0a77 to your computer and use it in GitHub Desktop.
example load average poster to internal consumer URL
#!/bin/bash
interval=1
echo "posting loadavg at $interval second(s) interval"
while :
do
now=`date +%s`
value=`cat /proc/loadavg | cut -d ' ' -f 1`
data="{\"control\":{\"type\":null,\"value\":null},\"metrics\":[{\"metric\":\"loadavg\",\"timestamp\":$now,\"value\":$value,\"tags\":{\"name\":\"value\"}}]}"
output=`curl -s -XPOST -H "Content-Type: application/json" -d "$data" "$CONTROLPLANE_CONSUMER_URL"`
if ! [[ "$output" == *OK* ]]
then
echo "failure";
fi
sleep $interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment