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:

Prerequisites

In order to set up the SMS notification, this requires the following:

Install hardware

  1. Install modem & USB-serial converter to Proxmox host.

  2. 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

  1. 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
    
  2. 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

  1. Install minicom.
[root@opsview ~]# dnf install minicom -y
  1. 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
  1. Change serial port settings to /dev/ttyUSB0 by pressing A and change /dev/modem to /dev/ttyUSB0.

  2. Press F to change Hardware Flow Control to No.

  3. Press Enter, and then select Save setup as dfl.

  4. Select Exit from Minicom.

  5. Type at and then press Enter.

    If modem respond OK, you are good to go. If not, press CTRL-A + Z and select initialize modem from menu.

Optional checks

SMS Service start and testing SMS

  1. 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 ~]#
    
  2. 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.
  1. 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 ~]#
    
  2. Check smsd directories.

    [root@opsview ~]# watch ls -la /var/spool/sms/*
    
  3. 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

  1. 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 ~]#
    
  2. To set and test SMS notification module, go to Configuration > Notification Methods > SMS Notification Module.

  3. On the Notfication Methods tab, select Enable.

  4. Select the Test tab and do the following:

    Enable SMS notification

    • Add the mobile number without the +, but still include the country code.
    • Write the message title or description.
  5. Click Send.

  6. 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.

  1. Navigate to Users and Roles > Notifications tab.

  2. Enter your mobile number without the +, but still include the country code.

    ![Notifications Mobile]!(/opsview/images/mobile-user-roles-notif-tab.png)

  3. On the Notification Profiles tab, click Add New.

  4. In the New Personal Notification Profile window, do the following:

    Personal Notification Profile

    • Enter the profile name.
    • Select SMS Notification Module on the Alert me by menu.
    • Deselect all from the Hosts/Service Checks tab.
  5. On the Hashtags tab, do the following:

    Hashtags Personal Notification Profile

    • 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.
  6. You should see something similar to the example below.

Notification Profile SMS

  1. Click Submit Changes, and then click Apply Changes.

  2. If you have configured Maximum Check Attempts to 1, you can easily test SMS by setting specific service status to CRITICAL.

    Set Service Check Status

    You should receive SMS and recovery message after five minutes.

["Opsview"] ["User Guide"]

Was this topic helpful?