View Full Version : Tool for bulkloading a template with snmpwalk data
I just started testing out ZABBIX yesterday (1.1a6) and had a need to bulk load large amounts of snmpwalk data into ZABBIX templates using vendor specific MIBs. Manually adding hundreds of items for a template through the UI could take a while and I didn't notice a ZABBIX provided tool that did this. So, I wrote a simple loader. It works in my test environment for the equipment I'm using, but I suspect that it may need changes for other MIBs and environments. Please read the code for more details and use at your own risk as this hasn't been tested very much yet :)
Also, I haven't bothered to write the snmptranslate in perl so '-m all' is quite expensive each time snmptranslate loads. It's best to just -m the MIBs you care about.
Thanks,
Steven
#!/usr/bin/perl
####################################
#
# zload_snmpwalk
# Author: Steven Dossett
# Email: sd at panath.com
#
####################################
# Disclaimer:
# This script has only been used with ZABBIX 1.1alpha6. It isn't thoroughly
# tested. It isn't very efficient. It may eat your database or cause other
# unintentional harm. Be careful and use at your own risk.
# Please share bug fixes and improvements that you make...
#
# See usage instructions by running: zload_snmpwalk -h
#
# Description:
# Creating new ZABBIX host templates can be time consuming. This script
# automates some of the process by loading snmpwalk data into a ZABBIX
# template. It is very important to use a MIB so that keys and descriptions
# for the data are usable. MIBs can be specified on the command line or
# snmpwalk may find them via your MIBS environment variable. The template
# items will need modification from the ZABBIX UI after bulk loading. The
# script doesn't attempt to manage interesting things like 'units' or 'custom
# multipliers'. The script also has a limited notion of what qualifies as
# 'Character' data and defaults to 'Numeric' for just about everything.
# Update the script to properly identify more types.
#
# An example session might work like the following:
#
# 1 - Create a new host template in the Zabbix UI. Make note of the ID for the
# new template.
# 2 - Use an additional -T option to test the examples in 2a and 2b.
# 2a - Build an initial set of items for the template. In the example below
# the template id 10015 is used:
# zload_snmpwalk -m SOMEVENDOR-MASTER-MIB secretstring dbuser dbpass 10015 somehost .iso.org.dod.internet.private
# 2b - Alternatively, the template can be created from saved snmpwalk data:
# zload_snmpwalk -m SOMEVENDOR-MASTER-MIB secretstring dbuser dbpass 10015 somefile
# For the option above, the data must be in 'snmpwalk -Of' format.
# 3 - Next, the template should be tweaked and tested from the Zabbix UI before
# applying to hosts.
#
use Getopt::Std;
use DBI;
use strict;
use vars qw($PROG $VERSION $community $host $mib $usagetxt %OPTS
$dbhost $dbuser $dbpass $zabbix_db $zabbix_id $translate $dbh
$zabbix_port $zabbix_delay $zabbix_history $zabbix_trends
$TEST);
$VERSION = "1.0";
$PROG = "zload_snmpwalk";
$usagetxt = qq {
USAGE:
$PROG [OPTIONS] <community> <dbuser> <dbpasswd> <zabbix_id> <agent> <oid>
$PROG [OPTIONS] <community> <dbuser> <dbpasswd> <zabbix_id> <file>
Version: $VERSION
snmpwalk the target <agent> from the starting <oid> and then store the results
in the ZABBIX template <zabbix_id>. Alternatively, a <file> containing the
output of a previous snmpwalk can be used. The data is expected in the format
generated by 'smpwalk -Of' and should be generated using the appropriate MIB(s)
so that meaningful descriptions can be created for ZABBIX. Without using a
MIB, the attempt will likely fail as the descriptions used for ZABBIX keys will
be duplicated.
Be sure to test your data with the -T option first!
BASIC ENVIRONMENT REQUIREMENTS:
Zabbix 1.1alpha6 - Not tested with any other versions.
perl - Tested with 5.8.0
Mysql & perl DBI - Might work with postgres after minor changes.
net-snmp - Tested with net-snmp 5.0.8
PRIMARY ARGUMENTS:
<community> SNMP community string
<dbuser> DB user that can update ZABBIX tables
<dbpasswd> DB password for the user
<zabbix_id> Zabbix template id for a template created from the UI
DATA SOURCES:
<agent> Target SNMP host/agent
<oid> Beginning oid - example: .iso.org.dod.internet.private
OR
<file> File containing snmpwalk data in '-Of' format to be loaded
OPTIONS:
-T Test Mode. No DB updates - just view the new records.
-v 1|2c SNMP version
-m MIB[:...] load given list of MIBs (ALL loads everything)
-p port SNMP port, default is 161
Database or ZABBIX data related options:
-r delay SNMP polling delay, default is 60
-h history How long to keep polling history, default is 7
-t trends How long to keep polling trends, default is 365
-s server Database server, default is localhost
-d database Database, default is zabbix
};
sub connect_db {
my $db = "DBI:mysql:$zabbix_db:$dbhost";
$dbh = DBI->connect($db, $dbuser, $dbpass) ||
die "Can't connect to DB: $dbh->errstr\n";
$dbh->{AutoCommit} = 0;
}
sub get_zabbix_description
{
my $raw_oid = shift(@_);
my $pos;
# Step back 2 positions for a description string and key
$pos = rindex($raw_oid,'.');
$pos = rindex($raw_oid,'.',$pos - 1);
return substr($raw_oid, $pos + 1);
}
sub get_zabbix_oid
{
my $raw_oid = shift(@_);
my $zabbix_oid = `$translate $raw_oid`;
chomp($zabbix_oid);
return $zabbix_oid;
}
sub get_zabbix_value_type
{
my $snmp_type = shift(@_);
my $zabbix_value_type;
# Zabbix types
# 0 = Numeric
# 1 = Character
# Add additional character types as needed. More are needed..
SWITCH:
{
if ($snmp_type eq "STRING")
{ $zabbix_value_type = 1; last SWITCH; }
$zabbix_value_type = 0;
}
return $zabbix_value_type;
}
sub usage
{
print $usagetxt;
exit 0;
}
MAIN:
$| = 1; # no print delay
my $input;
my $sql;
my $tcounter = 0;
if (!getopts('d:h:m:p:r:s:t:u:v:T', \%OPTS))
{
usage();
}
if (@ARGV == 5 || @ARGV == 6)
{
$TEST = exists($OPTS{T}) ? "1" : "0";
$community = $ARGV[0];
$dbuser = $ARGV[1];
$dbpass = $ARGV[2];
$zabbix_id = $ARGV[3];
$dbhost = exists($OPTS{s}) ? ($OPTS{s}) : "localhost";
$zabbix_db = exists($OPTS{d}) ? ($OPTS{d}) : "zabbix";
$zabbix_port = exists($OPTS{p}) ? ($OPTS{p}) : "161";
$zabbix_delay = exists($OPTS{r}) ? ($OPTS{r}) : "60";
$zabbix_history = exists($OPTS{h}) ? ($OPTS{h}) : "7";
$zabbix_trends = exists($OPTS{t}) ? ($OPTS{t}) : "365";
$translate = "snmptranslate -Ofn ";
$translate .= exists($OPTS{m}) ? ("-m $OPTS{m} ") : "";
# Input from file by default, might change below
$input = "<$ARGV[4]";
}
else
{
usage();
};
# Data from live snmpwalk
if (@ARGV == 6)
{
$host = $ARGV[4];
$input = "snmpwalk -c $community ";
$input .= exists($OPTS{m}) ? ("-m $OPTS{m} ") : "";
$input .= exists($OPTS{v}) ? ("-v $OPTS{v} ") : "";
# Host
$input .= "-Of $host";
$input .= exists($OPTS{p}) ? (":$OPTS{p} ") : ":161 ";
# OID
$input .= "$ARGV[5]|";
}
connect_db();
open(SWALK,$input) or die "Can't open $input\n";
print "Processing Data from $input ";
$sql = $dbh->prepare("INSERT INTO items (type, snmp_community, snmp_oid, snmp_port, hostid, description, key_, delay, history, trends, value_type) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
while(my $line = <SWALK>)
{
my $zabbix_value_type;
my $zabbix_description;
my $zabbix_oid;
next if ($line !~ /(.iso.org.dod.*) = (.*):/ );
#$1 = oid string to translate
#$2 = integer, string or other snmp type
#More snmp "character" types should be added
$zabbix_description = get_zabbix_description($1);
$zabbix_oid = get_zabbix_oid($1);
$zabbix_value_type = get_zabbix_value_type($2);
if ($TEST)
{
if (($tcounter++ % 10) == 0)
{
print "\ntype\tsnmp_community\tsnmp_oid\tsnmp_port\t",
"hostid\tdescription\tkey_\tdelay\t",
"history\ttrends\tvalue_type\n";
}
print "4\t$community\t$zabbix_oid\t$zabbix_port\t",
"$zabbix_id\t$zabbix_description\t",
"$zabbix_description\t$zabbix_delay\t",
"$zabbix_history\t$zabbix_trends\t",
"$zabbix_value_type\n";
}
else
{
print "." if (($tcounter++ % 10) == 0 );
$sql->execute(4, $community, $zabbix_oid, $zabbix_port,
$zabbix_id, $zabbix_description, $zabbix_description,
$zabbix_delay, $zabbix_history, $zabbix_trends,
$zabbix_value_type) || die "Insert Failure: $sql->strerror\n";
}
}
close(SWALK);
$dbh->commit();
$dbh->disconnect();
print "Finished\n";
exit 0;
Hi,
I am trying this with version 1.1 but it is failing with a duplicate entry fault.
/usr/bin/perl zload_snmpwalk.pl -v 2c -m all <community> <dbuser> <dbpassword> 10007 <ipaddress> .iso.org.dod.internet.private.enterprises.3375.2
Processing Data from snmpwalk -c public -m all -v 2c -Of <ipaddress>:161 .iso.org.dod.internet.private.enterprises.3375.2| ...DBD::mysql::st execute failed: Duplicate entry '10007-1.0' for key 2 at zload_snmpwalk.pl line 252, <SWALK> line 30.
Insert Failure: DBI::st=HASH(0x796f20)->strerror
any Ideas, or alternatives???
thanks
Ian
***EDIT***
Ok it works
:o
How did you get around this problem? :confused:
Has anybody looked at modifying this script for use with the XML import function of Zabbix 1.4 ?
This kind of functionality is essential for Zabbix in the long run. I hope the developers are looking to include something equivalent in 1.6.
I agree, it is vital for us to ease the making of templates for new (SNMP) devices.
Does anyone know if this is compatible with v1.4.2 ?
Thanks!
Are there any plans to add simililar functionality like this to the Web UI?
It would be really useful to have a page that simply asks you for the host, community string, and a new/existing template name, then does a snmpwalk.
Something called "Create Items based upon snmpwalk data from host"..
Just a thaught... :)
Hi!
I've modified the script to generate a xml-importfile to be imported using the Web UI. It's in the Wiki:
http://www.zabbix.com/wiki/doku.php?id=contrib:zload_snmpwalk
Have fun.
Regards,
Dennis
I've updated the script to correctly produce v1 and v2c-items and the ability for the user to change the way the scripts behaves when generating item keys and descriptions.
Also added one wonderful new feature: A version number. :)
Hi Ploeger,
I finally came around to testing this new script.
Thank you very much!!
I found the following in the output that doesn't seem correct to me:
1. At the end of the generated XML file it says "Finished" In my opinion, this is just a cosmetic problem.
2. The items are not enclosed by <ITEMS> and </ITEMS> tags like this:
<items>
<item type="0" key="proc.num[zabbix_server]" value_type="3">
<description>Number of running processes zabbix_server</description>
<delay>300</delay>
<history>90</history>
<trends>365</trends>
<formula>1</formula>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
</item>
</items>
3. The start of the file looks like this:
<zabbix_export version="1.0" date="08.01.08" time="16:27">
<hosts>
<host name="Template_SNMP">
<status>3</status>
Processing Data from <walk.txt <item type="4" key="sysDescr.0" value_type="1">
<description>sysDescr.0</description>
<delay>60</delay>
<history>30</history>
<trends>365</trends>
<snmp_community>xxxxxxxx</snmp_community>
<snmp_oid>.1.3.6.1.2.1.1.1.0</snmp_oid>
<snmp_port>161</snmp_port>
</item>
....
The "Processing Data from <walk.txt" doesn't seem to belong there.
After a little adjusting, the import goes just fine :cool:
Again, thank you!
Hi Ramond!
BTW: My name's Dennis ;-)
Did you try (the new) V1.0 from the wiki page or the previous version (without a version number). I've added a debug-switch to dis- or enable the debugging output (like "Processing data from...").
Please try out V1.0 again.
Thanks.
Regards,
Dennis
Hi Dennis,
I copied the script from the wiki just yesterday, so I was using version 1.0.
Would you like me to rerun the script with debugging enabled?
Hi!
Hmm.. The Output you mentioned should only be displayed, when the debug mode is enabled, so when you've used it without enabling debug mode, the output shouldn't be there.
Could you please just retry it and check, if the version you've used really is V1 ?
Thanks.
Kind Regards,
Dennis
Hi Dennis,
Output from "./zload_snmpwalk --help":
./zload_snmpwalk.pl version 1.0 calling Getopt::Std::getopts (version 1.05 [paranoid]),
running under Perl version 5.8.8.
Usage: zload_snmpwalk.pl [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...]
The following single-character options are accepted:
With arguments: -d -h -m -p -r -s -t -u -v -u -P -r
Boolean (without arguments): -T -x
Options may be merged together. -- stops processing of options.
Space is not required between options and their arguments.
[Now continuing due to backward compatibility and excessive paranoia.
See ``perldoc Getopt::Std'' about $Getopt::Std::STANDARD_HELP_VERSION.]
USAGE:
zload_snmpwalk [OPTIONS] <community> <zabbix_id> <agent> <oid>
zload_snmpwalk [OPTIONS] <community> <zabbix_id> <file>
Version: 1.0
snmpwalk the target <agent> from the starting <oid> and then store the results
in the ZABBIX template <zabbix_id>. Alternatively, a <file> containing the
output of a previous snmpwalk can be used. The data is expected in the format
generated by 'smpwalk -Of' and should be generated using the appropriate MIB(s)
so that meaningful descriptions can be created for ZABBIX. Without using a
MIB, the attempt will likely fail as the descriptions used for ZABBIX keys will
be duplicated.
Be sure to test your data with the -T option first!
For Zabbix > 1.4 a XML-output suitable for importing over the WEB frontend is supported (-x).
To use it, specify the hosts name rather than the hosts id as <zabbix_id>.
BASIC ENVIRONMENT REQUIREMENTS:
Zabbix 1.1alpha6 - Not tested with any other versions.
perl - Tested with 5.8.0
Mysql & perl DBI - Might work with postgres after minor changes.
net-snmp - Tested with net-snmp 5.0.8
PRIMARY ARGUMENTS:
<community> SNMP community string
<dbuser> DB user that can update ZABBIX tables
<dbpasswd> DB password for the user
<zabbix_id> Zabbix template id for a template created from the UI
DATA SOURCES:
<agent> Target SNMP host/agent
<oid> Beginning oid - example: .iso.org.dod.internet.private
OR
<file> File containing snmpwalk data in '-Of' format to be loaded
OPTIONS:
-T Test Mode. No DB updates - just view the new records.
-v 1|2c|3 SNMP version
-m MIB[:...] load given list of MIBs (ALL loads everything)
-p port SNMP port, default is 161
-x Output XML suitable for import rather than doing SQL.
-d Output debugging information
Database or ZABBIX data related options:
-r delay SNMP polling delay, default is 60
-h history How long to keep polling history, default is 7
-t trends How long to keep polling trends, default is 365
-s server Database server, default is localhost
-r num Use num indexes from the right as the description (default: 2)
-d database Database, default is zabbix
-u user Database-user
-P password Database-password
So its version 1, however, I figured out what the problem is.
There are options that can be given to the program that are not unique.
the -r and -d options have a dual purpose:
-d Output debugging information
-d database Database, default is zabbix
-r delay SNMP polling delay, default is 60
-r num Use num indexes from the right as the description (default: 2)
When I ran the program, I tried to set the default delay time with -r, this resulted in to much indexes being used.
So I asummed that -d would set the delay, but off course it just turned on debugging.
You might want to fix this (maybe use capital letters?) in a 1.1 version ;)
Hi Raymond!
Whoooops.. Thanks. I've updated the script to 1.1 in the wiki now.
Kind regards,
Dennis
Hi this looks great if i've understood everything but I'm having a bit of trouble getting this to work...
I've got Zabbix version 1.4.4
I'm just not sure of the syntax when running the zload_snmp script..
I've got a MIB file called interceptor.mib which I would love to get converted to an xml file.
Not sure if you need the host name...?
Is there any chance of a little help...?
Thanks in advance
Hi!
It seems, like you've got it all wrong with the mib-stuff. MIBs are only there to "convert" your snmp-data you receive from a host into a human readable form (that's very simple speaking, I know). What you have to do is the following:
* Copy your mib into your system's mib-directory. On Debian with an installed package "libsnmp-base" it is under /usr/share/snmp/mibs.
* Run zload_snmpwalk with the following arguments:
* -x (export to xml)
* -m ALL (load all mibs under /usr/share/snmp/mibs)
* -v 1 (snmp version 1)
* public (the SNMP-community configured on your host)
* myTemplate (name of the Zabbix-template you'd like to create)
* my.hostname.com (the name of your SNMP-aware host)
* .1.3.6.1.4 (the starting OID from where you'd like to scan the host)
So the command is:
zload_snmpwalk.pl -x -m ALL -v 1 public myTemplate my.hostname.com .1.3.6.1.4
If you don't get the terms "SNMP-community" and "OID", you should probably freshen up your knowledge about SNMP first.
HTH.
Regards,
Dennis
Thanks for getting back to me....
Ahh I now understand, ok I've also read a bit about it as well
All sorted and it's up and running...
Many thanks for your help.
When I run the script I get for some (none numerical indexes) oids the following output:
04/10/2008 06:32:11.115: Unknown Object Identifier (Index out of range: 04/10/2008 06:32:11 (staIproEstabTim))
No log handling enabled - turning on stderr logging
.iso.org.dod.internet.private.enterprises.lancom-systems.adsl-systems.iad-annex-b.lancom-1722.sta.staIpro.staIproRip.staIproRipLanTable.sta IproRipLanEntry.staIproRipLanNetw.INTRANET: Unknown Object Identifier (Index out of range: INTRANET (staIproRipLanNetw))
No log handling enabled - turning on stderr logging
How can I solve this problem?
Hi!
That...
04/10/2008 06:32:11.115: Unknown Object Identifier (Index out of range: 04/10/2008 06:32:11 (staIproEstabTim))
No log handling enabled - turning on stderr logging
.iso.org.dod.internet.private.enterprises.lancom-systems.adsl-systems.iad-annex-b.lancom-1722.sta.staIpro.staIproRip.staIproRipLanTable.sta IproRipLanEntry.staIproRipLanNetw.INTRANET: Unknown Object Identifier (Index out of range: INTRANET (staIproRipLanNetw))
No log handling enabled - turning on stderr logging
... looks like an error in your MIB-File. This happens A LOT! Some vendors just doesn't seem to understand how to properly write a MIB-file.
So, sorry. Can't help you there. However, the error output shouldn't be in the XML-output you get (Don't reroute stderr to stdout like 2>&1 when you're starting the script.). If you don't get XML-output at all, this MIB-error seems to stop the whole processing. Perhaps you should get a new MIB-file or delete the file that causes this error.
Sorry.
Regards
Dennis
rthomson
04-06-2008, 23:15
Hi,
First of all, I'd like to thank the author for this little gem! It's a great tool for loading up Zabbix with SNMP items.
I'm using the zload_snmpwalk.pl script to load up Zabbix with templates for several SNMP devices. I noticed that with a few of my devices, the zload_snmpwalk.pl script will create the names of some item keys as simply the last two numbers of the OID instead of the actual string description from the MIB.
I believe (although I haven't tested any changes to be sure) this is due to the following function:
sub get_zabbix_description
{
my $raw_oid = shift(@_);
my $pos;
# Step back 2 positions for a description string and key
$pos = length($raw_oid);
for (my $i=0; $i<$zabbix_right;$i++) {
$pos = rindex($raw_oid,'.', $pos - 1);
}
return substr($raw_oid, $pos + 1);
}
The assumption that we need to step back two positions to get the description string and key may not be correct in all cases.
I'll provide an example. I have a Xerox DocuPrint N2125 that I can snmpwalk and I get the following result:
(command: snmpwalk -v1 -m ALL -Oa -c community printer.name.dns .1.3.6.1.2.1.43.18)
Printer-MIB::prtAlertSeverityLevel.1.221 = INTEGER: warning(4)
Printer-MIB::prtAlertTrainingLevel.1.221 = INTEGER: untrained(3)
Printer-MIB::prtAlertGroup.1.221 = INTEGER: generalPrinter(5)
Printer-MIB::prtAlertGroupIndex.1.221 = INTEGER: 1
Printer-MIB::prtAlertLocation.1.221 = INTEGER: 3
Printer-MIB::prtAlertCode.1.221 = INTEGER: subunitPowerSaver(23)
Printer-MIB::prtAlertDescription.1.221 = STRING: "Power Saver On"
Printer-MIB::prtAlertTime.1.221 = Timeticks: (637316646) 73 days, 18:19:26.46
And the results returned from zload_snmpwalk.pl:
(command: ./zload_snmpwalk.pl -m ALL -x -v 1 community Template_Xerox_DocuPrintN2125 printer.name.dns .1.3.6.1.2.1.43.18)
<zabbix_export version="1.0" date="04.06.08" time="13:00">
<hosts>
<host name="Template_Xerox_DocuPrintN2125">
<status>3</status>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.2.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.3.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.4.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.5.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.6.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.7.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="1">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.8.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
<item type="1" key="1.221" value_type="0">
<description>1.221</description>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<snmp_community>public</snmp_community>
<snmp_oid>.1.3.6.1.2.1.43.18.1.1.9.1.221</snmp_oid>
<snmp_port>161</snmp_port>
</item>
</host>
</hosts>
</zabbix_export>
As you can see, the values for "key" in the XML only represent the last two parts of the OID, which in this case happen to be numeric and not include any of the text description from the MIB. This is why I suspect the "get_zabbix_description" subroutine and it's assumption of going back two steps to get the string description.
I also had this happen for some keys while I was using zload_snmpwalk.pl for my IBM BladeCenter but there isn't anything new to show by example with that case so I won't bother.
Now, I can't immediately offer any solution as I am certainly no expert or authority on SNMP and how to effectively make a judgement on when or how the script should decide how many steps back it should take for a specific OID.
I believe I can just edit the script to step back a different number of steps for the specific OIDs (and then run it against just the OIDs that need more steps back) but I am certain that there can be a more elegant solution.
Any thoughts?
Once I work my way around this issue, I'll be posting some of the templates I've generated, most of which will be of questionable value to others since it's so easy to create them with zload_snmpwalk.pl, but hey, I figure after benefiting so much from community contributions, I might as well contribute back anything I can.
Hi rthomson!
This sadly cannot be done "automagically", because it depends on the number and complexity of items under a specific information.
In your example you have the information "prtAlertGroup" for several objects in your printer. So you have a object "1" with a subobject "221" and perhaps your printer or another printer of the same vendor has another subobject "222" or even another object "2" or something. According to my knowledge, this information cannot be found somewhere. (If it can, please tell me!)
So zload_snmpwalk has another argument, which you probably overlooked:
-R num Use num indexes from the right as the description (default: 2)
So per default the script uses the two last objects it gets from the mib (which would be 1.221 in your example). If you set this to 3, you'd get the last three, which would include "prtAlertGroup". So your items will be named "prtAlertGroup.1.221".
BTW: What "1.221" really is can only be told by the vendor. Hope you're not dealing with Ricoh-printers out there :-(
Hth.
Regards
Dennis
rthomson
06-06-2008, 02:30
Thanks for replying.
I thought I spent enough time digging through information to find out whether this was a "known issue" or was already solved or what not... but it seems I missed the most obvious place to check, the usage information/documentation!
lwickline
09-09-2008, 01:46
Getting an error with the latest version. can anyone help with why?
./zload_snmpwalk -d zabbix -u root -P password comunity 10069 file
.DBD::mysql::st execute failed: Column 'type' cannot be null at ./zload_snmpwalk line 314, <SWALK> line 1.
Insert Failure: DBI::st=HASH(0x8819c0)->strerror
Ah... I haven't looked at the database-part of the import script, I just worked out the XML-part.
But I would stick to the XML-Solution, lwickline. Read the other posts of this thread to get the right arguments.
Thanks.
Kind regards,
Dennis
riegersteve
17-01-2009, 02:42
Getting an error with the latest version. can anyone help with why?
got the same error
Hi All,
I was just wondering if it's available somewhere an up to date version of this script...
Thank you ,
I think you can find it here:
http://www.zabbix.com/wiki/howto/monitor/snmp/zload_snmpwalk
I even posted an updated version (in comments)
thank you canepan!
Kind regards,
zhanghui8059
26-05-2011, 12:17
Getting an error with the latest version. can anyone help with why?zabbix version is 1.8.5.
thks!
.DBD::mysql::st execute failed: Duplicate entry '0' for key 1 at ./snmpwalk.pl line 314, <SWALK> line 2.
Insert Failure: DBI::st=HASH(0xb91760)->strerror
george04
30-07-2011, 00:39
zhanghui8059
Junior Member
Join Date: May 2011
Posts: 2
Getting an error with the latest version. can anyone help with why?zabbix version is 1.8.5.
thks!
.DBD::mysql::st execute failed: Duplicate entry '0' for key 1 at ./snmpwalk.pl line 314, <SWALK> line 2.
Insert Failure: DBI::st=HASH(0xb91760)->strerror
No dont tell me that, i was about to try it to.. hope it dont give me the same problem, ...
ill be posting in few days to tell how it went with me.
thanks for this tread its greate..
george04
30-07-2011, 01:55
Hi there i finaly , try this script but i got a problema.
Once i type the command with all its arguments this is the answer
MIB search path: /home/zabbix/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (SNMP-FRAMEWORK-MIB): At line 9 in /usr/share/mibs/netsnmp/NET-SNMP-AGENT-MIB
Cannot find module (SNMPv2-SMI): At line 8 in /usr/share/mibs/netsnmp/NET-SNMP-MIB
Did not find 'enterprises' in module #-1 (/usr/share/mibs/netsnmp/NET-SNMP-MIB)
Unlinked OID in NET-SNMP-MIB: netSnmp ::= { enterprises 8072 }
Undefined identifier: enterprises near line 10 of /usr/share/mibs/netsnmp/NET-SNMP-MIB
Looks like im not conecting NEtSNMP..
or something else , ill thankful if you tellme something about this problem, im really new and its my first week on this,...
thanks by the way
Trying to use this a juniper srx240h. Have the junos enterprise mibs loaded into /usr/share/snmp/mibs
But getting the following errors:
[root@zenoss scripts]# /usr/bin/perl zload_snmpwalk.pl -v 2c -m ALL -x public SRX240H 10.10.254.2 1.3.6.1.4.1.2636.3.39.
<zabbix_export version="1.0" date="13.12.11" time="15:28">
<hosts>
<host name="SRX240H">
<status>3</status>
Cannot find module (ENTITY-MIB): At line 15 in /usr/share/snmp/mibs/mib-rfc2922.txt
Did not find 'PhysicalIndex' in module #-1 (/usr/share/snmp/mibs/mib-rfc2922.txt)
1.3.6.1.4.1.2636.3.39.: Unknown Object Identifier (Sub-id not found: jnxJsMibRoot -> )
</host>
</hosts>
</zabbix_export>
[root@zenoss scripts]# service net-snmp restart
net-snmp: unrecognized service
[root@zenoss scripts]# /usr/bin/perl zload_snmpwalk.pl -v 2c -m ALL -x public SRX240H 10.10.254.2 1.3.6.1.4.1.2636.3.39.
<zabbix_export version="1.0" date="13.12.11" time="15:29">
<hosts>
<host name="SRX240H">
<status>3</status>
Cannot find module (IPMROUTE-STD-MIB): At line 13 in /usr/share/snmp/mibs/mib-pimmib.txt
Did not find 'ipMRouteGroup' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteSource' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteSourceMask' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteNextHopGroup' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteNextHopSource' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteNextHopSourceMask' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteNextHopIfIndex' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Did not find 'ipMRouteNextHopAddress' in module #-1 (/usr/share/snmp/mibs/mib-pimmib.txt)
Cannot find module (ATM-MIB): At line 23 in /usr/share/snmp/mibs/mib-jnx-atm.txt
Did not find 'atmInterfaceConfEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-atm.txt)
Did not find 'atmVclEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-atm.txt)
Did not find 'atmVplEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-atm.txt)
Cannot find module (ATM-MIB): At line 17 in /usr/share/snmp/mibs/mib-jnx-atm-cos.txt
Did not find 'atmVclVpi' in module #-1 (/usr/share/snmp/mibs/mib-jnx-atm-cos.txt)
Did not find 'atmVclVci' in module #-1 (/usr/share/snmp/mibs/mib-jnx-atm-cos.txt)
Cannot find module (DISMAN-PING-MIB): At line 28 in /usr/share/snmp/mibs/mib-jnx-ping.txt
Did not find 'pingResultsEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingProbeHistoryEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingCtlTargetAddressType' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingCtlTargetAddress' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsOperStatus' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsIpTargetAddressType' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsIpTargetAddress' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsMinRtt' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsMaxRtt' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsAverageRtt' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsProbeResponses' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsSentProbes' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsRttSumOfSquares' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'pingResultsLastGoodProbe' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Did not find 'OperationResponseStatus' in module #-1 (/usr/share/snmp/mibs/mib-jnx-ping.txt)
Cannot find module (PPVPN-TC-MIB): At line 23 in /usr/share/snmp/mibs/mib-l3vpnmib.txt
Did not find 'VPNId' in module #-1 (/usr/share/snmp/mibs/mib-l3vpnmib.txt)
Cannot find module (MPLS-TC-STD-MIB): At line 33 in /usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt
Did not find 'MplsLabel' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsLabelDistributionMethod' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsLdpIdentifier' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsLdpLabelType' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsLspType' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsLsrIdentifier' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Did not find 'MplsRetentionMode' in module #-1 (/usr/share/snmp/mibs/mib-jnx-mpls-ldp.txt)
Cannot find module (BRIDGE-MIB): At line 10 in /usr/share/snmp/mibs/mib-jnx-l2cp-features.txt
Did not find 'dot1dStpPort' in module #-1 (/usr/share/snmp/mibs/mib-jnx-l2cp-features.txt)
Did not find 'dot1dStpPortEntry' in module #-1 (/usr/share/snmp/mibs/mib-jnx-l2cp-features.txt)
Cannot find module (PerfHist-TC-MIB): At line 17 in /usr/share/snmp/mibs/mib-jnx-pwatm.txt
Cannot find module (ATM-TC-MIB): At line 30 in /usr/share/snmp/mibs/mib-jnx-pwatm.txt
Did not find 'PerfCurrentCount' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwatm.txt)
Did not find 'PerfIntervalCount' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwatm.txt)
Did not find 'AtmVpIdentifier' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwatm.txt)
Did not find 'AtmVcIdentifier' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwatm.txt)
Cannot find module (PerfHist-TC-MIB): At line 24 in /usr/share/snmp/mibs/mib-jnx-pwtdm.txt
Did not find 'PerfCurrentCount' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwtdm.txt)
Did not find 'PerfIntervalCount' in module #-1 (/usr/share/snmp/mibs/mib-jnx-pwtdm.txt)
Cannot find module (RMON2-MIB): At line 23 in /usr/share/snmp/mibs/mib-lldp.txt
Did not find 'TimeFilter' in module #-1 (/usr/share/snmp/mibs/mib-lldp.txt)
Did not find 'ZeroBasedCounter32' in module #-1 (/usr/share/snmp/mibs/mib-lldp.txt)
Cannot find module (DISMAN-PING-MIB): At line 20 in /usr/share/snmp/mibs/mib-jnx-rpm.txt
Did not find 'pingCtlOwnerIndex' in module #-1 (/usr/share/snmp/mibs/mib-jnx-rpm.txt)
Did not find 'pingCtlTestName' in module #-1 (/usr/share/snmp/mibs/mib-jnx-rpm.txt)
Did not find 'pingProbeHistoryIndex' in module #-1 (/usr/share/snmp/mibs/mib-jnx-rpm.txt)
1.3.6.1.4.1.2636.3.39.: Unknown Object Identifier (Sub-id not found: jnxJsMibRoot -> )
</host>
</hosts>
</zabbix_export>
Surely I'm missing something stupid... can anyone see it might be?
[root@zenoss scripts]#
Surely I'm missing something stupid... can anyone see it might be?
You're using the wrong monitoring tool? :D
You're using the wrong monitoring tool? :D
Funny, I knew someone would comment on that :)
Just reusing a vm that was going to be testing some zenoss stuff. We currently have both running (zenoss came first) but are hoping to ditch zenoss and switch over to zabbix entirely.
If I could figure out what stupid thing I'm doing wrong...
Seriously though, you don't need the snmp deamons since you are using the tools only. In most distros it is a different package, pleas check if you have the proper tools installed.
Seriously though, you don't need the snmp deamons since you are using the tools only. In most distros it is a different package, pleas check if you have the proper tools installed.
zabbix is running fine, even catching traps. Only zabbix is running and it's a clean setup of centos. That's just the host name you are seeing.
It could also be a missing perl dependency
zabbix is running fine, even catching traps. Only zabbix is running and it's a clean setup of centos. That's just the host name you are seeing.
Yes I know, but really, for this tool you dont need the snmp deamons, it is a client based. I'm not sure if it uses the snmp tools or the perl modules though.
Yes I know, but really, for this tool you dont need the snmp deamons, it is a client based. I'm not sure if it uses the snmp tools or the perl modules though.
We have the snmp tools installed. We needed that to use the cisco template builder script that's on this site. Which we used to make templates for our 3750x stack and our 7204vxr npe-g2's. That worked great.
Sorry if I'm being dense and not getting what you're saying about the daemons. I thought we needed that for the way we are catching traps and then tossing them over through the zabbix script into zabbix. Either way I remember installing the snmp tools package to get the cisco template builder working.
In your log you showed that starting the snmp deamon works correctly, but strictly speaking you dont neef that for this script.
Of course you do need it for trap handeling, but that is unrelated.
Weird that the script did work for your catalysts. Can you do a normal snmpwalk from the zabbix macine to the Juni?
In your log you showed that starting the snmp deamon works correctly, but strictly speaking you dont neef that for this script.
Of course you do need it for trap handeling, but that is unrelated.
Weird that the script did work for your catalysts. Can you do a normal snmpwalk from the zabbix macine to the Juni?
It was a different script, one for cisco devices and not this particular one.
snmpwalk seems fine:
[root@zenoss mibs]# snmpwalk -v 2c -c public 10.10.254.2 SNMPv2-MIB::sysContact.0
SNMPv2-MIB::sysContact.0 = STRING: support@xxxx.com
[root@zenoss mibs]#