SMS Server Tools 3 via cellular (USB)-dongle
Posted: Sat Mar 16, 2019 11:17 am
When I installed my Nemslinux on the Raspi3, I had one main goal as a target: Monitoring my internet-connection, and sending SMS if it breaks down, obviously as it's the only communication back left in my home.
I thought about a separate UMTS/LTE-connection that the usb-dongle could also provide, but that would need a corresponding hosted monitoring service plus UMTS data - that surely will cost extra money, that I was not willing to pay.
The SMS-Server-Tools 3 are easy to install on NEMSlinux, a bit more difficult was it to configure the smstools to communicate with the dongle and to fiddle with the ttyusb0-comport always changing its ID on reboot, causing loss of communication. That was done by mapping the device-id to a symlink.
You will have to give the nagios-user permissions to create files under /var/spool/sms inherited, I just chose 777 for easygoing..
Then you would add two misccommand in nconf:
notify-host-by-sms
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/local/bin/sendsms $CONTACTPAGER$ "** $NOTIFICATIONTYPE$ Host Alert:$HOSTNAME$ is $HOSTSTATE$ **"
notify-service-by-sms
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/local/bin/sendsms $CONTACTPAGER$ "** $NOTIFICATIONTYPE$ Service Alert:$SERVICEDESC$ on $HOSTNAME$ State: $SERVICESTATE$ **"
and then configuring your contact with the new notify-command and adding a phone-nr in the format +49170123465
That's it, I still have to find out, how I check for a failed internet connection, I think about pinging three individual internet-ip-adresses, and when ALL three fail, trigger a "Internet-down-SMS". (if interconnecting switch not down, if router not down, if DSL-Modem not down, keeping a proper parenting dependency. Still have to properly implement that, but it's cool not to be dependant on a running internet line for that monitoring-notifications to work.
It would also be a good idea to put this into the standard NEMSlinux wouldn't it?
I thought about a separate UMTS/LTE-connection that the usb-dongle could also provide, but that would need a corresponding hosted monitoring service plus UMTS data - that surely will cost extra money, that I was not willing to pay.
The SMS-Server-Tools 3 are easy to install on NEMSlinux, a bit more difficult was it to configure the smstools to communicate with the dongle and to fiddle with the ttyusb0-comport always changing its ID on reboot, causing loss of communication. That was done by mapping the device-id to a symlink.
You will have to give the nagios-user permissions to create files under /var/spool/sms inherited, I just chose 777 for easygoing..
Then you would add two misccommand in nconf:
notify-host-by-sms
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/local/bin/sendsms $CONTACTPAGER$ "** $NOTIFICATIONTYPE$ Host Alert:$HOSTNAME$ is $HOSTSTATE$ **"
notify-service-by-sms
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/local/bin/sendsms $CONTACTPAGER$ "** $NOTIFICATIONTYPE$ Service Alert:$SERVICEDESC$ on $HOSTNAME$ State: $SERVICESTATE$ **"
and then configuring your contact with the new notify-command and adding a phone-nr in the format +49170123465
That's it, I still have to find out, how I check for a failed internet connection, I think about pinging three individual internet-ip-adresses, and when ALL three fail, trigger a "Internet-down-SMS". (if interconnecting switch not down, if router not down, if DSL-Modem not down, keeping a proper parenting dependency. Still have to properly implement that, but it's cool not to be dependant on a running internet line for that monitoring-notifications to work.
It would also be a good idea to put this into the standard NEMSlinux wouldn't it?