SNMP 监控

SNMP 监控

我尝试在 CentOS 中配置 SNMP 陷阱,但没有得到积极的结果。

目的:在 SNMP 代理上配置 SNMP 陷阱,以检查文件是否存在并将消息发送至 SNMP 服务器。

为了测试目的,我把“出口 1“ 进入/tmp/script1.sh而是检查某个文件是否存在。

下面是我的配置文件:

rocommunity  public
trapcommunity public
group MyROGroup v2c        readonly
view all    included  .1                               80
access MyROGroup ""      any       noauth    exact  all    none   none
createUser testMonitor SHA testMonitor AES
rouser testMonitor
rwuser testMonitor
iquerySecName testMonitor
extend MyScript1 /tmp/script1.sh
monitor -r 60 "RunScript" .1.3.6.1.4.1.8072.1.3.2.3.1.4.9.77.121.83.99.114.105.112.116.49 !=0
monitor -r 60 "RunMyScript" nsExtendNumEntries.0 !=

snmpwalk -v2c -c 公共本地主机 NET-SNMP-EXTEND-MIB::nsExtendObjects

回到:

NET-SNMP-EXTEND-MIB::nsExtendResult。“MyScript1”= INTEGER:1

snmpwalk -v2c -c 公共本地主机 NET-SNMP-EXTEND-MIB::nsExtendObjects -On

回到:

.1.3.6.1.4.1.8072.1.3.2.1.0 = 整数:1 .1.3.6.1.4.1.8072.1.3.2.2.1.2.9.77.121.83.99.114.105.112.116.49 = 字符串:/tmp/script1.sh .1.3.6.1.4.1.8072.1.3.2.2.1.3.9.77.121.83.99.114.105.112.116.49 = 字符串: .1.3.6.1.4.1.8072.1.3.2.2.1.4.9.77.121.83.99.114.105.112.116.49 = 字符串: .1.3.6.1.4.1.8072.1.3.2.2.1.5.9.77.121.83.99.114.105.112.116.49 = 整数:5 .1.3.6.1.4.1.8072.1.3.2.2.1.6.9.77.121.83.99.114.105.112.116.49 = 整数:exec(1) .1.3.6.1.4.1.8072.1.3.2.2.1.7.9.77.121.83.99.114.105.112.116.49 = 整数:读取时运行(1) .1.3.6.1.4.1.8072.1.3.2.2.1.20.9.77.121.83.99.114.105.112.116.49 = 整数:永久(4) .1.3.6.1.4.1.8072.1.3.2.2.1.21.9.77.121.83.99.114.105.112.116.49 = 整数:活动(1) .1.3.6.1.4.1.8072.1.3.2.3.1.1.9.77.121.83.99.114.105.112.116.49 = 字符串: .1.3.6.1.4.1.8072.1.3.2.3.1.2.9.77.121.83.99.114.105.112.116.49 = 字符串: .1.3.6.1.4.1.8072.1.3.2.3.1.3.9.77.121.83.99.114.105.112.116.49 = 整数:1 .1.3.6.1.4.1.8072.1.3.2.3.1.4.9.77.121.83.99.114.105.112.116.49 = 整数:1 .1.3.6.1.4.1.8072.1.3.2.4.1.2.9.77.121.83.99.114.105.112.116.49.1 = 字符串:

日志档案:

Nov 30 17:20:44 localhost snmpd[29291]: NET-SNMP version 5.3.2.2
Nov 30 17:20:44 localhost snmpd[29291]: Received SNMP packet(s) from callback: 1 on fd 4
Nov 30 17:20:44 localhost snmpd[29291]: snmp_build: unknown failure
Nov 30 17:20:44 localhost snmpd[29291]: snmpd: send_trap: Error building ASN.1 representation (wrong type in snmp_realloc_rbuild_var_op: 0)
Nov 30 17:20:44 localhost snmpd[29291]: snmp_build: unknown failure
Nov 30 17:20:44 localhost snmpd[29291]: snmpd: send_trap: Error building ASN.1 representation (wrong type in snmp_realloc_rbuild_var_op: 0)

我的问题:

如何正确配置 snmpd.conf 以自动检查 /tmp/script1.sh 退出代码以及如何将信息发送到 SNMP 服务器(snmptrapd)

此致!

相关内容