Writing commands to send notifications
Another part of Nagios that can be extended to fit your needs are notifications. These are messages that Nagios sends out whenever a problem occurs, or is resolved.
One way in which the Nagios notification system can be expanded is to create template-based e-mail sending. This will send notifications as both plain text and HTML messages. The template of the e-mail will be kept in separate files.
We will use two npm libraries: handlebars
(http://handlebarsjs.com) for template processing and emailjs
(https://github.com/eleith/emailjs) for the e-mail sending functionality.
E-mails that contain content in multiple formats need to be wrapped in the multipart/alternative
MIME type. This type will contain two sub-parts—first the plain text version, and following this is the HTML version. This order makes e-mail clients choose HTML over plain text if both the types are supported. For the sake of example, we will ignore plain text.
In the same way as how...