Update mib2zabbix.pl

Missing ValueMap in item template for Zabbix v2.4
This commit is contained in:
Steven Yu 2016-08-30 11:11:43 +10:00 committed by GitHub
parent 2f8de1afe9
commit 8d66732e27

View file

@ -4,22 +4,16 @@
mib2zabbix.pl - SNMP MIB to Zabbix Template mib2zabbix.pl - SNMP MIB to Zabbix Template
=head1 SYNOPSIS =head1 SYNOPSIS
mib2zabbix.pl -o <OID> [OPTIONS]... mib2zabbix.pl -o <OID> [OPTIONS]...
Export loaded SNMP MIB OIDs to Zabbix Template XML Export loaded SNMP MIB OIDs to Zabbix Template XML
-f, --filename=PATH output filename (default: stdout) -f, --filename=PATH output filename (default: stdout)
-N, --name=STRING template name (default: OID label) -N, --name=STRING template name (default: OID label)
-G, --group=STRING template group (default: 'Templates') -G, --group=STRING template group (default: 'Templates')
-e, --enable-items enable all template items (default: disabled) -e, --enable-items enable all template items (default: disabled)
-o, --oid=STRING OID tree root to export -o, --oid=STRING OID tree root to export
-v, --snmpver=1|2|3 SNMP version (default: 2) -v, --snmpver=1|2|3 SNMP version (default: 2)
-p, --port=PORT SNMP UDP port number (default: 161) -p, --port=PORT SNMP UDP port number (default: 161)
SNMP Version 1 or 2c specific SNMP Version 1 or 2c specific
-c, --community=STRING SNMP community string (default: 'public') -c, --community=STRING SNMP community string (default: 'public')
SNMP Version 3 specific SNMP Version 3 specific
-L, --level=LEVEL security level (noAuthNoPriv|authNoPriv|authPriv) -L, --level=LEVEL security level (noAuthNoPriv|authNoPriv|authPriv)
-n, --context=CONTEXT context name -n, --context=CONTEXT context name
@ -39,7 +33,6 @@ Zabbix item configuration
--trends=DAYS trends retention in days (default: 365) --trends=DAYS trends retention in days (default: 365)
Help Help
-h, --help print this message -h, --help print this message
=head1 DESCRIPTION =head1 DESCRIPTION
B<mib2zabbix.pl> will export a loaded MIB tree into a Zabbix Template starting B<mib2zabbix.pl> will export a loaded MIB tree into a Zabbix Template starting
@ -214,7 +207,6 @@ GetOptions(
'z|zabbix_ver=i' => \$opts->{ zabbix_ver}, # Zabbix version 'z|zabbix_ver=i' => \$opts->{ zabbix_ver}, # Zabbix version
'check-delay=i' => \$opts->{ delay }, # Update interval in seconds 'check-delay=i' => \$opts->{ delay }, # Update interval in seconds
'disc-delay=i' => \$opts->{ disc_delay }, # Update interval in seconds 'disc-delay=i' => \$opts->{ disc_delay }, # Update interval in seconds
'history=i' => \$opts->{ history }, # History retention in days 'history=i' => \$opts->{ history }, # History retention in days
@ -293,6 +285,7 @@ my %item_template_v2 = (
multiplier => '0', # Enable multiplier multiplier => '0', # Enable multiplier
trends => $opts->{ trends }, # Trends retention in days trends => $opts->{ trends }, # Trends retention in days
units => '', units => '',
valuemap => ''
); );
if ( $opts->{zabbix_ver} == 3 ) { if ( $opts->{zabbix_ver} == 3 ) {
@ -564,6 +557,7 @@ sub node_to_item {
# Assign value map to item # Assign value map to item
$item->{valuemap} = { name => $map_name }; $item->{valuemap} = { name => $map_name };
} }
} }
return $item; return $item;
@ -869,7 +863,6 @@ sub build_template {
else { else {
# No need for Indexer to be added in Zabbix 2.4 # No need for Indexer to be added in Zabbix 2.4
if ( $proto->{name} !~ m/Index/ ) { if ( $proto->{name} !~ m/Index/ ) {
push(@{ $disc_rule->{ item_prototypes } }, $proto); push(@{ $disc_rule->{ item_prototypes } }, $proto);
} }
} }
@ -942,6 +935,7 @@ if (!$oid_root || $oid_root->{ objectID } ne $opts->{ oid }) {
@{ $template->{ applications } } = map { { name => $_ } } keys %{ $template->{ apptags } }; @{ $template->{ applications } } = map { { name => $_ } } keys %{ $template->{ apptags } };
delete($template->{ apptags }); delete($template->{ apptags });
# Build XML document # Build XML document
my $time = time(); my $time = time();
@ -1018,6 +1012,7 @@ if (!$oid_root || $oid_root->{ objectID } ne $opts->{ oid }) {
} }
); );
} }
if ($opts->{ filename }) { if ($opts->{ filename }) {
close $fh; close $fh;
} }