mib2zabbix icon indicating copy to clipboard operation
mib2zabbix copied to clipboard

Not all traps was imported from MIB to XML

Open romale opened this issue 6 years ago • 5 comments

Hi Ryan, I've receive snmp trap from my devices, and after research i tried to convert mib file to zabbix xml, but not all trap entry was imported to xml file.

Example trap messages (from snmptt.log): 13:39:05 2018/06/04 FCMGMT-MIB::connUnitPortStatusChange Normal "General event" 10.1.1.232 - ZBXTRAP 10.1.1.232 general failure offline 13:39:05 2018/06/04 FCMGMT-MIB::connUnitPortStatusChange Normal "General event" 10.1.1.233 - ZBXTRAP 10.1.1.233 general failure offline 13:42:10 2018/06/04 FCMGMT-MIB::connUnitPortStatusChange Normal "General event" 10.1.1.233 - ZBXTRAP 10.1.1.233 general failure offline 13:42:10 2018/06/04 FCMGMT-MIB::connUnitPortStatusChange Normal "General event" 10.1.1.232 - ZBXTRAP 10.1.1.232 general failure offline

Example trap messages (from snmptrapd.log): 2018-06-04 13:31:51 10.1.1.232(via UDP: [10.1.1.232]:57541->[172.1.1.1]:162) TRAP, SNMP v1, community public experimental.94 Enterprise Specific Trap (6) Uptime: 359 days, 7:39:40.55 experimental.94.1.10.1.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.369098964 = INTEGER: 1 experimental.94.1.10.1.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.369098964 = INTEGER: 3 2018-06-04 13:31:51 10.1.1.233(via UDP: [10.1.1.233]:18726->[172.1.1.1]:162) TRAP, SNMP v1, community public experimental.94 Enterprise Specific Trap (6) Uptime: 359 days, 5:42:48.85 experimental.94.1.10.1.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.369098964 = INTEGER: 1 experimental.94.1.10.1.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.369098964 = INTEGER: 3 2018-06-04 13:35:02 10.1.1.232(via UDP: [10.1.1.232]:57541->[172.1.1.1]:162) TRAP, SNMP v1, community public experimental.94 Enterprise Specific Trap (6) Uptime: 359 days, 7:42:51.49 experimental.94.1.10.1.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.527958784 = INTEGER: 5 experimental.94.1.10.1.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.527958784 = INTEGER: 3 2018-06-04 13:35:02 10.1.1.233(via UDP: [10.1.1.233]:18726->[172.1.1.1]:162) TRAP, SNMP v1, community public experimental.94 Enterprise Specific Trap (6) Uptime: 359 days, 5:45:58.93 experimental.94.1.10.1.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.528024320 = INTEGER: 5 experimental.94.1.10.1.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.528024320 = INTEGER: 3

Mib file: http://www.oidview.com/mibs/0/FCMGMT-MIB.html

And after converting, no any mentions about connUnitPortStatusChange in XML file.

Could you help me?

Thanks

romale avatar Jun 09 '18 12:06 romale

I can imagine one of two problems happening here:

  1. Zabbix doesn't support all types of traps, so the script might be skipping them deliberately
  2. The trap you desire does not exist in the portion of the MIB tree (root OID) you are exporting.

Try adding some logging to the script to see if your trap is being processed and what is happening to it. Also, try grepping the MIB files for connUnitPortStatusChange so you can see where it lives and what types it is composed of.

cavaliercoder avatar Jun 11 '18 20:06 cavaliercoder

# grep -i connUnitPortStatusChange FCMGMT-MIB.mib
    connUnitPortStatusChange TRAP-TYPE 
# grep -i connUnitPortStatusChange FCMGMT-MIB.xml
# echo $?
1
#

From my first post, we can see in "snmptt" output, that FCMGMT-MIB file parsed correctly and translated to human readable format.

Unfortunately, i'm not perl developer, i was try debug your script, but it isn't easy for me. Bash or python i can (on user-level), but not perl.

romale avatar Jun 13 '18 08:06 romale

Understood. I'll take a look to try understanding what is going wrong. For reference, can you please provide the exact commands you are using to generate the Zabbix templates?

cavaliercoder avatar Jun 13 '18 16:06 cavaliercoder

I use this command

mib2zabbix.pl -o .1.3.6.1.3.94 -G CUSTOM-TEMPLATES -v 2 > FCMGMT-MIB.xml

And some examples, that show if MIB in the right location:

# snmptranslate .1.3.6.1.3.94
fcmgmt
# snmptranslate .1.3.6.1.3.94.5
connUnitServiceSet

romale avatar Jun 14 '18 07:06 romale

Disregard this. I found that it's all ok ~~I have same issue. I generated xml template, but found, that's not all OID included in my template.~~

~~That's how i was generating:~~

$ snmptranslate -Tz -m ./Shtyl-MIB_UPS2-06.mib  | ./mib2zabbix.pl -o ".1.3.6.1.4.1.34498.2.6" -f "./Template Shtyl UPS auto.xml" -e -G UPS -N "Template Shtyl UPS" -v 3 -L authNoPriv -n main -a SHA --disc-delay=3600 --history=90 --trends=365
Smartmatch is experimental at ./mib2zabbix.pl line 475.

~~Now, after realizing that not all OID included i made oneline script to find which of them:~~

~~$ for oid in $(snmptranslate -Tz -m ./Shtyl-MIB_UPS2-06.mib | grep -oE "1.3.6.1.4.1.34498.2.6[0-9,\.]+"); do echo -n $(snmptranslate -Onf $oid)"("$oid"): "; if grep -q "$oid" "Template Shtyl UPS auto.xml"; then echo "present"; else echo "absent"; fi; done~~

~~....~~ ~~My MIB file is:~~ ~~Shtyl-MIB_UPS2-06.mib.zip~~

rafaelrs avatar Jul 10 '20 19:07 rafaelrs