Book Image

Learning Nagios 4

By : Wojciech Kocjan
Book Image

Learning Nagios 4

By: Wojciech Kocjan

Overview of this book

Table of Contents (19 chapters)
Learning Nagios 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 Nagios' notification system can be expanded is to create template-based e-mails. These 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 Tcl for this purpose as it contains libraries for MIME (http://tcllib.sourceforge.net/doc/mime.html) and SMTP (http://tcllib.sourceforge.net/doc/smtp.html) functionality. The first one allows the creation of structured e-mails, whereas the latter one is used to send these using an SMTP server.

E-mails that contain content in multiple formats need to be wrapped in the multipart/alternative MIME type. This type will contain two subparts: first the plain text version and then the HTML version. This order makes e-mail clients choose HTML over plain text if both the...