Nagios, server monitor

From Andreida

install nagios on server

install the client on the watching system

apt-get install nagios3 nagios3-doc (nagios-statd-client ?)

Remember the password you are to give during the installation. The user for that password will be: nagiosadmin

go to your new nagios at http://<site>/nagios3

install nagios on client

this is not necessary, if you only want to watch via ping/ssh !


install the server on the watched system

 apt-get install nagios-statd-server

configure nagios

These services nagios is currently using:

/etc/nagios3/conf.d/*

And this is, how these services work:

/etc/nagios-plugins/config/*

To see the documentation in your nagios interface, make sure that in /etc/nagios3/apache2.conf the following line exists

DirectoryIndex index.php index.html

instead of sometimes

 DirectoryIndex index.php

searching for errors in the config

if you get errors when restarting nagios, for example after changing localhost to something meaningful:

nagios3 -v /etc/nagios3/nagios.cfg

You will then see, then you will have to change localhost to something else in other files (groups) too.

different ssh port

services_nagios2.cfg, change

check_command                   check_ssh

to

check_command                   check_ssh_port!1022!server

only the port is here dynamic it seems, the "server" is a hard coded word!

checking existence of ssl site without auth

define command{
  command_name    check_ssl_url_unauth
  command_line    /usr/lib/nagios/plugins/check_http --ssl -H '$HOSTADDRESS$' --no-body --expect 'HTTP/1.1 401 Unauthorized'  -u 'https://$HOSTADDRESS$$ARG1$'

use:

 define service{
   use                             generic-service         ; Name of service template to use
   host_name                       v-d8-svn
   service_description             Https
   check_command                   check_ssl_url_unauth!/yourRepositoryRoot/test
 }

nagios, adding a host

in /etc/nagios3/conf.d copy localhost_nagios2.cfg to yourhost.cfg and modify it. Then restart nagios. An easy way to "add" services to a host is to add the host via /etc/nagios3/conf.d/hostgroups_nagios2.cfg to a group. Just add comma seperated hosts.

If you want another group, like telnet-servers or so, add it in /etc/nagios3/conf.d/services_nagios2.cfg

But I do prefer to have all services for one host in the host file (/etc/nagios3/conf.d/MYHOST.cfg) so I only have to change one file per host. If you more often change hosts than services, this may be your way too.

Be sure to not show local services (like hard disc space) as if they were remote services, check twice !

nagios, adding a host without ping

  • copy generic-host-nagios2.cfg to generic-host-no-ping-but-YOUR-SERVICE-nagios2.cfg
  • rename the template host inside this new template file
  • change the check_command to something, which DOES exist. (http, ssh, whatever)
  • in the config file for the host without ping service, use the new template host via use.

Nagios Console Monitor

nslog=YourServer:/var/cache/nagios3/status.dat
remote.copy_cmd=scp -q -p -C %H:%F %D >%L 2>&1 ;  sed -i 's/status {/ {/g' %D
  • ./nsc.pl

The user who calls ./nsc.pl has to be able to ssh without password to the nagios server (ssh-keygen). He has to be able to cd to /var/cache/nagios3/, which means you will have to allow o+rx for /var/cache/nagios3/. He has to be able scp from HIS host the file to himself.


I need to do the above because the status.dat file is in a different format than the one the parser wants. If you need more information: http://rpm.pbone.net/index.php3/stat/45/idpl/16344088/numer/1/nazwa/nsc