Nagios NSClient++ per monitorare server Windows

Posted by Cristian | Posted in Nagios | Posted on 02-10-2009

0

NSClient++ è un agent per server windows disponibile per sistemi X32, X64 ed Itanium che permette a Nagios di eseguire innumerevoli check a servizi, processi e molto altro.

Una volta scaricata dal sito nsclient.org la versione corretta per il vostro sistema ed installata, basta personalizzare il file nsc.ini presente nella directory in cui è stato installato l’agent così da attivare i moduli aggiuntivi necessario ed impostare una password di sicurezza che non è obbligatoria ma a mio avviso vivamente consigliata.

E’ bene anche controllare le impostazioni del servizio che è stato creato NSClientpp e inpostare sul Log On il flag su Local System account e Allow service to interact with desktop.

nsclient

nsclient

Io ho installato una versione un pò vecchia, ho visto che ora c’è la 0.3.7…

Per attivare i moduli basta decommentare le righe associate ai moduli di cui si ha bisogno all’interno del file nsc.ini.

di seguito la parti minime da personalizzare sul file nsc.ini che comunque con l’ultima versione del client dovrebbe poter essere possibile impostare già dalla gui di installazione:

[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
;  You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; *                                                               *
; * N O T I C E ! ! ! – Y O U   H A V E   T O   E D I T   T H I S *
; *                                                               *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
NSCAAgent.dll
; LUA script module used to write your own “check deamon” (sort of) early beta.
LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
NRPEClient.dll
; Extreamly early beta of a task-schedule checker
CheckTaskSched.dll

[Settings]
;# OBFUSCATED PASSWORD
;  This is the same as the password option but here you can store the password in an obfuscated manner.
;  *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the
;  password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
;  This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.
password=
QUI INSERISCO LA PASSWORD A PROTEZIONE DELL’AGENT
;
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=
QUI INSERISCO L’IP DEL MIO SERVER NAGIOS
……….

Ora che lato windows abbiamo ultimato la configurazione è necessario definire l’host, i servizi da monitorare ed inserire nei check presenti sul file command.cfg la password messa a protezione del client NSclient installato sul server windows.

Di seguito tutte le definizioni da inserire nei file di configurazione lato Nagios.

Riga da aggiungere nel file degli hosts.cfg (che dovrà essere a sua volta incluso nel file di configurazione di nagios.cfg)

# Definizioni host 192.168.1.101
define host{
host_name                         192.168.1.101
alias                                      192.168.1.101
address                               192.168.1.101
check_command            check-host-alive
check_interval                5
retry_interval                 1
max_check_attempts  5
check_period                  24×7
contact_groups              admins
process_perf_data        0
retain_nonstatus_information    0
notification_interval           30
notification_period             24×7
notification_options           d,u,r
parents                                     192.168.1.1
}

Righe da aggiungere o modificare se già presenti nel file services.cfg

# Create a service for monitoring CPU USAGE
define service{
use                     generic-service
host_name               192.168.1.101
service_description     CPU Load
check_command           check_nt!CPULOAD!-l 5,80,90
}

# Create a service for monitoring ping
define service{
use                     generic-service
host_name               192.168.1.101
service_description     PING
check_command           check-host-alive
}

# Create a service for monitoring MEMORY USAGE
define service{
use                     generic-service
host_name               192.168.1.101
service_description     Memory Usage
check_command           check_nt!MEMUSE!-w 80 -c 90
}

# Create a service for monitoring C:\ disk usage
define service{
use                     generic-service
host_name               192.168.1.101
service_description     C:\ Drive Space
check_command           check_nt!USEDDISKSPACE!-l c -w 85 -c 95
}

# Create a service for monitoring S:\ disk usage
define service{
use                     generic-service
host_name               192.168.1.101
service_description     S:\ Drive Space
check_command           check_nt!USEDDISKSPACE!-l s -w 85 -c 95
}

# Create a service for monitoring sql server connections
define service{
use                     generic-service
host_name               192.168.1.101
service_description     SQL Server connection
check_command           check_nt_sql_server_connections
}

# Create a service for monitoring paging file useage
define service{
use                     generic-service
host_name               192.168.1.101
service_description     Utilizza file paging
check_command           check_nt_paging_file_useage
}

# Create a service for monitoring error logs
define service{
use                     generic-service
host_name               192.168.1.101
service_description     Error logs
check_command           check_nt_logon_errors
}

# Create a service for monitoring W3SVC service
define service{
use                     generic-service
host_name               192.168.1.101
service_description     W3SVC
check_command           check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

# Create a service for monitoring IIS Admin Service
define service{
use                     generic-service
host_name               192.168.1.101
service_description     IIS Admin Service
check_command           check_nt!SERVICESTATE!-d SHOWALL -l IISADMIN
}

# Create a service for monitoring HTTS SSL service
define service{
use                     generic-service
host_name               192.168.1.101
service_description     HTTP SSL
check_command           check_nt!SERVICESTATE!-d SHOWALL -l HTTPFilter
}

# Create a service for monitoring Windows TIME service
define service{
use                     generic-service
host_name               192.168.1.101
service_description     Servizio Windows TIME
check_command           check_nt!SERVICESTATE!-d SHOWALL -l W32Time
}

righe da aggiungere o modificare se già presenti nel file commands.cfg

# ‘check_nt’ command definition
define command{
command_name    check_nt
command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s
PASSWORD INSERITA NEL FILE NSC.INI -v $ARG1$ $ARG2$
}

# ‘check_nt’ command definition per error log
define command{
command_name     check_nt_logon_errors
command_line     $USER1$/check_nt -H $HOSTADDRESS$ -s
PASSWORD INSERITA NEL FILE NSC.INI -p 12489 -v COUNTER -l “\\Server\\Errors Logon”,”Logon Errors since last reboot is %.f” -w 50 -c 150
}

#Paging File Usage
define command{
command_name     check_nt_paging_file_useage
command_line     $USER1$/check_nt -H $HOSTADDRESS$ -s
PASSWORD INSERITA NEL FILE NSC.INI -p 12489 -v COUNTER  -l “\\Paging File(_Total)\\% Usage”,”Paging file usage is %.2f %%” -w 30 -c 60
}

#SQL Server Connections
define command{
command_name     check_nt_sql_server_connections
command_line     $USER1$/check_nt -H $HOSTADDRESS$ -s
PASSWORD INSERITA NEL FILE NSC.INI -p 12489 -v COUNTER -l “\\SQLServer:General Statistics\\User Connections”,”SQL Server Connections are %.f” -w 1500 -c 2000
}

In conclusione una volta installato e configurato NSClient, definito il nuovo host, i nuovi services e i nuovi commands sui rispettivi file di configurazione  richiamati  dal file di configurazione di Nagios basta fare un  /etc/init.d/nagios reload e se non ci sono errori si dovrebbe ottenere qualcosa del genere.

nagios

Write a comment