3Com Total Control HiPer NMP - Modem Utilization

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
User avatar
silicon_freak
Posts: 20
Joined: Tue Nov 25, 2003 4:29 pm
Location: Heath, Oh
Contact:

3Com Total Control HiPer NMP - Modem Utilization

Post by silicon_freak »

This script I have posted by an unknown author monitors 3Com Total Control Modem Banks.

perl <path_cacti>/scripts/3com_totalcontrol_hipernmc.pl <snmp_community>@<ip>

Hope this helps... *!*You may need two files from the mrtg package (SNMP_Session and BER)*!*

Code: Select all

#!/usr/bin/perl

# 3Com Total Control HiPer NMP - Modem Utilization
# Modems In Use (value1)
# Modems Available (value2)

use SNMP_Session;
use BER;
use Socket;
use strict;

%snmpget::OIDS = (  'value1' =>  '1.3.6.1.4.1.429.1.27.2.1.26',
                 );

my($community,$router) = split /\@/, $ARGV[0];
die <<USAGE  unless $community && $router;

USAGE: hiperdsp.pl 'SNMP_community'\@'aaa.bbb.ccc.ddd'

Where 'aaa.bbb.ccc.ddd' is the ip address for the Network Management Card.

USAGE


my($sysName,$sysUptime,$interfaces,$value1,$value2) =
    snmpgettable($router,$community,'value1');

exit(0);

sub snmpgettable{
  my($host,$community,$var) = @_;
  my($next_oid,$enoid,$orig_oid,
     $response, $bindings, $binding, $value, $inoid,$outoid,
     $upoid,$oid,@table,$tempo);
  die "Unknown SNMP var $var\n"
    unless $snmpget::OIDS{$var};

  $orig_oid = encode_oid(split /\./, $snmpget::OIDS{$var});
  $enoid=$orig_oid;
  srand();
  my $session = SNMP_Session->open ($host ,
                                 $community,
                                 161);
  for(;;)  {
    if ($session->getnext_request_response(($enoid))) {
      $response = $session->pdu_buffer;

      ($bindings) = $session->decode_get_response ($response);
      ($binding,$bindings) = decode_sequence ($bindings);
      ($next_oid,$value) = decode_by_template ($binding, "%O%@");
      # quit once we are outside the table
      last unless BER::encoded_oid_prefix_p($orig_oid,$next_oid);

        my $bulkindex = 2;
        while( $bulkindex < "52" ){

        $tempo = substr ($value,$bulkindex,1);
        $bulkindex=$bulkindex+2;
        if( ord($tempo) eq '5' or ord($tempo) eq '3' or ord($tempo) eq '22' ){$v
alue1=$value1 + 1 ;
                }
        if( ord($tempo) eq '2' or ord($tempo) eq '5' or ord($tempo) eq '3' or or
d($tempo) eq '22' ){$value2=$value2 + 1 ;
                }
        }
      push @table, $tempo;
    } else {
      die "No answer from $ARGV[0]\n";
    }
    $enoid=$next_oid;
  }
  $session->close ();
if( $value1 eq ''){$value1 = 0 };
if( $value2 eq ''){$value2 = 0 };
     print "modems_in_use:$value1 ";
     print "modemsavailable:$value2";
  return (@table);
}
Attachments
What it looks like!
What it looks like!
Image1.png (5.92 KiB) Viewed 26141 times
silicon_freak
http://www.siliconworksinc.net
roger69
Posts: 19
Joined: Mon Apr 04, 2005 2:05 pm

Data Input Method (was 3Com TCR modem util)

Post by roger69 »

I've been running this same script on an MRTG system for several years, and want to migrate it to Cacti.

So: I created a data input method for the script, created graph and data templates that use the data input method, added the hosts of the Total Control chassis on our network, and created the graphs for the system.

The bandwidth graphs for the TC chassis seem to work fine, but the graphs for the modem utilization are blank.

I can run the script from commandline and it returns valid data.

Turning on debug in loggint, I get this:

04/04/2005 06:45:26 PM - CMDPHP: Poller[0] Host[13] WARNING: Result from CMD not valid. Partial Result: 77
0

Okay, so the script is returning 77 and 0, on separate lines. This is what it does from command-line. Any help with the data input method would be appreciated, as I obviously don't have it right.

What am I missing?
roger69
Posts: 19
Joined: Mon Apr 04, 2005 2:05 pm

Update

Post by roger69 »

Okay, I figured out the problem with the script, and now just have it returning the integer number of modems in use, and not a trailing zero on another line. The logs are happy, it shows that the script returns a single number, but the graphs are still empty.

