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

Principali file di configurazione in Nagios

Posted by Cristian | Posted in Nagios | Posted on 11-08-2009

0

Il file di configurazione di Nagios viene collocato di default sotto /etc/nagios/nagios.cfg – /usl/local/nagios/etc/nagios.cfg dipende dalla distribuzione che utilizzate.

Per una questione di ordine è a mio avviso meglio suddividere le configurazioni degli host, service, command, ecc. su diversi file ed includerli all’interno del nostro nagios.cfg come negli esempi che vedremo poi sotto e come suggerito anche dagli esempi commentati già presenti nel file nagios.cfg.

## —– ESTRATTO DAL FILE NAGIOS.CFG
# Definitions services and hosts
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg

cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/contact-group.cfg

cfg_file=/usr/local/nagios/etc/hosts-extinfo.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg

## ——- ESTRATTO DAL FILE HOSTS.CFG
# Definizioni host 192.168.0.101
define host{
host_name 192.168.0.101
alias 192.168.0.101
address 192.168.0.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.0.1
}

# Definizioni host 192.168.0.102 – Cisco VPNConcentrator
define host{
host_name 192.168.0.102
alias 192.168.0.102
address 192.168.0.102
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.0.1
}

# Definizioni host 192.168.0.103
define host{
host_name 192.168.0.103
alias 192.168.0.103
address 192.168.0.103
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.0.1
}

# Definizioni host 192.168.0.110
define host{
host_name 192.168.0.110
alias 192.168.0.110
address 192.168.0.110
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.0.1
}

# Definizioni host 62.149.140.117
define host{
host_name 62.149.140.117
alias 62.149.140.117
address 62.149.140.117
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
}

## ——- ESTRATTO DAL FILE SERVICE.CFG
# Create a service for monitoring CPU load 192.168.0.101 — occorre aver installato sull’host NSClient++
define service{
use generic-service
host_name 192.168.0.101
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

# Create a service for monitoring 192.168.0.101 — occorre aver installato sull’host NSClient++
define service{
use generic-service
host_name 192.168.0.101
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

# Create a service for monitoring C:\ disk usage 192.168.0.101 — occorre aver installato sull’host NSClient++
define service{
use generic-service
host_name 192.168.0.101
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 75 -c 95
}

# Create a service for monitoring the service 192.168.0.101 — occorre aver installato sull’host NSClient++
define service{
use generic-service
host_name 192.168.0.101
service_description NOME_SERVIZIO
check_command check_nt!SERVICESTATE!-d SHOWALL -l NOME_SERVIZIO
}

#Create a service server 192.168.0.103
define service{
use generic-service
host_name 192.168.0.103
service_description PING
check_command check-host-alive
}

#Create a service server 192.168.0.103
define service{
use generic-service
host_name 192.168.0.103
service_description TCP port 8080
check_command check_tcp!8080
}

#Create a service switch Cisco – 192.168.0.110
define service{
use generic-service
host_name 192.168.0.110
service_description CPU Utilizzata
check_command check_snmp!-C public -o 1.3.6.1.4.1.9.2.1.56.0 -l Status -w 80 -c 95
}

#Create a service switch Cisco – 192.168.0.110
define service{
use generic-service
host_name 192.168.0.110
service_description RAM libera
check_command check_snmp!-C public -o 1.3.6.1.4.1.9.9.48.1.1.1.6.1
}

#Create a service switch Cisco – 192.168.0.110
define service{
use generic-service
host_name 192.168.0.110
service_description RAM utilizzata
check_command check_snmp!-C public -o 1.3.6.1.4.1.9.9.48.1.1.1.5.1
}

#Create a service switch Cisco – 192.168.0.110
define service{
use generic-service
host_name 192.168.0.110
service_description UpTime
check_command check_snmp!-C public -o sysUpTime.0
}

#Create a service check www.smemorando.com
define service{
use generic-service
host_name 62.149.140.117
service_description PING
check_command check-host-alive
}

#Create a service check certificato www.smemorando.com
define service{
use generic-service
host_name 62.149.140.117
service_description Stato Certificato
check_command check_http_cert
}

#Create a service check www.smemorando.com
define service{
use generic-service
host_name 62.149.140.117
service_description HTTP
www.smemorando.com
check_command check_http_smemorando
}

# Create a service for monitoring via SNMP service 192.168.0.102 — occorre sia attivo l’snmp sull’host
define service{
use generic-service
host_name 192.168.0.102
service_description Temperature
check_command check_snmp!-l Temperature -o .1.3.6.1.4.1.3076.2.1.2.22.1.29.0,.1.3.6.1.4.1.3076.2.1.2.22.1.33.0 -w 37,:40 -c :40,:45
}

# Create a service for monitoring via SNMP service 192.168.0.102 — occorre sia attivo l’snmp sull’host
define service{
use generic-service
host_name 192.168.0.102
service_description Active VPN Sessions
check_command check_snmp!-l ActiveSessions -o 1.3.6.1.4.1.3076.2.1.2.17.1.7.0,1.3.6.1.4.1.3076.2.1.2.17.1.9.0 -w :70,:8 -c :75,:10
}

è possibile utilizzare snmpwalk per visualizzare gli OID di un host, la sintassi è questa [snmpwalk –c public –v 1 hostIP] per altre informazioni a riguardo guardate il man.

## —– ESTRATTO DAL FILE CONTACTS.CFG
define contact{
contact_name          nagiosadmin        ; Short name of user
use                              generic-contact        ; Inherit default values from generic-contact template (defined above)
alias                           Nagios Admin        ; Full name of user
email                         info@tuodominio.ext    ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

define contact{
contact_name         helpdesk             ; Short name of user
use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
alias                          Help Desk          ; Full name of user
email                         helpdesk
@tuodominio.ext ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

define contact{
contact_name          oem             ; Short name of user
use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
alias                          Oem          ; Full name of user
email                         oem
@tuodominio.ext ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

## —– ESTRATTO DAL FILE CONTACT-GROUP.CFG
define contactgroup{
contactgroup_name    admins
alias                              Administrators
members                       nagiosadmin,oem
}

define contactgroup{
contactgroup_name       operatore
alias                                  Operatore
members                            helpdesk
}

## —– ESTRATTO DAL FILE HOSTS-EXTINFO.CFG — PERSONALIZZAZIONE ICONE STATUS MAP
define hostextinfo{
host_name               NAGIOS
icon_image_alt          Nagios
icon_image              nagios.png
statusmap_image         nagios.gd2
}

define hostextinfo{
host_name               192.168.0.102
icon_image_alt          VPN Concentrator
icon_image              cisco3.png
statusmap_image         cisco3.gd2
}

define hostextinfo{
host_name               192.168.0.101,192.168.0.103
icon_image_alt          Server
icon_image              server2.png
statusmap_image         server2.gd2
}

define hostextinfo{
host_name               192.168.0.110
icon_image_alt          Switch
icon_image              switch.png
statusmap_image         switch.gd2
}

define hostextinfo{
host_name               62.149.140.117
icon_image_alt          Web Server Smemorando.com
icon_image              www_server.png
statusmap_image         www_server.gd2
}

## —– ESTRATTO DAL FILE TIMEPERIODS.CFG
define timeperiod{
timeperiod_name 24×7
alias           24 Hours A Day, 7 Days A Week
sunday          00:00-24:00
monday          00:00-24:00
tuesday         00:00-24:00
wednesday       00:00-24:00
thursday        00:00-24:00
friday          00:00-24:00
saturday        00:00-24:00
}

# ‘workhours’ timeperiod definition
define timeperiod{
timeperiod_name    workhours
alias        Normal Work Hours
monday        09:00-17:00
tuesday        09:00-17:00
wednesday    09:00-17:00
thursday    09:00-17:00
friday        09:00-17:00
}

# ‘none’ timeperiod definition
define timeperiod{
timeperiod_name    none
alias        No Time Is A Good Time
}

## —– ESTRATTO DAL FILE COMMANDS.CFG
# Check verifica stato certificato ssl www.smemorando.com
define command{
command_name    check_http_cert
command_line    $USER1$/check_http -H smemorando.com -S -C 30
}

tra qualche giorno la terza parte.