Monitoraggio di sistemi Windows con Nagios: Difference between revisions

From RVM Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 5: Line 5:
* Scaricare il client Windows [http://nsclient.org/nscp/downloads NSClient++]ed installarlo:
* Scaricare il client Windows [http://nsclient.org/nscp/downloads NSClient++]ed installarlo:
  cd %TEMP%
  cd %TEMP%
  C:\Cygwin\bin\wget http://files.nsclient.org/x-0.3.x/NSClient%2B%2B-Win32-0.3.6.zip
  C:\Cygwin\bin\wget http://files.nsclient.org/stable/NSCP-0.4.1.105-Win32.msi
mkdir %SYSTEMDRIVE%\NSClient++
start NSCP-0.4.1.105-Win32.msi
"%PROGRAMFILES%\7-zip\7z" x -o%SYSTEMDRIVE%\NSClient++ NSClient*.zip
 
DEL NSClient*.zip
* Selezionare installazione completa
* Selezionare
:*sample checks
:*nrpe
:*wmi


  cd %SYSTEMDRIVE%\NSClient++
  cd %SYSTEMDRIVE%\NSClient++
Line 16: Line 20:
   NSClient++ SysTray install
   NSClient++ SysTray install


* Open the  
* Open the  
  services manager and make sure the
  services manager and make sure the
Line 82: Line 85:


*Definizione del comando sulla macchina Linux NRPE intermedia.
*Definizione del comando sulla macchina Linux NRPE intermedia.
Installare il pugin NRPE:
Installare il plugin NRPE:
  sudo apt-get install nagios-nrpe-plugin
  sudo apt-get install nagios-nrpe-plugin



Revision as of 17:48, 14 July 2014

Configurazione dell'agente sulla macchina Windows da monitorare

  • Da prompt di DOS (su suppone Cygwin installato con wget e unzip)
  • Scaricare il client Windows NSClient++ed installarlo:
cd %TEMP%
C:\Cygwin\bin\wget http://files.nsclient.org/stable/NSCP-0.4.1.105-Win32.msi
start NSCP-0.4.1.105-Win32.msi
  • Selezionare installazione completa
  • Selezionare
  • sample checks
  • nrpe
  • wmi
cd %SYSTEMDRIVE%\NSClient++
nsclient++ /install
  • Abilitare l'usco della SysTray:
 NSClient++ SysTray 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
%SYSTEMDRIVE%\NSClient++\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

    • In the
[Settings]

section, uncomment the

allowed_hosts = 192.168.1.254/32

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

Installazione Plugin Windows aggiuntivi

  • Scompattarli in
%SYSTEMDRIVE%\NSClient++\scripts
  • Modificare NSC.INI, scommentando i valori di default per NRPE:
[NRPE]
port=5666
command_timeout=60
allow_arguments=0
use_ssl=1
script_dir=scripts\
socket_timeout=30
  • Definire il comando da richiamare (Bug della 0.3.6: tutti i comandi presenti in scripts\ dovrebbero essere disponibili senza essere dichiarati qui)
[NRPE Handlers]
command[check_virusscan.exe]=scripts\check_virusscan.exe
  • Verificare che il plugin funzioni (Versione minima 8.5)
cd \NSClient++\scripts
check_virusscan
  • Definizione del comando sulla macchina Linux NRPE intermedia.

Installare il plugin NRPE:

sudo apt-get install nagios-nrpe-plugin

Il plugin va richiamato con il nome completo del file, esempio:

check_virusscan.exe

Esempio:

command[check-mansrv01-mcafee]=/usr/lib/nagios/plugins/check_nrpe -H mansrv01 -c check_virusscan.exe

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

Plugin Windowsupdate

  • Inizializzare il DB lanciando:
C:\NSClient++\scripts\inspect_onlineupdates.exe -d C:\NSClient++\scripts\onlineupdates.db
  • Schedulare ogni 15 minuti sul server windows l'esecuzione del comando
C:\NSClient++\scripts\inspect_onlineupdates.exe -d C:\NSClient++\scripts\onlineupdates.db
  • Configurare il comando nrpe
command[check-nrpe]=/usr/lib/nagios/plugins/check_nrpe -H $ARG1$ -c $ARG2$
  • Richiamare da server nagios il check con:
define service{
        use                             generic-service
        host_name                       ronchett-nt.ronchetti.priv
        service_description             WINUPDATE
        check_command                   check-nrpe-remote!check_onlineupdates.exe
        }

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