Once again: multiple OID's to one graph

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
holger
Posts: 1
Joined: Tue Mar 24, 2015 5:46 am

Once again: multiple OID's to one graph

Post by holger »

Hello!

I've been struggling for a couple of days now trying to make a indexed SNMP-query for a controller, and nothing really works. I've been reading through the FAQ's, another newbie's posts, various walkthroughs and the manual itself, but with no luck.


So the dilemma is as follows:

One IP-address, 31 different OID's which indicate different alarms on the device. Return value 0 = no alarm, 1 = alarm.
I want to collect all these in one graph, because i don't really care what kind of alarm is on, just if there is an alarm or not. The main point is to be able to then put this value on my Network Weathermap, and to have a node that is green when the number of alarms is 0, and red if the number of alarms is >0.

There is no MIB and no Index, only these OID's:
.1.3.6.1.4.1.9839.2.1.1.1.0
.1.3.6.1.4.1.9839.2.1.1.2.0
.1.3.6.1.4.1.9839.2.1.1.3.0
........
.1.3.6.1.4.1.9839.2.1.1.31.0


Based on this i have now a script that collects the values as inputs, and that does not generate a RRD-file. If i put them all as outputs, a graph was created, but with no info. Also, the poller for some reason just polls one non-existing OID (1.3.6.1.4.1.9839.2.1.1.1.0.0) for all values. Though, if used as inputs, the values show up correctly on the data-query.

I really don't want to attach any of the XML or so at the moment, as it is really messed up. It would be better to just start from scratch and do it right from the beginning. Ideally the 31 OID's should be collected all in one and added together in one RRD. I don't want 31 RRD's more because i'm running on Raspberry Pi, which already is slow and limited.
User avatar
Happiness0
Cacti User
Posts: 63
Joined: Wed Oct 29, 2014 5:01 am
Contact:

Re: Once again: multiple OID's to one graph

Post by Happiness0 »

You can use this code as a starting point for your weathermap. It will output the nodes for the map, with images displayed on one line, horizontally. In order to get the map to work, you will need to install the Net::SNMP module for Perl, print the global options for the map above the loop, set the ip address and the community and you will be all right :-)

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;
use Net::SNMP;
my ($ip, $community, $x, $y, $img, $out) = qw(xx.xx.xx.xx xxxx 100 100);
my $session = Net::SNMP->session( Hostname   => $ip,
                                                         Community => $community,
                                                         port            => 161)
                                      or die "Session: $!";
for my $i (1..31) {
    my $query = $session->get_request(".1.3.6.1.4.1.9839.2.1.1.$i.0");
    my $state = $query->{".1.3.6.1.4.1.9839.2.1.1.$i.0"};
    $state
        ? ($img = 'green.png')
        : ($img = 'red.png');
    $out = "NODE $i\n"
        . "\tPOSITION " . $x . " " .  $y . "\n"
        . "\tICON images/$img\n";
    print $out;
    $x += 100;
}
The code below allow you to format the output according to cacti's data input method requirements. Add a data input method which points to the script, with data1, data2, etc as output

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;
use Net::SNMP;
my ($ip, $community, $x, $y, $img, $out) = qw(xx.xx.xx.xx xxxx 100 100);
my $session = Net::SNMP->session( Hostname   => $ip,
                                                         Community => $community,
                                                         port            => 161)
                                      or die "Session: $!";
for my $i (1..31) {
    my $query = $session->get_request(".1.3.6.1.4.1.9839.2.1.1.$i.0");
    my $state = $query->{".1.3.6.1.4.1.9839.2.1.1.$i.0"};
    print "data" . $i . ":" . $state . " ";
}
Hope that helps
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests