📜 ⬆️ ⬇️

Trivial SMS alert when server \ hardware is unavailable

With many of my colleagues (system administrators, and probably not only) it happened that during a power outage \ hardware failure \ software failure - they found out about the unavailability of a service \ server from disgruntled bosses \ dissatisfied colleagues.
In order to somehow solve the problem of what I learn about the 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. ... This article will discuss a simple and banal solution. - and so I will begin the description.

Given:
1) Windows computer on board with RS-232 port (COM port);
2) Siemens MC35i GSM modem \ (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 for 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 not available over the network, receive an SMS message with its name.
')
Decision:
1) First, the modem was connected to a computer — configured as a normal modem with a port speed of 115200 bits / s;
2) Next, the software was found and tested, which via the command line (cmd \ bat) sends text messages - NHSMS (link above);
3) Then it was necessary to somehow detect the events after which it was necessary to use written cmd files to send messages. Nncron (link above) with its scripts helped us here.

The nncron script can be configured through its configuration form:

image
image

Following the configuration, the file nncron.tab is formed. It is located in the root directory of the application 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 pings the NS-name every 5 minutes (the value can be changed, but if something falls off, if there is no ping, then the cmd-file works. The same applies
The cmd files themselves contain a message for sending SMS (for each server its own cmd file, so that it is 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 a message that comes to the phone (in Russian, I never managed to teach how to write a program — possibly due to the encoding of the cmd file, but that doesn't matter).

Actually, the modem itself looks like (what if someone has not seen):

image

Well, as a result:

image

I will note:
1) when the computer itself is disconnected 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 accessibility, but is it necessary in a small office;
2) nncron also has a polling function on the port - so you can configure for example the polling of significant TCP ports and in case of service collapse - SMS will also come;
3) it is advisable to power the computer with a 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 good!

Source: https://habr.com/ru/post/233883/


All Articles