Skip to content

Introduction to Nagios Plugin Development and Simple Nagios Configuration

If you are looking this page, I thought that you need help about Nagios, and you might not find enough examples for developing your own plugin. Do not worry about this. I will explain how to write plugin for Nagios and run it on Nagios.

 

As all of you know, we can say that Nagios is basically a web monitoring tool. We can trace server behaviors (CPU, RAM, Hard Disk etc…), network status, web services and web links working status etc… If any negative situation (defined in plugin or your configuration) happens on the system, Nagios alerts and sends a detailed feedback about problem with email. Admin can configure Nagios to check the system freshness by a specific time interval.

Plugin for Nagios: There are 3 situations in Nagios. Admin should categorize the all situation that will be exists. If a condition happens during the system freshness checking, Nagios will display status of system via any result of these conditions (OK, CRITICAL, WARNING). And printing information will be shown as information about the happened condition.

General Plugin Development Definition:

  • Condition: successful

Print(“System is working properly.”);

exit(0); // successful: system is working properly

  • Condition: not successful

Print(“System is working properly, service answers too slowly!”);

exit(1); // warning: system is not working properly, is working slowly or there will be a critical situation in the near future.

  • Condition: not successful and

Print(“System is not working, request is failed!”);

exit(2); // critical: system is not working, there is an emergency situation.

Freshness Time Interval Configuration: Edit “Nagios.cfg” file and find the configuration line as at the blow. Change the interval time with a reasonable interval time for your system. Also it is possible to change other configuration options, but wrong configuration may cause  failure!!!

# HOST AND SERVICE CHECK REAPER FREQUENCY

# This is the frequency (in seconds!) that Nagios will process

# the results of host and service checks.

check_result_reaper_frequency=3600

3600 means; Nagios will check your system every hour.