Nagios监控cisco2960交换机硬件以及运行状态

前提条件:
1. Cisco交换机都支持SNMP协议,只需要简单的设置即可开启。

2. 在安装Nagios之前,必须已经安装Net-Utils及其开发组件。成功安装Nagios之后,再次检查libexec目录下有check_snmp命令。

由于使用check_snmp检测的结果不够人性化,大部分的结果都需要重新调整。使用Perl脚本调用NET::SNMP模块,实现收集监控结果,并重新输出,更易阅读和使用。

采取其他的插件监控

check_snmp_cisco_ifstatus、check_snmp_cisco_loadavg、check_snmp_cisco_memutil、check_snmp_cpfw.pl

vim switch.cfg增加

##########################################################
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960,lan_2960
service_description  Environment
check_command  check_snmp_env!public
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960,lan_2960
service_description  LoadAVG
check_command  check_snmp_cisco_cpu!public!60!80
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960,lan_2960
service_description  Memutil
check_command  check_snmp_cisco_mem!public!70!90
}

########################################################

# Define the switch that we’ll be monitoring

define host{
use  generic-switch  ; Inherit default values from a template
host_name  wan_2960  ; The name we’re giving to this switch
address  ip  ; IP address of the switch
hostgroups  switches  ; Host groups this switch is associated with
}

define host{
use  generic-switch  ; Inherit default values from a template
host_name  lan_2960  ; The name we’re giving to this switch
address  10.10.10.141  ; IP address of the switch
hostgroups  switches  ; Host groups this switch is associated with
}

###########################################################

# Create a new hostgroup for switches

define hostgroup{
hostgroup_name  switches  ; The name of the hostgroup
alias  Network Switches  ; Long name of the group
}

###########################################################

# Create a service to PING to switch

define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960  ; 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
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  lan_2960  ; 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
}

# Monitor uptime via SNMP

define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960
service_description  Uptime
check_command  check_snmp!-C public -o sysUpTime.0
}

define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  lan_2960
service_description  Uptime
check_command  check_snmp!-C public -o sysUpTime.0
}
#
#
## Monitor Port 1 status via SNMP
#
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960
service_description  Port 1 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10101 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960
service_description  Port 3 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10103 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  wan_2960
service_description  Port 19 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10119 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  wan_2960
service_description  check_1_traffic
check_command  check_traffic!10101!4000,5000!6000,7000
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  wan_2960
service_description  check_3_traffic
check_command  check_traffic!10103!4000,5000!6000,7000
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  wan_2960
service_description  check_19_traffic
check_command  check_traffic!10119!4000,5000!6000,7000
}

########################################lan_2960############################
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  lan_2960
service_description  Port 3 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10103 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  lan_2960
service_description  Port 5 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10105 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp ; Inherit values from a template
host_name  lan_2960
service_description  Port 7 Link Status
check_command  check_snmp!-C public -o ifOperStatus.10107 -r 1 -m RFC1213-MIB
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  lan_2960
service_description  check_3_traffic
check_command  check_traffic!10103!40000,50000!60000,70000
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  lan_2960
service_description  check_5_traffic
check_command  check_traffic!10105!40000,50000!60000,70000
}
define service{
use  generic-service,srv-pnp  ; Name of service template to use
host_name  lan_2960
service_description  check_7_traffic
check_command  check_traffic!10107!40000,50000!60000,70000
}

image12

 

此条目发表在Nagios分类目录。将固定链接加入收藏夹。