From 10f682b4974e7ca77cd94a305dd4df56148267b0 Mon Sep 17 00:00:00 2001 From: Ryan Armstrong Date: Wed, 17 Aug 2016 11:33:49 +0800 Subject: [PATCH] Added support for OIDs without the . prefix --- mib2zabbix.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mib2zabbix.pl b/mib2zabbix.pl index 00c876c..4125fac 100755 --- a/mib2zabbix.pl +++ b/mib2zabbix.pl @@ -17,7 +17,7 @@ Export loaded SNMP MIB OIDs to Zabbix Template XML -G, --group=STRING template group (default: 'Templates') -e, --enable-items enable all template items (default: disabled) - -o, --oid=STRING OID tree root to export (must start with '.') + -o, --oid=STRING OID tree root to export -v, --snmpver=1|2|3 SNMP version (default: 2) -p, --port=PORT SNMP UDP port number (default: 161) @@ -758,6 +758,10 @@ $SNMP::save_descriptions = 1; SNMP::initMib(); # Verify the specified OID exists +if ($opts->{ oid } !~ m/^\./) { + $opts->{ oid } = "." . $opts->{ oid } +} + my $oid_root = $SNMP::MIB{ $opts->{ oid } }; if (!$oid_root || $oid_root->{ objectID } ne $opts->{ oid }) { print STDERR "OID $opts->{ oid } not found in MIB tree.\n";