Adding Objects To Nagios 3.0 By: Mikhail Kniaziewicz
What is an Object in Nagios 3.0 Nagios has two types of objects Host Service Nagios has object inheritance like Object Orientated Programming Languages.
Directory Structure of Nagios 3.0 $USER1$ is the default Nagios command directory. Four our system that is: /opt/nagios/libexec Nagios global configuration files exist under /opt/nagios/etc Object directories are broken down as follows under /opt/nagios/etc/objects: command, timeperiods, services, eventhandlers and contacts.
Process Flow for Nagios 3.0 The heart of Nagios is in the directory: /var/opt/nagios/. When Nagios starts, restarts or reloads it reads all ”.cfg” files within the object directories. The objects are stored within the object.cache file. Current host and service statuses are stored in the status.dat file. Logs for historical trending are stored under the archive directory.
Object Monitoring Objects are monitored using two methods Active – Nagios request status Passive – Client sends status when a change occurs Nagios can monitor objects from two locations Locally – On the Nagios server Remotely – On the client using a daemon
Object Definition - Service Basically, services are comprised from any action that is not directly related to defining a host. Check a system's load average Checking partition or directory size Checking the number of users on a system Pinging a host is not considered a service object but rather a host object.
Object Definition - Service Send email to System Monitoring so they know you are working with a new object definition. Only work on objects during business hours to prevent alarming the World in the event you do not receive the desired results. Check for existing templates and objects so you utilize Nagios' object inheritance feature. Let EVERYONE in IT know about the object you created. Objects are created to benefit business functions and not one person.
Object Definition - Service Define the service to be monitored Check Nagios Exchange to see if a plugin already exists to monitor the service If plugin is located, load the plugin into /opt/nagios/libexec directory Run plugin with the –help flag to see options.
Object Definition - Service Run plugin locally until desired results are obtained Define command Define service from command Add host or hostgroups to be monitored Define contacts Define contact group Define timeperiod
Object Definition - Service Run command sudo /opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg to verify configuration files. If everything is fine. Add the newly defined object to /opt/nagios/etc/nrpe.cfg file on the client. Run sudo /etc/init.d/nagios reload. You should see the new object appear in the Pending catagory on the nagios screen.
Object Definition - Service After command runs, check the status within Nagios I would recommend triggering an event with the new command to test your contacts.
Summary Nagios consists of two objects: host and services Directory structure for the nagios process is: /var/opt/nagios/ while global configuration files can be found under /opt/nagios/etc/. Object definitions can be found under /opt/nagios/etc/objects Plugin commands can be found under /opt/nagios/libexec Abide by basic courtesies while creating objects. Define, create and test new objects.