No other debug information. Can anyone point me at what the problem might be?

Roger
compudaze
Posts: 2
Joined: Fri Apr 08, 2005 9:46 am

Modems

Post by compudaze »

Could you post your template used to create that graph?
roger69
Posts: 19
Joined: Mon Apr 04, 2005 2:05 pm

Templates

Post by roger69 »

Here are the graph and data templates I created for use with the hiperdsp.pl script. It looks like you can't export a data input method or I would export that as well, but I don't think that's where the problem lies.

Roger
Attachments
cacti_data_template_tc_modem_utilization.xml
(3.96 KiB) Downloaded 1648 times
cacti_graph_template_tc_modem_utilization.xml
(8.46 KiB) Downloaded 1682 times
compudaze
Posts: 2
Joined: Fri Apr 08, 2005 9:46 am

Post by compudaze »

sorry. my question was more geared towards silicon_freak.

i was hoping to get something like this to work as well...

i get this in my poll.log file...
sh: -c: line 2: syntax error: unexpected end of file
MULTI command: /usr/share/cacti/scripts/3com_totalcontrol_hipernmc.pl |host_snmp_community|@|host_hostname|, output:

i'm not sure how to send the actual host/community for my device.
Riceman
Posts: 21
Joined: Thu Oct 14, 2004 2:39 pm

Post by Riceman »

I think your problem is that when it was pasted into this thread it word wrapped and some of the line are jacked up because of this.

e.g

Code: Select all

if( ord($tempo) eq '2' or ord($tempo) eq '5' or ord($tempo) eq '3' or or
d($tempo) eq '22' ){$value2=$value2 + 1 ;
should be:

Code: Select all

if( ord($tempo) eq '2' or ord($tempo) eq '5' or ord($tempo) eq '3' or ord($tempo) eq '22' ){$value2=$value2 + 1 ;
There are several lines that got messed up and would need to be fixed to work.

Later,

BTW I can send you a working file if need be, let me know...
warut115
Posts: 3
Joined: Mon Apr 24, 2006 12:06 am

Post by warut115 »

hi all
please help me, i have followed step. when i run scrip. i receive this result ->>modems_in_use:29 modemsavailable:48.
But,i have 2 E1 ,modemsavailabe should be 60.
And at the time there are 37 users ,modem_in_use should be 37.
anyone help me to solve problem to get correct data.
warut115
Posts: 3
Joined: Mon Apr 24, 2006 12:06 am

Post by warut115 »

hi all
i came back to answer my question and hope it help other person.
i soved problem by this scrip.


use lib "/usr/share/doc/mrtg-2.9.17";
use BER;
use SNMP_util;
use SNMP_Session;

my $community = "xxxx";
my $router = "xxx.xxx.xxx.xxx";

#my($community,$router,$slot) = split /\@/, $ARGV[0];

foreach ($i = 2001;$i <= 2030; $i++) {
$mib1 = "enterprises.429.1.6.9.1.1.2.";
$mib2 = "200";
$mib = $mib1.$i;

($value) = snmpget("$community\@$router","$mib");
#print "Query interface $mib = $value\n";
if ($value eq 8){
$value1=($value1+1);
$value2=($value2+1);
}
else {
$value2=($value2+1);
}
}

foreach ($i = 3001;$i <= 3030; $i++) {
$mib1 = "enterprises.429.1.6.9.1.1.2.";
$mib2 = "300";
$mib = $mib1.$i;

($value) = snmpget("$community\@$router","$mib");
#print "Query interface $mib = $value\n";
if ($value eq 8){
$value1=($value1+1);
$value2=($value2+1);
}
else {
$value2=($value2+1);
}
}

if( $value1 eq ''){$value1 = 0 };
if( $value2 eq ''){$value2 = 0 };
print "val1:$value1 ";
print "val2:$value2";



-------------------------------------------------
foreach ($i = 2001;$i <= 2030; $i++)
in foreach Loop above it mean that Query interface slot:2/mod:1 until slot:2/mod:30 ( change the number are appropriate your system)
cksrealm
Cacti User
Posts: 140
Joined: Sun May 08, 2005 5:45 pm
Location: Sydney,Australia
Contact:

Post by cksrealm »

Please can you advise what Perl Modules are required to do this as when running the command Im getting the following errors.

Can't locate SNMP_Session.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at ./3com_totalcontrol_hipernmc.pl line 7.
BEGIN failed--compilation aborted at ./3com_totalcontrol_hipernmc.pl line 7.

Taking this into account it is apparent that the SNMP_Session module is mising yet looking on CPAN I cant find it as an option.

Cheers

Chris
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest