Skip to content

Instantly share code, notes, and snippets.

@halcyonardency
Last active August 29, 2015 14:27
Show Gist options
  • Save halcyonardency/063007478422b9ae95ad to your computer and use it in GitHub Desktop.
Save halcyonardency/063007478422b9ae95ad to your computer and use it in GitHub Desktop.
Ad-hoc Sensu Alarm
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
}
@halcyonardency
Copy link
Author

. ./goodbad.sh

good test123

Tue Aug 11 09:31:10 MST 2015: gooding test123, alarmtest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment