Accurate time is always in need on your network so a good place to start monitoring is to start monitoring NTP with nagios. So far I have already defined an additional host but I have not defined services for that host within Nagios. The server is my time server so monitoring NTP will be a great starting point. We will start the journey looking at Nagios Plugins. The workers for Nagios are the plugins and many are provided with the out-of-the-box configuration. We can download others our create are own. To look at what we have lets change into the directory
cd /usr/lib/nagios/plugins
From here we can view the plugins but we can also run them manually
sudo /usr/lib/nagios/plugins/check_ntp_peer -H 192.168.0.8
Running the above command checks the NTP Service is running on the specified host. Automating this check means that we need to run this command through the configuration. Ubuntu already Has this file that will run several NTP plugins. The file is located at:
/etc/nagios-plugin/config/ntp.cfg
This directory is included in the main nagios.cfg so all files in the directory are also included as part of the nagios configuration. The ntp.cfg file defines the following commands
- check_ntp
- check_ntp_peer
- check_time
For our service definitions, what we want to monitor we can only reference commands and not the plugins directly. The commands defines what plugins will be run and with which parameters.
Define Service
Now we can define the service and I will do this is the host configuration I created in the previous exercise:
/etc/nagios3/conf.d/store.cfg
define host { host_name store.tup.local alias store address 192.168.0.8 max_check_attempts 3 check_period 24x7 check_command check-host-alive contacts root notification_interval 60 notification_period 24x7 } define service { host_name store.tup.local service_description NTP max_check_attempts 3 check_period 24x7 check_command check_ntp contacts root notification_interval 60 notification_period 24x7 retry_interval 5 check_interval 15 }
The new entry start with define service. here we check NTP every 15 minutes and retry after 5 minutes if we have a failure. The command we run is defines as check_ntp in this example.