Skip to content

Instantly share code, notes, and snippets.

@warmfusion
Created May 29, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warmfusion/c823937dac7a22627544 to your computer and use it in GitHub Desktop.
Save warmfusion/c823937dac7a22627544 to your computer and use it in GitHub Desktop.
Sensu Event Wrapper
#!/bin/bash
#
# Usage: echo 'My Message' | ./sensu-event-wrapper.sh my-event-name
#
NAME=${1:-sensu_event}
SOURCE=$(hostname -f)
# JSON doesnt like newlines, it demands \n - which is suprisingly tricky to do in bash
OUTPUT=$(cat | awk '{printf "%s\\n",$0} END {print ""}' )
# Change localhost/3030 to some.remote.server.com/1234 if you run
# a balancer or change sensu-client to listen on different ports
cat << EOF > /dev/tcp/localhost/3030
{
"name": "${NAME}",
"source": "${SOURCE}",
"output": "${OUTPUT}",
"handler": "default",
"status": 0
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment