description |
---|
How to get Phone, SMS and Slack alerts from CheckMk? |
Make sure to add the Checkmk integration and copying the webhook.
{% content-ref url="create-integration-and-service-on-dashboard.md" %} create-integration-and-service-on-dashboard.md {% endcontent-ref %}
Using Spike.sh script with Checkmk
Download the official checkmk-spike package here.
If you are using Checkmk docker, scroll below.
Create a script called spike.sh
at local/share/check_mk/notifications
Paste the below script in the spike.sh file, using your prefered editor like nano or vim.
#!/bin/bash
# Notify via Spike.sh
# In order to use this script:
# - copy it into your site into ~/local/share/check_mk/notificaions
# - make sure it is executable
# - Modify the spike webhook url into SPIKE_URL=
# - Create a notification rule that makes use of the new plugin
curl --header "Content-Type: application/json" \
--request POST \
--data '{"OMD_ROOT" : "'"$OMD_ROOT"'","OMD_SITE" : "'"$OMD_SITE"'","NOTIFY_WHAT" : "'"$NOTIFY_WHAT"'","NOTIFY_CONTACTNAME" : "'"$NOTIFY_CONTACTNAME"'","NOTIFY_CONTACTEMAIL" : "'"$NOTIFY_CONTACTEMAIL"'","NOTIFY_CONTACTPAGER" : "'"$NOTIFY_CONTACTPAGER"'","NOTIFY_DATE" : "'"$NOTIFY_DATE"'","NOTIFY_LONGDATETIME" : "'"$NOTIFY_LONGDATETIME"'","NOTIFY_SHORTDATETIME" : "'"$NOTIFY_SHORTDATETIME"'","NOTIFY_HOSTNAME" : "'"$NOTIFY_HOSTNAME"'","NOTIFY_HOSTOUTPUT" : "'"$NOTIFY_HOSTOUTPUT"'","NOTIFY_HOSTSTATE" : "'"$NOTIFY_HOSTSTATE"'","NOTIFY_NOTIFICATIONTYPE" : "'"$NOTIFY_NOTIFICATIONTYPE"'","NOTIFY_PARAMETERS" : "'"$NOTIFY_PARAMETERS"'","NOTIFY_PARAMETER_1" : "'"$NOTIFY_PARAMETER_1"'","NOTIFY_PARAMETER_2" : "'"$NOTIFY_PARAMETER_2"'","NOTIFY_SERVICEDESC" : "'"$NOTIFY_SERVICEDESC"'","NOTIFY_SERVICEOUTPUT" : "'"$NOTIFY_SERVICEOUTPUT"'","NOTIFY_SERVICESTATE" : "'"$NOTIFY_SERVICESTATE"'"}' \
"$SPIKE_URL"
Export the spike webhook in an environment variable as:
$ export SPIKE_URL="https://hooks.spike.sh/********************/push-events"
Make the file executable.
$ sudo chmod +x spike.sh
On the dashboard, create a notification rule and choose to Notify via Spike.sh option to enable this integration.
Using Spike.sh script with Checkmk Docker
In case if you are using Checkmk with Docker containers, follow these steps.
Create a script called spike.sh
in your server at $HOME
$ sudo nano $HOME/spike.sh
Paste the below script in the spike.sh file.
#!/bin/bash
# Notify via Spike.sh
# In order to use this script:
# - copy it into your site into ~/local/share/check_mk/notificaions
# - make sure it is executable
# - Modify the spike webhook url into SPIKE_URL=
# - Create a notification rule that makes use of the new plugin
curl --header "Content-Type: application/json" \
--request POST \
--data '{"OMD_ROOT" : "'"$OMD_ROOT"'","OMD_SITE" : "'"$OMD_SITE"'","NOTIFY_WHAT" : "'"$NOTIFY_WHAT"'","NOTIFY_CONTACTNAME" : "'"$NOTIFY_CONTACTNAME"'","NOTIFY_CONTACTEMAIL" : "'"$NOTIFY_CONTACTEMAIL"'","NOTIFY_CONTACTPAGER" : "'"$NOTIFY_CONTACTPAGER"'","NOTIFY_DATE" : "'"$NOTIFY_DATE"'","NOTIFY_LONGDATETIME" : "'"$NOTIFY_LONGDATETIME"'","NOTIFY_SHORTDATETIME" : "'"$NOTIFY_SHORTDATETIME"'","NOTIFY_HOSTNAME" : "'"$NOTIFY_HOSTNAME"'","NOTIFY_HOSTOUTPUT" : "'"$NOTIFY_HOSTOUTPUT"'","NOTIFY_HOSTSTATE" : "'"$NOTIFY_HOSTSTATE"'","NOTIFY_NOTIFICATIONTYPE" : "'"$NOTIFY_NOTIFICATIONTYPE"'","NOTIFY_PARAMETERS" : "'"$NOTIFY_PARAMETERS"'","NOTIFY_PARAMETER_1" : "'"$NOTIFY_PARAMETER_1"'","NOTIFY_PARAMETER_2" : "'"$NOTIFY_PARAMETER_2"'","NOTIFY_SERVICEDESC" : "'"$NOTIFY_SERVICEDESC"'","NOTIFY_SERVICEOUTPUT" : "'"$NOTIFY_SERVICEOUTPUT"'","NOTIFY_SERVICESTATE" : "'"$NOTIFY_SERVICESTATE"'"}' \
"$SPIKE_URL"
Export the spike webhook in an environment variable as:
$ export SPIKE_URL="https://hooks.spike.sh/********************/push-events"
Do this step once the checkmk docker container is up.
Get the container id using docker ps
Copy the spike.sh file inside the docker container at the location /opt/omd/sites/cmk/local/share/check_mk/notifications#
using the following command.
replace the <CONTAINER_ID> with the container id you got from docker ps.
$ docker cp spike.sh <CONTAINER_ID>:/opt/omd/sites/cmk/local/share/check_mk/notifications/spike.sh
Now exec into the docker container.
$ docker exec -it <CONTAINER_ID> /bin/bash
Make the spike.sh executable.
$ cd /opt/omd/sites/cmk/local/share/check_mk/notifications
$ chmod +x spike.sh
Export the spike webhook in an environment variable as:
$ export SPIKE_URL="https://hooks.spike.sh/********************/push-events"