root@sz-yunfan:~# vi /usr/local/nagios/etc/nagios.cfg
启用下面这行配置
cfg_file=/usr/local/nagios/etc/objects/switch.cfg
2)配置 Nagios
需要做些对象定义用于监控新的交换机与路由器等网络设备。
打开 switch.cfg 配置文件进行配置
# vi /usr/local/nagios/etc/objects/switch.cfg
对被监控的交换机加一个新的主机对象定义。 编辑主机对象中的 host_name、alias 和 address 值。
define host{
use generic-switch
host_name 交换机名称
alias 交换机别名
address 核心交换机ip地址
hostgroups 主机组成员
}
3)监控丢包率和 RTA
增加服务定义配置,用于监控被 Nagios 监控主机到交换机的丢包率和平均回包周期 RTA,检测周期一般是每 5 分钟。
define service{
use generic-service
host_name RG6806E
service_description PING
check_command check_ping! 200.0,20%! 600.0,60%
normal_check_interval 5
retry_check_interval 1
}
Nagios 监控系统实现了网络服务系统重要信息的监控,提供了可靠的、稳定的应用服务,保证了网络服务的正常运行。解决了日常网络服务器管理的繁杂工作,释放了大量的人工管理工作时间。 Nagios 监控系统能准确记录、定位并及时报警,为解决网络操作系统故障提供了宝贵的时间,同时也将故障导致服务中断的时间降低至最低。有效、可靠的报警为网络服务的正常运行提供了良好的保障。
/usr/local/nagios/etc/nagios.cfg
define host{
use generic-switch,hosts-pnp ; Inherit default values from a template
host_name switch ; The name we're giving to this switch
alias Linksys SRW224P Switch ; A longer name associated with the switch
address 192.168.32.25 ; IP address of the switch
hostgroups switches ; Host groups this switch is associated with
}
define hostgroup{
hostgroup_name switches ; The name of the hostgroup
alias Network Switches ; Long name of the group
}
define service{
use generic-service,services-pnp ; Inherit values from a template
host_name switch ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
#监控SNMP状态信息
# Monitor uptime via SNMP
define service{
use generic-service ; Inherit values from a template
host_name switch
service_description Uptime
check_command check_snmp! -C public -o sysUpTime.0
}
监控端口带宽和流量
define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p
service_description Port 1 Link Status
check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
# Monitor bandwidth via MRTG logs
define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p
service_description Port 1 Bandwidth Usage
#check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.20.25_1.log!AVG!1000000,1000000!5000000,5000000!10
}