-
-
Save yogin/39def9303546858878236c72c8301276 to your computer and use it in GitHub Desktop.
Script to mute or unmute and resolve a Datadog monitor
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
vagrant@kratos:~$ chmod +x manage_monitor.sh | |
vagrant@kratos:~$ sudo cp manage_monitor.sh /etc/init.d/manage_monitor | |
vagrant@kratos:~$ sudo update-rc.d manage_monitor defaults |
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/sh | |
# Make sure to populate the variables below with ones for your account | |
api_key=xxx | |
app_key=xxx | |
monitor_id=12345 | |
monitor_scope=host:kratos | |
case "$1" in | |
stop) | |
# Mute monitor | |
echo "Muting host monitor..." | |
curl -X POST "https://app.datadoghq.com/api/v1/monitor/${monitor_id}/mute?api_key=${api_key}&application_key=${app_key}" | |
;; | |
start) | |
echo "Resolving and unmuting host monitor..." | |
# Resolve monitor | |
curl -X POST -H "Content-type: application/json" -d "{ \"resolve\": [{\"${monitor_id}\": \"${monitor_scope}\"}] }" "https://app.datadoghq.com/monitor/bulk_resolve?api_key=${api_key}&application_key=${app_key}" | |
# Unmute monitor | |
curl -X POST "https://app.datadoghq.com/api/v1/monitor/${monitor_id}/unmute?api_key=${api_key}&application_key=${app_key}" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment