Monitoraggio di sistemi Windows con Nagios

From RVM Wiki
Jump to navigation Jump to search

Configurazione dell'agente sulla macchina Windows da monitorare:

  • Da prompt di DOS (su suppone Cygwin installato con wget e unzip)
  • Scaricare il client Windows ed installarlo:
cd %TEMP%
wget http://files.nakednuns.org/x-0.3.x/NSClient%2B%2B-Win32-0.3.2.zip
mkdir %SYSTEMDRIVE%\NSClient++
unzip NSClient++-Win32-0.3.2.zip -d %SYSTEMDRIVE%\NSClient++
DEL NSClient++-Win32-0.3.2.zip
cd %SYSTEMDRIVE%\NSClient++
nsclient++ /install

  • Open the services manager and make sure the NSClientpp service is allowed to interact with the desktop (see the 'Log On' tab of the services manager). If it isn't already allowed to interact with the desktop, check the box to allow it to.
  • Edit the NSC.INI file (located in the C:\NSClient++ directory) and make the following changes:
    • Uncomment all the modules listed in the [modules] section, except for CheckWMI.dll and RemoteConfiguration.dll
    • Optionally require a password for clients by changing the 'password' option in the [Settings] section.
    • In the [Settings] section, uncomment the 'allowed_hosts' option. Add the IP address of the Nagios server to this line, or leave it blank to allow all hosts to connect.
    • In the [NSClient] section, make sure the 'port' option is uncommented and set to '12489' (the default port).
  • Avviare l'agente in test
nsclient++.exe /test

Se non ci sono messaggi di errore, digitare

exit
  • Avviare l'agente
nsclient++.exe /start

Si deve vedere l'icona nella Systray

Configurazione dell'agente monitorante Linux

SI suppone di voler monitorare il tutto da una macchina linux, la quale è interrgata poi via NRPE da un server centrale Nagios.

  • Verificare che si stata completata la configurazione dei NRPE
HOSTTOCHECK=192.168.1.100
  • Testare il ping
/usr/lib/nagios/plugins/check_fping $HOSTTOCHECK
FPING OK - $HOSTTOCHECK (loss=0%, rta=0.380000 ms)|loss=0%;;;0;100 rta=0.000380s;;;0.000000
  • Testare che NSClient++ sia accessibile da questa macchina Linux:
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -v CLIENTVERSION -p 12489
NSClient++ 0.3.2.9 2008-05-17

Testare anche i comandi che si vorranno monitorare:

  • Per verificare che l'agente sia attivo:
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -v CLIENTVERSION -p 12489 
NSClient++ 0.3.2.9 2008-05-17
  • Per l'Uptime
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -v UPTIME -p 12489
System Uptime - 85 day(s) 16 hour(s) 34 minute(s)
  • Per il CPU Load
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -p 12489 -v CPULOAD -l 5,80,90
CPU Load 14% (5 min average) |   '5 min avg Load'=14%;80;90;0;100
  • Per l'utilizzo di memoria
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -p 12489 -v MEMUSE -w 80 -c 90
Memory usage: total:1255.98 Mb - used: 651.92 Mb (52%) - free: 604.06 Mb (48%) | 'Memory usage'=651.92Mb;1004.78;1130.38;0.00;1255.98
  • Per lo spazio sul disco C:
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -p 12489 -v USEDDISKSPACE -l c -w 80 -c 90
c:\ - total: 4.88 Gb - used: 4.48 Gb (92%) - free 0.40 Gb (8%) | 'c:\ Used Space'=4.48Gb;3.90;4.39;0.00;4.88
  • Per lo spazio sul disco D:
/usr/lib/nagios/plugins/check_nt -H $HOSTTOCHECK -p 12489 -v USEDDISKSPACE -l d -w 80 -c 90
d:\ - total: 29.00 Gb - used: 22.10 Gb (76%) - free 6.90 Gb (24%) | 'd:\ Used Space'=22.10Gb;23.20;26.10;0.00;29.00
  • Se tutto è corretto, aggiungere i comandi in nrpe_local.cfg
sudoedit /etc/nagios/nrpe_local.cfg

command[check-manserver-ping]=/usr/lib/nagios/plugins/check_fping 192.168.1.100
command[check-manserver-nsclient]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v CLIENTVERSION
command[check-manserver-uptime]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v UPTIME p 12489
command[check-manserver-cpuload]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v CPULOAD -l 5,80,90
command[check-manserver-memuse]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v MEMUSE -w 80 -c 90
command[check-manserver-disk-c]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v USEDDISKSPACE -l c -w 80 -c 90
command[check-manserver-disk-d]=/usr/lib/nagios/plugins/check_nt -H 192.168.1.100 -p 12489 -v USEDDISKSPACE -l d -w 80 -c 90
  • Riavviare nrpe
sudo /etc/init.d/nagios-nrpe-server restart

Configurazione del Server Nagios

  • Testare se nrpe riesce ad colloquiare con l'host linux monitorante:
/usr/lib/nagios/plugins/check_nrpe -H man.rvmgroup.it -c check-manserver-ping
FPING OK - 192.168.1.100 (loss=0%, rta=0.380000 ms)|loss=0%;;;0;100 rta=0.000380s;;;0.000000
  • Definire l'host: dato che l'host Windows da monitorare non è raggiungibile, si deve definire l'host con un comando di monitoraggio fittizio che dia sempre host up, e dargli l'IP pubblico raggiungibile della macchina linux monitorante:


    • Definire il comando di host checking:

sudoedit /etc/nagios/misccommands.cfg

define command{
        command_name    check-host-dummy-up
        command_line    $USER1$/check_dummy 0 -H $HOSTADDRESS$
        }
    • Definire quindi l'host:
sudoedit /etc/nagios/hosts.cfg

define host{
        use                     generic-host
        host_name               manserver.mannesmann.priv
        alias                   Mannesmann Server
        address                 man.rvmgroup.it
        check_command           check-host-dummy-up
        }

Assegnare l'host ad un nuovo gruppo:

sudoedit /etc/nagios/hostgroups.cfg

define hostgroup{
        hostgroup_name  Mannesmann
        alias           Thyssenkrupp Mannex
        contact_groups  nagios-admins
        members         manserver.mannesmann.priv
        }

Definire i servizi da monitorare:

sudoedit /etc/nagios/services.cfg

define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             PING
        check_command                   check-nrpe!check-manserver-ping
        }
define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             NSCLIENT
        check_command                   check-nrpe!check-manserver-nsclient
        }

define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             UPTIME
        check_command                   check-nrpe!check-manserver-uptime
        }

define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             CPULOAD
        check_command                   check-nrpe!check-manserver-ping
        }
define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             MEMUSE
        check_command                   check-nrpe!check-manserver-memuse
        }

define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             DISK-C
        check_command                   check-nrpe!check-manserver-disk-c
        }

define service{
        use                             generic-service
        host_name                       manserver.mannesmann.priv
        service_description             DISK-D
        check_command                   check-nrpe!check-manserver-disk-d
        }


  • Testare la configurazione e riavviare:
sudo nagios -v /etc/nagios/nagios.cfg
sudo /etc/init.d/nagios restart

Riferimenti