=== INIZIO CONFIGURAZIONE ===
Prerequisito: net-snmp installato sull’host che si desidera monitorare (nell’esempio seguente CentOS release 5.6).
Nota: il pacchetto net-snmp potrebbe avere nomi differenti a seconda della distribuzione (es. Debian e derivate: sudo apt-get install snmpd)
Installazione snmp sull’host che si desidera monitorare
yum install net-snmp
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
crea un nuovo file /etc/snmp/snmpd.conf con il seguente contenuto
rocommunity public 192.168.1.0/24
rocommunity public 127.0.0.1
disk /
Abbi cura di modificare la porzione network in modo tale che il subnet identificato sia quello contenente anche l’IP del site controller che effettuerà il monitiraggio.
Nota: per consentire al site controller di interrogare l’snmpd che gira sull’host che si desidera monitorare è necessario quantomeno aprire la porta UDP 161 (se il firewall è disabilitato puoi saltare questo step).
chkconfig snmpd on
service snmpd start
puoi ora effettuare un test sul localhost appena configurato eseguendo:
snmpwalk -v 1 -c public localhost
o dal site controller:
snmpwalk -v 1 -c public <IP_DEL_CLIENT_DA_MONITORARE>
In entrambe i casi dovresti vedere centinaia di righe di informazioni snmp.
Ora sul site controller crea questo folder (oppure seleziona tu la locazione che ritieni più corretta)
mkdir -pv /etc/nagios/customer/RTC/snmp
Sotto il folder appena creato popola con i seguenti 4 file:
# cat snmp-host.cfg
### HOSTS ###
define host{
use linux-server
host_name snmp-host-name
alias SNMP-HOST-NAME
address 192.168.1.101
}
avendo cura di modificare host_name, alias e address
# cat snmp-hostgroup.cfg
### HOSTGROUPS ###
define hostgroup {
hostgroup_name snmp-servers
alias SNMP MONITORED SERVERS
members snmp-host-name
}
avendo cura dirimpiazzare members con l’host_name definito in snmp-host.cfg
Infine:
# cat commands.cfg
# LOAD
define command{
command_name snmp_1minute_load
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.1 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define command{
command_name snmp_5minute_load
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.2 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define command{
command_name snmp_15minute_load
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.3 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
# RAM/SWAP
define command{
command_name snmp_SwapSize
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.3.0 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define command{
command_name snmp_SwapFree
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.4.0 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define command{
command_name snmp_RamSize
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.5.0 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define command{
command_name snmp_RamFree
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.6.0 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
# DISKS
#Get the mount point of the first disk (usually /)
define command{
command_name snmp_Disk1_Mount
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.2.1 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
#Get the size of the first disk (usually /)
define command{
command_name snmp_Disk1_Size
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.6.1 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
#Get the usage of the first disk (usually /)
define command{
command_name snmp_Disk1_Usage
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.8.1 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
#Get the usage as a percentage of the first disk (usually /)
define command{
command_name snmp_Disk1_UsedPercentage
command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.9.1 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
## ADVANCED DISK CONFGURATION
## This section is to monitor additional mountpoints/disks
## Uncomment it and add a line to your client snmpd.conf file
## disk /path/to/the/mountpoint
## then restart snmpd on client
## Get the mount point of the second disk
#define command{
# command_name snmp_Disk2_Mount
# command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.2.2 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
#}
#
## Get the size of the second disk
#define command{
# command_name snmp_Disk2_Size
# command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.6.2 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
#}
#
## Get the usage of the second disk
#define command{
# command_name snmp_Disk2_Usage
# command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.8.2 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
#}
#
## Get the usage as a percentage of the second disk
#define command{
# command_name snmp_Disk2_UsedPercentage
# command_line $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.9.2 -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
#}
Seguito da:
# cat services.cfg
# LOAD
define service{
use generic-service
hostgroup_name snmp-servers
service_description CPU 01 Minute Average
check_command snmp_1minute_load!-C public!-w 5!-c 10
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description CPU 05 Minute Average
check_command snmp_5minute_load!-C public!-w 5!-c 10
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description CPU 15 Minute Average
check_command snmp_15minute_load!-C public!-w 5!-c 10
}
# RAM/SWAP
define service{
use generic-service
hostgroup_name snmp-servers
service_description Swap Size
check_command snmp_SwapSize!-C public
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description Swap Free
check_command snmp_SwapFree!-C public!-c @0:250000
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description RAM Size
check_command snmp_RamSize!-C public!-w @0:50000
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description RAM Free
check_command snmp_RamFree!-C public
}
# DISKS
define service{
use generic-service
hostgroup_name snmp-servers
service_description Disk 1 Mountpoint
check_command snmp_Disk1_Mount!-C public
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description Disk 1 Size
check_command snmp_Disk1_Size!-C public
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description Disk 1 Usage
check_command snmp_Disk1_Usage!-C public
}
define service{
use generic-service
hostgroup_name snmp-servers
service_description Disk 1 Usage Percentage
check_command snmp_Disk1_UsedPercentage!-C public!-w 80!-c 90
}
#
## ADVANCED DISK CONFGURATION
## This section is to monitor additional mountpoints/disks
## Uncomment it and add a line to your client snmpd.conf file
## disk /path/to/the/mountpoint
#
#define service{
# use generic-service
# hostgroup_name snmp-servers
# service_description Disk 2 Mountpoint
# check_command snmp_Disk2_Mount!-C public
#}
#define service{
# use generic-service
# hostgroup_name snmp-servers
# service_description Disk 2 Size
# check_command snmp_Disk2_Size!-C public
#}
#define service{
# use generic-service
# hostgroup_name snmp-servers
# service_description Disk 2 Usage
# check_command snmp_Disk2_Usage!-C public
#}
#define service{
# use generic-service
# hostgroup_name snmp-servers
# service_description Disk 2 Usage Percentage
# check_command snmp_Disk2_UsedPercentage!-C public!-w 80!-c 90
#}
# NON SNMP BASED ADDITIONAL SRVICES CHECKS
define service {
use generic-service
hostgroup_name snmp-servers
service_description FTP
check_command check_ftp
}
define service {
use generic-service
hostgroup_name snmp-servers
service_description WEB SERVER
check_command check_http
}
Per cominciare il monitoraggio effettua un check sintattico:
nagios -v /etc/nagios/nagios.cfg
seguito da un nagios reload
service nagios reload
=== FINE CONFIGURAZIONE ===