1

I trying configure SNMP trap in CentOS without positive result.

Purpose: Configure SNMP trap on SNMP Agent for checking if file exist and send message to SNMP Server.

For testing purposes I've put "exit 1" into /tmp/script1.sh instead checking if some file exist.

Below my is config file:

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 public localhost NET-SNMP-EXTEND-MIB::nsExtendObjects

Returned:

NET-SNMP-EXTEND-MIB::nsExtendResult."MyScript1" = INTEGER: 1

snmpwalk -v2c -c public localhost NET-SNMP-EXTEND-MIB::nsExtendObjects -On

Returned:

.1.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1 .1.3.6.1.4.1.8072.1.3.2.2.1.2.9.77.121.83.99.114.105.112.116.49 = STRING: /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 = STRING: .1.3.6.1.4.1.8072.1.3.2.2.1.4.9.77.121.83.99.114.105.112.116.49 = STRING: .1.3.6.1.4.1.8072.1.3.2.2.1.5.9.77.121.83.99.114.105.112.116.49 = INTEGER: 5 .1.3.6.1.4.1.8072.1.3.2.2.1.6.9.77.121.83.99.114.105.112.116.49 = INTEGER: 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 = INTEGER: run-on-read(1) .1.3.6.1.4.1.8072.1.3.2.2.1.20.9.77.121.83.99.114.105.112.116.49 = INTEGER: permanent(4) .1.3.6.1.4.1.8072.1.3.2.2.1.21.9.77.121.83.99.114.105.112.116.49 = INTEGER: active(1) .1.3.6.1.4.1.8072.1.3.2.3.1.1.9.77.121.83.99.114.105.112.116.49 = STRING: .1.3.6.1.4.1.8072.1.3.2.3.1.2.9.77.121.83.99.114.105.112.116.49 = STRING: .1.3.6.1.4.1.8072.1.3.2.3.1.3.9.77.121.83.99.114.105.112.116.49 = INTEGER: 1 .1.3.6.1.4.1.8072.1.3.2.3.1.4.9.77.121.83.99.114.105.112.116.49 = INTEGER: 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 = STRING:

Log file:

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)

My questions:

How to properly configure snmpd.conf for automatically check what is /tmp/script1.sh exit code and how to send information to SNMP Server (snmptrapd)

Best regards!

jackaaxc
  • 11
  • 2

0 Answers0