Last active
August 29, 2015 14:27
-
-
Save halcyonardency/063007478422b9ae95ad to your computer and use it in GitHub Desktop.
Ad-hoc Sensu Alarm
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
function bad () { | |
# { short_hostname, alarm_name, handler_name} | |
# default: hostname -s, alarmtest, enterprise_mws | |
[ -z ${1} ] && ahost="`hostname -s`" || ahost=${1} | |
[ -z ${2} ] && check="alarmtest" || check="${2}" | |
[ -z ${3} ] && handler="enterprise_mws" || handler="${3}" | |
echo "`date`: badding ${ahost}, ${check}" | |
echo '{ "source": "'${ahost}'", "handlers": [ "'${handler}'" ], "name": "'${check}'", "issued": "'`date +%s`'", "output": "CRITICAL: '${ahost}' is sad.", "status": 2 }' | nc -w1 127.0.0.1 3030 | |
} | |
function good () { | |
# { short_hostname, alarm_name, handler_name} | |
# default: hostname -s, alarmtest, enterprise_mws | |
date | |
[ -z ${1} ] && ahost="`hostname -s`" || ahost=${1} | |
[ -z ${2} ] && check="alarmtest" || check="${2}" | |
[ -z ${3} ] && handler="enterprise_mws" || handler="${3}" | |
echo "`date`: gooding ${ahost}, ${check}" | |
echo '{ "source": "'${ahost}'", "handlers": [ "'${handler}'" ], "name": "'${check}'", "issued": "'`date +%s`'", "output": "CRITICAL: '${ahost}' is great.", "status": 0 }' | nc -w1 127.0.0.1 3030 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
. ./goodbad.sh
good test123
Tue Aug 11 09:31:10 MST 2015: gooding test123, alarmtest