2013-02-18 106 views
0

我有两个主机的nagios。一个是localhost(10.10.62.5),另一个是 ubuntu(10.10.62.10)。我在本地主机上设置了nagios监视器。发送SNMP陷阱到Nagios的特定主机

主机配置文件是以下

localhost.cfg:

define host{ 
    use      linux-server   
    host_name    localhost 
    alias     localhost 
    address     10.10.62.5 
    } 

define service{ 
host_name  localhost 
service_description WSN_COUNT 
is_volatile  1 
check_command  check-host-alive  
max_check_attempts 1 
normal_check_interval 1 
retry_check_interval 1 
active_checks_enabled 0 
passive_checks_enabled 1 
check_period  24x7  
notification_interval 31536000  
notification_period 24x7  
notification_options w,u,c 
notifications_enabled 1 
} 

ubuntu.cfg:

define host{ 
    use linux-server 
    host_name ubuntu 
    alias ubuntu 
    address 10.10.62.10 
} 
define service{ 
host_name localhost 
service_description WSN_COUNT 
is_volatile 1 
check_command check-host-alive 
max_check_attempts 1 
normal_check_interval 1 
retry_check_interval 1 
active_checks_enabled 0 
passive_checks_enabled 1 
check_period  24x7 
notification_interval 31536000  
notification_period 24x7  
notification_options w,u,c 
notifications_enabled 1 
} 

MIBfile:

NAGIOS-TRAP-TEST-MIB DEFINITIONS ::= BEGIN 
IMPORTS enterprises FROM SNMPv2-SMI; 

nagiostests OBJECT IDENTIFIER ::= { enterprises 0 } 
nagiostraps OBJECT IDENTIFIER ::= { nagiostests 1 } 
nagiosnotifs OBJECT IDENTIFIER ::= { nagiostests 2 } 

WSNcount NOTIFICATION-TYPE 
     OBJECTS { sysLocation } 
     STATUS current 
     DESCRIPTION "SNMPv2c notification" 
     ::= { nagiosnotifs 9 } 
END 

我用snmptt(NET- snmp)整合陷阱w ith nagios。配置文件是

snmptt.conf.local:

EVENT WSNcount .1.3.6.1.4.1.0.2.1 "Status Events" Normal 
FORMAT SNMPv2c notification $* 
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result localhost WSN_COUNT 1 "SNMPv2c notification $*" 
SDESC 
SNMPv2c notification 
Variables: 
    1: sysLocation 
EDESC 

snmptt.conf.local:

EVENT WSNcount .1.3.6.1.4.1.0.2.1 "Status Events" Normal 
FORMAT SNMPv2c notification $* 
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result ubuntu WSN_COUNT 1 "SNMPv2c notification $*" 
SDESC 
SNMPv2c notification 
Variables: 
    1: sysLocation 
EDESC 

当我发送从Ubuntu的陷阱(10.10.62.10)机使用下面的命令,陷阱发送给nagios的两个主机。

snmptrap -v 2c -c private 10.10.62.5 "" NAGIOS-TRAP-TEST-MIB::RFIDcount SNMPv2-MIB::sysLocation.0 s "snmptest trap" 

请帮我送陷阱特定主机..它是如何可能的?

+0

请帮助我一个人。 – sujin 2013-02-18 17:21:02

+0

您正在将10.10.62.10的SNMP陷阱发送到10.10.62.5,但Nagios将它显示给两台主机? – 2013-03-05 16:39:10

回答

1

我想你误解了一个SNMP陷阱是什么。 SNMP陷阱是从网络设备(如路由器,交换机,刀片,集群等)发送到您的监控系统/服务的SNMP消息。

我想要做的事情是搜索MIB文件用于要监视的特定网络设备,并搜索与您希望从该特定设备收集的信息相匹配的OID。

要通过SNMP监控的设备必须在其配置中启用SNMP(基于Web的或其他)。

你可以做一个snmpwalk的这种设备才能看到所有可用的OID:

snmpwalk -v 2c -c public <ip address network device> 

-c代表“社区”,默认情况下,这是“公”,你可以在配置编辑这个你网络设备。

-v表示您要使用的SNMP版本。

当你发现它提供了你,你穿在身上找您可以执行以下命令(或者把它放进一个Perl或bash脚本)设备的信息的OID:

snmpwalk -v 2c -c public <ip address network device> <OID> 

当你做这个脚本你可以在commands.cfg中为此脚本定义命令:

#'check_lefthand' command definition 
define command{   
    command_name check_lefthand 
    command_line $USER1$/lefthands.pl $ARG1$ $ARG2$ 
    } 

您现在可以在Nagios的服务定义中使用此check_。