我有nagios和两个主机。一个是localhost(10.10.62.5),另一个是ubuntu(10.10.62.10)。我在本地主机上设置了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)将陷阱与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
EDESCsnmptt.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"请帮助我将陷阱发送到特定的主机。怎么可能..。
发布于 2013-04-30 20:31:32
我想你误解了SNMP陷阱是什么。SNMP陷阱是从路由器、交换机、刀片、群集等网络设备发送到监控系统/服务的SNMP消息。
我猜您想要做的事情是在MIB文件中搜索您想要监视的特定网络设备,并搜索与您希望从该特定设备收集的信息相匹配的OID。
您想要通过SNMP监控的设备必须在其配置中启用SNMP (基于you或其他..)。
您可以对此设备执行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的服务定义中使用此check_。
https://stackoverflow.com/questions/14941612
复制相似问题