fmeister
(Florian Meister)
January 20, 2023, 7:48am
1
Hello all
We have since a few weeks Checkmk (Raw Edition 2.1.0p19 on Ubuntu 22.04 LTS) and want to replace our existing Nagios3.
In Nagios3 we have SMS sending via Gammu and a USB modem (Huawei Surfstick E303).
Sending SMS works via console (echo “Hello recipient :)” | gammu sendsms TEXT 004179xxxyyzz).
Haven’t found any instructions/scripts on how exactly I teach checkmk to send SMS.
In Nagios we use this command:
# 'notify-host-by-gsm' command definition
define command{
command_name notify-host-by-gsm
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$: Host - $HOSTNAME$ is $HOSTSTATE$ / Info: $HOSTOUTPUT$ / Date/Time: $LONGDATETIME$" | gammu sendsms TEXT $_CONTACTGSM$
}
# 'notify-service-by-gsm' command definition
define command{
command_name notify-service-by-gsm
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ / Info: $SERVICEOUTPUT$ / Date/Time: $LONGDATETIME$" | gammu sendsms TEXT $_CONTACTGSM$
}
Will this easy work with Gammu or do you use another tool for sending SMS with a SIM Card in an USB Modem?
I created a new user attribute, because i used already Contactpager. The new attribute is called mobilephone. How can I use this?
Thanks for your help
Florian
r.sander
(Robert Sander)
January 20, 2023, 8:20am
2
You would need to create your own notification plugin.
An example is the sms
plugin which uses smssend
to generate the SMS.
#!/usr/bin/env python3
# SMS (using smstools)
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Notification via sms using the sms tools
# Note: You have to add the site user to the sendsms group
# and restart the site
import os
import re
import shutil
import subprocess
import sys
import tempfile
from cmk.notification_plugins.utils import collect_context, get_sms_message_from_context
This file has been truncated. show original
Put your own notification plugin in $OMD_ROOT/local/share/check_mk/notifications
. After that you can select it in the dropdown of the notification rule.
If it is working build an extension package and publish it to the Exchange: https://exchange.chekcmk.com/
2 Likes
fmeister
(Florian Meister)
January 30, 2023, 1:38pm
3
Thanks for you reply. I will check this.
I created a new user attribute, because i used already Contactpager. The new attribute is called mobilephone. Do you know how I can use this?
r.sander
(Robert Sander)
February 2, 2023, 6:32am
4
The attribute gets “translated” into a new env variable for the notification plugin script.
Use “env | sort > /tmp/notification.env” in your script to see them all.
system
(system)
Closed
February 2, 2024, 6:33am
5
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.