首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将SNMP陷阱发送到Nagios中的特定主机

将SNMP陷阱发送到Nagios中的特定主机
EN

Stack Overflow用户
提问于 2013-02-19 01:09:34
回答 1查看 3.7K关注 0票数 0

我有nagios和两个主机。一个是localhost(10.10.62.5),另一个是ubuntu(10.10.62.10)。我在本地主机上设置了nagios监视器。

主机配置文件如下

localhost.cfg:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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:

代码语言:javascript
复制
    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:

代码语言:javascript
复制
    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中的两台主机。

代码语言:javascript
复制
    snmptrap -v 2c -c private 10.10.62.5 "" NAGIOS-TRAP-TEST-MIB::RFIDcount SNMPv2-MIB::sysLocation.0 s "snmptest trap"

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-30 20:31:32

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

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

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

您可以对此设备执行SNMPwalk命令,以查看所有可用的OID:

代码语言:javascript
复制
snmpwalk -v 2c -c public <ip address network device>

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

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

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

代码语言:javascript
复制
snmpwalk -v 2c -c public <ip address network device> <OID>

创建此脚本时,您可以在commands.cfg中为此脚本定义命令:

代码语言:javascript
复制
#'check_lefthand' command definition
define command{        
    command_name    check_lefthand  
    command_line    $USER1$/lefthands.pl $ARG1$ $ARG2$
    }

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14941612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档