SMS Notifications
Overview
Warning
The procedure described in this article is not part of Opsview and is not supported. If you continue to follow the instructions in this document, there are no assurances or product support offered.
In order to use the SMS notification module, the SMS gateway must be installed first. This software consists of four utilities, which are run from command shell:
submit_sms
— submits SMS messages onto the queuing system.device_admin
— an administrative front end to the device configuration.message_admin
— an administrative front end to the message queues.check_smsgateway
— a Nagios plugin to report status of system.smsqueued
— handles queuing of messages and status of devices.
Prerequisites
In order to set up the SMS notification, this requires the following:
- Opsview 6.7.6 and newer
- CentOS 7, OEL7, and RHEL 8
- USB-serial adapter
- Siemens TC35 modem
- Sim card for modem
Install hardware
-
Install modem & USB-serial converter to Proxmox host.
-
Select Opsview VM and Hardware, then add USB-device USB-Serial Controller D (067b:2303) to VM as passthrough device. You can check
dmesg
to find the USB address.[root@opsview ~]# dmesg |grep tty [ 0.001000] printk: console [tty0] enabled [ 3.753985] usb 2-1: pl2303 converter now attached to ttyUSB0 [root@opsview ~]#
Note
If you have Moxa 5110A RJ-45 to RS-232 converter, you may configure SMS send through IP address.
Install software
-
Download smstools on Opsview host.
[root@opsview ~]# wget https://downloads.opsview.com/opsview-support/smstools-2021.11.30.1.20211130155919.el8.x86_64.rpm -P /root
-
Install smstools to Opsview.
[root@opsview ~]# dnf install /root/smstools-2021.11.30-op5.1.20211130155919.el8.x86_64.rpm -y [root@opsview sms]# chmod 777 /var/spool/sms/outgoing modify “device = /dev/ttyS0” to “device = /dev/ttyUSB0” [root@opsview ~]# vi /etc/smsd.conf [GSM1] device = /dev/ttyUSB0 incoming = yes #pin = 1111
Check modem access
- Install minicom.
[root@opsview ~]# dnf install minicom -y
- Check that the port is active.
[root@opsview ~]# ll /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 26. 1. 09:41 /dev/ttyUSB0
[root@opsview ~]#
[root@opsview ~]# minicom -s
-
Change serial port settings to
/dev/ttyUSB0
by pressingA
and change/dev/modem
to/dev/ttyUSB0
. -
Press
F
to change Hardware Flow Control toNo
. -
Press Enter, and then select Save setup as dfl.
-
Select Exit from Minicom.
-
Type
at
and then press Enter.If modem respond
OK
, you are good to go. If not, pressCTRL-A + Z
and select initialize modem from menu.
Optional checks
-
Check operator:
at+cops? +COPS: 0,0,"FI SONERA" OK
-
Send test message:
at+cmgf=1 OK at+cmgs="0408488118" > test message (press CTRL-Z) to end message writing +CMGS: 0 OK
-
Press
CTRL-A + Z
anytime to open menu and selectQ
to quit.
SMS Service start and testing SMS
-
Start SMS service.
[root@opsview ~]# systemctl start smsd [root@opsview ~]# systemctl status smsd ● smsd.service - smsd Loaded: loaded (/usr/lib/systemd/system/smsd.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2023-01-26 10:30:31 EET; 1s ago Process: 62239 ExecStartPre=/bin/chown smstools:smstools /var/run/smsd.working (code=exited, status=0/SUCCESS) Process: 62237 ExecStartPre=/bin/touch /var/run/smsd.working (code=exited, status=0/SUCCESS) Process: 62235 ExecStartPre=/bin/chown smstools:smstools /var/run/smsd.pid (code=exited, status=0/SUCCESS) Process: 62233 ExecStartPre=/bin/touch /var/run/smsd.pid (code=exited, status=0/SUCCESS) Main PID: 62242 (smsd) Tasks: 2 (limit: 102266) Memory: 4.1M CGroup: /system.slice/smsd.service ├─62242 /usr/sbin/smsd -t └─62245 /usr/sbin/smsd -t tammi 26 10:30:31 opsview systemd[1]: Starting smsd... tammi 26 10:30:31 opsview systemd[1]: Started smsd. [root@opsview ~]#
-
Check log files for issues
/var/log/smsd/smsd.log
.
Sending a test SMS
Note
Remove+
sign out of your mobile number, but include country code.
-
Send a test message to a mobile number.
[root@opsview ~]# smssend 44123456789 "testing modem behind opsview" -- Text: testing modem behind opsview To: 44123456789 [root@opsview ~]#
-
Check smsd directories.
[root@opsview ~]# watch ls -la /var/spool/sms/*
-
Check log.
[root@opsview ~]# less /var/log/smsd/smsd.log 2023-01-27 08:39:50,5, smsd: SMS To: 44123456789. Moved file /var/spool/sms/outgoing/send_O9fFUC to /var/spool/sms/checked 2023-01-27 08:39:53,5, GSM1: SMS sent, Message_id: 14, To: 44123456789, sending time 3 sec.
Modify Opsview
-
Edit
submit_sms_script
file:[root@opsview ~]# vi /opt/opsview/monitoringscripts/notifications/submit_sms_script 45,46c45 < #$command = '/usr/local/bin/submit_sms'; < $command = '/usr/bin/smssend'; --- 84,86c83 < #my @command = ( $command, '-n', $number, '-t', $text ); < my @command = ( $command, $number, $text ); [root@opsview ~]#
-
To set and test SMS notification module, go to Configuration > Notification Methods > SMS Notification Module.
-
On the Notfication Methods tab, select Enable.
-
Select the Test tab and do the following:
- Add the mobile number without the
+
, but still include the country code. - Write the message title or description.
- Add the mobile number without the
-
Click Send.
-
Once the Notification Sent appears, click Submit Changes.
Configure users and roles
In this example admin-user
is used and the CRITICAL-services
hashtag was prepared arlier which have few most critical servicechecks from NetApp storage (Cluster health, power supplies, temperatures) and from my Proxmox virtualization platform. These services should send SMS if there are any
issues.
-
Navigate to Users and Roles > Notifications tab.
-
Enter your mobile number without the
+
, but still include the country code.![Notifications Mobile]!(/opsview/images/mobile-user-roles-notif-tab.png)
-
On the Notification Profiles tab, click Add New.
-
In the New Personal Notification Profile window, do the following:
- Enter the profile name.
- Select SMS Notification Module on the Alert me by menu.
- Deselect all from the Hosts/Service Checks tab.
-
On the Hashtags tab, do the following:
- Select SMS Notification Module on the Alert me by menu.
- Select the timeperiod on the During menu.
- Select the status you want to set for the Hosts and Service Checks.
- Select
CRITICAL-services
on in the following Hashtags menu. - Set the Stop after alert # field to
1
. - Click Update.
-
You should see something similar to the example below.
-
Click Submit Changes, and then click Apply Changes.
-
If you have configured Maximum Check Attempts to
1
, you can easily test SMS by setting specific service status toCRITICAL
.You should receive SMS and recovery message after five minutes.