Created
January 19, 2015 20:38
-
-
Save hashbrowncipher/c044bc60a2c8d577dc50 to your computer and use it in GitHub Desktop.
a script written by @solarkennedy at Yelp to test sensu alerts
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
#!/bin/bash | |
cat <<EOF >/tmp/test-sensu-alert.json | |
{ | |
"name": "test_alert_for_${USER}", | |
"interval": 0, | |
"alert_after": 0, | |
"realert_every": "1", | |
"runbook": "y/unknown", | |
"annotation": "unknown", | |
"sla": "No SLA defined.", | |
"dependencies": [], | |
"team": "noop", | |
"irc_channels": [], | |
"notification_email": "${USER}@yelp.com", | |
"ticket": false, | |
"project": false, | |
"page": false, | |
"tip": "this is a test alert", | |
"output": "", | |
"status": 1, | |
"command": "send-test-sensu-alert", | |
"watchdog_timer": null | |
} | |
EOF | |
$EDITOR /tmp/test-sensu-alert.json | |
if [[ $? -eq 0 ]]; then | |
if cat /tmp/test-sensu-alert.json | tr -d "\n" | jq . > /dev/null ; then | |
echo "Sending the alert to the localhost:3030 socket!" | |
cat /tmp/test-sensu-alert.json | tr -d "\n" > /dev/tcp/localhost/3030 | |
echo | |
echo "Resolve your check with:" | |
echo "sensu-cli resolve `hostname -f` `cat /tmp/test-sensu-alert.json | jq .'name'`" | |
else | |
echo "Error: Invalid JSON?" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment