【问题标题】:Send SNMP trap to particular host in Nagios向 Nagios 中的特定主机发送 SNMP 陷阱
【发布时间】:2013-02-18 17:09:34
【问题描述】:

我有两个主机的 nagios。一个是 localhost(10.10.62.5),另一个是 ubuntu(10.10.62.10)。我在 localhost 上设置了 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
}

MIB 文件:

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) 将陷阱与 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"

请帮助我将陷阱发送到特定主机.. 怎么可能...

【问题讨论】:

  • 请帮帮我。
  • 您正在从 10.10.62.10 向 10.10.62.5 发送 SNMP 陷阱,但 Nagios 为两台主机都显示它?

标签: snmp nagios net-snmp


【解决方案1】:

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

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

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

您可以对该设备执行 SNMPwalk 以查看所有可用的 OID:

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

-c 代表“社区”,默认为“公共”,您可以在网络设备的配置中对其进行编辑。

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

当您找到 OID 时,可以为您提供您正在寻找的设备信息,您可以执行以下命令(或将其放入 perl 或 bash 脚本中):

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 的服务定义中使用此检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    相关资源
    最近更新 更多