Trivial SMS alert when server / equipment is unavailable

It happened to many of my colleagues (system administrators, and probably not only) that when the power was turned off \ hardware failure \ software failure - they learned about the unavailability of a service / server from dissatisfied bosses / dissatisfied colleagues.
In order to somehow solve the problem of what I learn about a problem in the infrastructure from colleagues, it became necessary to make an SMS alert.
Surely there are some ready-made solutions, maybe some paid, hardware, etc. ... In this article we will talk about a simple and banal solution - and so I will begin the description.

Given:
1) A Windows computer on board with an RS-232 port (COM port);
2) GSM-modem Siemens MC35i \ (now called Cinterion) with RS-232 port with antenna and power supply;
3) RS-232 cable;
4) SIM card at the corporate rate (which will not be disabled by the operator for the absence of paid operations within 90 days), on the general balance of the building. personal account so that the money does not run out;
5) nncron software ;
6) NHSMS software

Task:
If the server / device \ Internet is unavailable via the network, receive an SMS message with its name.

Solution:
1) First, the modem was connected to the computer - configured as a regular modem with a port speed of 115200 bps;
2) Next, software was found and tested, which sends sms via the command line (cmd \ bat) - NHSMS (link above);
3) Then it was necessary to somehow detect events after which it was necessary to use the written cmd-files for sending messages. We were helped here by nncron (link above) with its scripts.

The nncron script can be configured through its configuration form:

image
image

As a result of the setup, the nncron.tab file is generated. It is located in the application root directory and looks like this:

# (OMEGA-inet
Time: * / 5 * * * * *
Rule: HOST-EXIST: "8.8.8.8" NOT
Action:
StartIn: "C: \ soft"
ShowNormal NormalPriority
START- APP: C: \ soft \ OMEGA-inet.cmd
) #

# (OMEGA-AV01
Time: * / 5 * * * * *
Rule: HOST-EXIST: "OMEGA-AV01" NOT
Action:
StartIn: "C: \ soft »
ShowNormal NormalPriority
START-APP: C: \ soft \ OMEGA-AV01.cmd
) #

# (OMEGA-MX6
Time: * / 5 * * * * *
Rule: HOST-EXIST: "OMEGA-MX6" NOT
Action:
StartIn: "C: \ soft »
ShowNormal NormalPriority
START-APP: C: \ soft \ OMEGA-MX6.cmd
) #

# (OMEGA-OFFICE
Time: * / 5 * * * * *
Rule: HOST-EXIST:" OFFICE "NOT
Action:
StartIn: “C: \ soft”
ShowNormal NormalPriority
START-APP: C: \ soft \ OMEGA-office.cmd
) #

Its meaning is simple - the server responds by NS name every 5 minutes (the value can be changed, but if something falls off, ,, if there is no ping, then the cmd file is triggered.
The cmd files themselves contain a message for sending SMS (each server has its own cmd file to make it easier to search and edit):

nhsmscl.exe -COM: 1 -smsc: 79168999100 -phone: 79639666666 -esc: Server OMEGA-MX6 is down.
echo off
echo% * >> in-sms.log

where “Server OMEGA-MX6 is down.” is the message that comes to the phone (in Russian, I still couldn’t learn how to write a program - it is probably related to the cmd- encoding file, but it doesn’t matter).

Actually, what does the modem itself look like (suddenly someone didn’t see it):

image

Well, and as a result

image

:
1) when you turn off the computer with the modem, nothing will happen - in such a case, as an option, you can make a second computer with a modem that will poll the first computer for availability, but whether it is necessary in a small office;
2) nncron also has a function of polling by port - so you can configure, for example, polling of significant TCP ports and in case of a service failure - SMS will also come;
3) it is advisable to power the computer with the modem with a separate personal uninterruptible power supply - in case of failure of the main UPS, the computer with the modem will be protected.

All peace and goodness!

Also popular now: