In our environment we manage a bunch of end clients, who are mostly using Mikrotik routers. One of the challenges we have is version management. To keep this more manageable I want to collect some properties like sysName, sysDescr, sysLocation and .1.3.6.1.4.1.14988.1.1.4.4.0 (Mikrotik RouterOS version).
The first three are automatically visible in cacti when the device is added, but since I'd like to be able to pass this information on to another system I think that I might have to manually add them again in order to have this in a separate .rrd file. (for example to use in a Grafana dashboard)
To do this (and I could be completely on the wrong track here) I edited a perl script I found online and made this
Code: Select all
#!/usr/bin/perl
use warnings;
use strict;
use SNMP;
use Socket;
# VARIABLES YOU SHOULD EDIT.
my $comm = $ARGV[1];
my $dest = $ARGV[0];
my $mib = $ARGV[3];
my $sver = $ARGV[2];
# VARIABLES YOU SHOULD LEAVE ALONE.
my $sess; # The SNMP::Session object that does the work.
my $var; # Used to hold the individual responses.
my $vb; # The Varbind object used for the 'real' query.
# Initialize the MIB (else you can't do queries).
&SNMP::initMib();
my %snmpparms;
$snmpparms{Community} = $comm;
$snmpparms{DestHost} = inet_ntoa(inet_aton($dest));
$snmpparms{Version} = $sver;
$snmpparms{UseSprintValue} = '1';
$sess = new SNMP::Session(%snmpparms);
# Turn the MIB object into something we can actually use.
$vb = new SNMP::Varbind([$mib,'0']); # '0' is the instance.
$var = $sess->get($vb); # Get exactly what we asked for.
if ($sess->{ErrorNum}) {
die "Got $sess->{ErrorStr} querying $dest for $mib.\n";
# Done as a block since you may not always want to die
# in here. You could set up another query, just go on,
# or whatever...
}
#print $vb->tag, ".", $vb->iid, " : $var\n";
print "$var"
Code: Select all
perl snmp.pl 192.168.1.54 community 2c sysDescr
Code: Select all
RouterOS RB750
Now what I would like to do is to have cacti run this for me for every host, so (I think) I have to create a Data Source for this. So I have created this using http://www.cacti.net/downloads/docs/html/templates.html and other sources.
after this I am stuck and have no idea how to continue. My google-fu is also giving up, so I'm starting to wonder if this is even possible (because of the all-text values that you might get).
The ultimate goal would be to end up with a few .rrd files, collected by cacti, which I can then use elsewhere by just displaying the last value.