Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Fri Apr 19, 2019 7:37 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: 3Com Total Control HiPer NMP - Modem Utilization
PostPosted: Tue Nov 25, 2003 4:36 pm 
Offline
User avatar

Joined: Tue Nov 25, 2003 4:29 pm
Posts: 20
Location: Heath, Oh
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:
#!/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:
File comment: What it looks like!
Image1.png
Image1.png [ 5.92 KiB | Viewed 21171 times ]

_________________
silicon_freak
http://www.siliconworksinc.net
Top
 Profile  
 
 Post subject: Data Input Method (was 3Com TCR modem util)
PostPosted: Mon Apr 04, 2005 6:31 pm 
Offline

Joined: Mon Apr 04, 2005 2:05 pm
Posts: 19
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?


Top
 Profile  
 
 Post subject: Update
PostPosted: Mon Apr 04, 2005 7:30 pm 
Offline

Joined: Mon Apr 04, 2005 2:05 pm
Posts: 19
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


Top
 Profile  
 
 Post subject: Modems
PostPosted: Fri Apr 08, 2005 9:47 am 
Offline

Joined: Fri Apr 08, 2005 9:46 am
Posts: 2
Could you post your template used to create that graph?


Top
 Profile  
 
 Post subject: Templates
PostPosted: Fri Apr 08, 2005 11:32 am 
Offline

Joined: Mon Apr 04, 2005 2:05 pm
Posts: 19
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_graph_template_tc_modem_utilization.xml [8.46 KiB]
Downloaded 1009 times
cacti_data_template_tc_modem_utilization.xml [3.96 KiB]
Downloaded 1058 times
Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 08, 2005 12:21 pm 
Offline

Joined: Fri Apr 08, 2005 9:46 am
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 5:25 pm 
Offline

Joined: Thu Oct 14, 2004 2:39 pm
Posts: 21
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:
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:
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...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 12:20 am 
Offline

Joined: Mon Apr 24, 2006 12:06 am
Posts: 3
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 2:10 am 
Offline

Joined: Mon Apr 24, 2006 12:06 am
Posts: 3
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)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 26, 2006 10:22 am 
Offline
Cacti User

Joined: Sun May 08, 2005 5:45 pm
Posts: 88
Location: Sydney,Australia
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group