Created
May 29, 2015 14:40
-
-
Save warmfusion/c823937dac7a22627544 to your computer and use it in GitHub Desktop.
Sensu Event Wrapper
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 | |
# | |
# 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