Book Image

Learning Nagios 3.0

Book Image

Learning Nagios 3.0

Overview of this book

Table of Contents (16 chapters)
Learning Nagios 3.0
Credits
About the Author
About the Reviewer
Preface

Writing Plugins the Right Way


We have already created a few sample scripts, and they're working. So it is possible to use them from Nagios. But these checks are very far from being complete. They lack error control, parsing, and argument verification.

It is recommended that you write all the commands in a more user-friendly way. The reason is that, in most cases, after some time, someone else will take over your custom check commands. You might also come back to your own code after a year of working on completely different things. In such cases, having a check command that is user friendly, commented, and allows debugging will save a lot of time.

The first thing that should be done to provide the proper handling of arguments — this means using functionality such as the getopt package for Python (http://www.python.org/doc/2.5/lib/module-getopt.html) or the cmdline package for Tcl (http://tcllib.sourceforge.net/doc/cmdline.html) to parse the arguments. This way, functionality such as --help...