Besides local notifications, which were represented in the article «Integrating NetPing into the Monitoring System The Dude by Microtik», The Dude can perform almost any actions upon events through external applications. Let us show this on the example of configuring e-mail notifications.
Configuring E-mail Notifications in the Monitoring System The Dude
The monitoring system The Dude has a built-in system of e-mail notifications, but it can work only with SMTP servers without authorization. We will use the service Gmail to send e-mail notifications, where SMTP authorization is required. To do this, we will use a free SMTP client – mailsend).
Let us examine the example of a configuration for Windows OS.
After downloading an SMTP client, there is a need to unpack the application, for example, into the directory of installing the monitoring system The Dude:
- «C:\Program Files (x86)\Dude\mailsend» – for 64 bit versions of Windows OS;
- «C:\Program Files\Dude\mailsend» – for 32 but versions of Windows OS
After extracting the archive with the application, the application will have a version number in its name – rename it into «mailsend.exe». In the same directory create a file «mailsend.cmd» with the next contents:
:: Send email notifications from Dude via Gmail :: set mailsenderdir=C:\Program Files (x86)\Dude\mailsend set mailsender=mailsend.exe set email@example.com set smtpsenderfullname=TheDude set smtpserver=smtp.gmail.com set smtpport=465 set firstname.lastname@example.org set smtppwd=password set email@example.com :: :: "%mailsenderdir%\%mailsender%" -smtp %smtpserver% -port %smtpport% -ssl -auth -user %smtpuser% -pass %smtppwd% -t %mailto% -f %smtpsender% -name "%smtpsenderfullname%" +cc +bc -q -sub %1 -M %2 :: ::pause ::
There is a need to change the next values in the script for own ones:
- smtpsender – is an e-mail, from which emails will be sent;
- smtpsenderfullname – a sender's name;
- smtpuser – a sender's e-mail;
- smtppwd – a password from e-mail sender. If a two-step authorization is enabled, generate a password for an application;
- mailto – is an e-mail, where notifications will be sent
Then let us go to the settings of the monitoring system The Dude. In the section «Notifications» let us add a new notification (icon with a red plus):
Let's fill in the fields the next way:
- Name: email
- Type: execute on server
- Command: "C:\Program Files (x86)\Dude\mailsend\mailsend.cmd" "Service [Probe.Name] on [Device.Name] is now [Service.Status]" "Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])"
As a result of clicking the button «Test», a test notification will be sent to the specified e-mail.
You can get a letter from Google with the subject «An attempt to sign in has been blocked». To unblock the application, there is a need to sign into the settings of the Google account https://myaccount.google.com/, and then go to the point «Sign in Google account» and enable the option «Unreliable applications are allowed». Also, sometimes a transition to the address https://accounts.google.com/DisplayUnlockCaptcha may be required as well as entering a security code of a third party application. Afterwards, sending notifications must be fulfilled without errors.
Then enable a new type of notifications for each of the controlled services: temperature and humidity sensors. To do this, there is a need to go to the section «Devices», click a mouse twice on the name of a device «dude.netping.ru», go to the tab «Services» in the opened window and click a mouse twice on the first sensor. In the new window go to «Notifications» and enable a new type of notifications – «email». There is a need to repeat this procedure for each sensor.
Therefore after exceeding a threshold value of readings of one of the sensor a corresponding notification will be sent to the email specified in the script.
Using the example of the script used in the article, it is possible to implement any external logic on notifying through executing an external program or starting a script for controlling third-party devices. For example, it is possible to run an external program for sending SMS notifications to the specified phone number.
Other Features of the Monitoring System The Dude
Besides active notifications or executing an external logic, The Dude performs internal logging. All logs are located in the section «Logs»:
- Action – is a log, where events on changing a configuration of devices, services, sensors, etc. are represented;
- Debug – is a debugging log, where a detailed information on events, actions and enabled debugging mode is stored;
- Event – is an event log. The information on exceeding threshold values from different sensors, starting/stopping the Dude service by its users is represented here.
Logs may be exported in a CSV format for a further analysis. Also, sometimes there is a need to send events into external storage besides local logging. To do this, supporting a Syslog protocol is implemented. A configuration is performed the same as for any other notifications, in the section «Notifications». There is a need to choose the type «syslog» and indicate a server address for sending event logs.