Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created January 19, 2015 20:38
Show Gist options
  • Save hashbrowncipher/c044bc60a2c8d577dc50 to your computer and use it in GitHub Desktop.
Save hashbrowncipher/c044bc60a2c8d577dc50 to your computer and use it in GitHub Desktop.
a script written by @solarkennedy at Yelp to test sensu alerts
#!/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