This document is the third in my series on nagios. In the first one I discussed what Nagios is, the second one discussed the installation of nagios. This one will discuss writing custom check scripts (plugins). Finally a fourth is a howto on creating event handlers.
One of the beauties of Nagios, is that there is a large amount of freely available plugins available online, http://exchange.nagios.org/directory/Plugins
However in the unlikely event of you not being able to find what you require, it is quite easy to write your own custom plugins.
In the howto I will show you how to write a plugin to monitor the number of huge_pages in use on your system, so as to alert with a warning once a certain threshold is breached, followed by a critical alert once a higher threshold is reached. These thresholds will be passed into the script as parameters, so that you can re-use this plugin across multiple systems with differing threshold requirements.
First I will show you the whole script, and then afterwards explain its operation: