将SNMP陷阱发送到Nagios中的特定主机
我有两台主机的nagios。一个是localhost(10.10.62.5),另一个是 ubuntu(10.10.62.10)。我在本地主机上设置了nagios监视器 主机配置文件如下所示 localhost.cfg:将SNMP陷阱发送到Nagios中的特定主机,snmp,nagios,net-snmp,Snmp,Nagios,Net Snmp,我有两台主机的nagios。一个是localhost(10.10.62.5),另一个是 ubuntu(10.10.62.10)。我在本地主机上设置了nagios监视器 主机配置文件如下所示 localhost.cfg: define host{ use linux-server host_name localhost alias localhost
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(netsnmp)将陷阱与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
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
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
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"
请帮助我将陷阱发送给特定的主机。。怎么可能 我认为您误解了SNMP陷阱是什么。SNMP陷阱是从网络设备(如路由器、交换机、刀片、群集等)发送到监控系统/服务的SNMP消息 我猜您要做的是在MIB文件中搜索要监视的特定网络设备,并搜索与要从该特定设备收集的信息相匹配的OID 要通过SNMP监控的设备必须在其配置中启用SNMP(基于Web或其他方式) 您可以对此设备执行SNMPwalk以查看所有可用的OID:
snmpwalk -v 2c -c public <ip address network device>
您现在可以在Nagios的服务定义中使用此检查。请帮助我。您正在从10.10.62.10发送SNMP陷阱到10.10.62.5,但Nagios会为两台主机显示它吗?