From RootdevWiki
Contents |
What is Nagios
Nagios is an Open Source host, service and network monitoring program which is used for monitoring the production environment.
It is a modular system which allows us to write custom plugins for specific monitoring requirements - whether these be for monitoring a particular service or port, or running checks on a home grown application.
How do I pronounce that?
It's pronounced nah-ghee-os or nah-ghee-ose
Not: nah-jee-oh, the nah-jee-oh, nah-zhee-o, nah-zhee-os, or anything else.
Deal with it!
Writing Nagios Plugins
Dos and Don'ts
- All Nagios plugins should follow the official guidelines (see below)
They can be written in pretty much any language you like. I use perl because it is the operational language in most places I have worked and therefore the defacto standard.
It just so happens that there are existing guidelines and standards for writing perl plugins, as well as supplied modules, notably utils.pm, to provide standard functions.
If you are asked to write a nagios plugin don't simply embark on it in your own preferred fashion. Chances are if you do so you will:
- Spend a significant amount of time reinventing the wheel
- Have to do far more work than need be
- End up with bloated code
- Write unclear code that someone else will have to spend an unnecessary amount of time trying to decipher
Examples
At the bare minimum, all plugin scripts should start as follows:
#!/usr/bin/perl -w # Comment describing plugin functionality and the task it is expected to fulfil # Author name and date use lib "/etc/nagios/libexec"; use utils qw( %ERRORS ); use strict;
There are other functions available in the utils module but the %ERRORS should be considered fundamental
Reference
Read this before embarking on any plugin development: