Skip to content

Instantly share code, notes, and snippets.

@kakerukaeru
Last active March 18, 2016 12:10
Show Gist options
  • Save kakerukaeru/4881a742e134cd83f48f to your computer and use it in GitHub Desktop.
Save kakerukaeru/4881a742e134cd83f48f to your computer and use it in GitHub Desktop.
#!/bin/bash
_SENSU_USER_=sensu
_SENSU_PASS_=sensu
_SENSU_SERVER_=10.10.10.10
stop_monit () {
_HTTP_STATUS_=`curl -s -m 5 -X POST http://${_SENSU_USER_}:${_SENSU_PASS_}@${_SENSU_SERVER_}:4567/stashes -d "{\"path\" : \"silence/$1\", \"content\" : {\"reason\" : \"${REASON}\"} }" -w "status:%{http_code}" -o /dev/null`
if [ $_HTTP_STATUS_ != "status:201" ]; then
echo "stop_monit command failed"
exit 1
fi
}
start_monit () {
_HTTP_STATUS_=`curl -s -m 5 -X DELETE http://${_SENSU_USER_}:${_SENSU_PASS_}@${_SENSU_SERVER_}:4567/stashes/silence/$1 -w "status:%{http_code}" -o /dev/null`
if [ $_HTTP_STATUS_ != "status:204" ]; then
echo "start_monit command failed"
exit 1
fi
}
stash_list () {
curl -s -m 5 http://${_SENSU_USER_}:${_SENSU_PASS_}@${_SENSU_SERVER_}:4567/stashes | jq '.[] | {host: .path ,reason: .content.reason}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment