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.

