[prev in list] [next in list] [prev in thread] [next in thread] 

List:       portmaster-users
Subject:    Re: (PM) Monitoring Line Usage
From:       Wade Maxfield <maxfield () one ! ctelcom ! net>
Date:       2002-11-15 1:58:08
[Download RAW message or body]


  we use snmp.  But we also use telnet.  The following uses mrtg to graph 
users online.  it shows how you can use filter files to modify counts.  We 
have a portmaster with two different call in lines, and this splits them 
into two parts.  this one gets the first 23 lines and throws away the 
rest.

  the second mrtg recipe uses snmp to get the number of users online.


  In our mrtg file, we have a lines like this:

#-------------------------------------------------------------
Target[3413-users]: `/usr/sbin/getpmusers.new| /usr/local/bin/3413pmuserfilter`
MaxBytes[3413-users]: 25
AbsMax[3413-users]: 25
Unscaled[3413-users]: dwym
ShortLegend[3413-users]: users
YLegend[3413-users]: Number Of Users
Options[3413-users]: growright, gauge, nopercent
Legend1[3413-users]: Count
Legend2[3413-users]: Usage
LegendI[3413-users]: &nbsp;
LegendO[3413-users]:
Title[3413-users]:  Total Users on 3413 
PageTop[3413-users]: <H1>Total Users on 3413</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>Main Server</TD></TR>
   <TR><TD>Maintainer:</td><td>Root <root@llll.net></TD><TD></TD></TR>
  </TABLE>


#-------------------------------------------------------------
Target[501-users]: 1.3.6.1.2.1.2.1.0&1.3.6.1.2.1.2.1.0:public@wfordpm2.ctelcom.net - 1
#Target[501-users]: `/usr/sbin/getpmusers.new| /usr/local/bin/501pmuserfilter`
MaxBytes[501-users]: 25
AbsMax[501-users]: 25
Unscaled[501-users]: dwym
ShortLegend[501-users]: users
YLegend[501-users]: Number Of Users
Options[501-users]: growright, gauge, nopercent
Legend1[501-users]: Count
Legend2[501-users]: Usage
LegendI[501-users]: &nbsp;
LegendO[501-users]:
Title[501-users]:  Total Users on 501 
PageTop[501-users]: <H1>Total Users on 501</H1>
 <TABLE>
   <TR><TD>System:</TD><TD> Main Server</TD></TR>
   <TR><TD>Maintainer:</td><td>Root <root@lllll.net></TD><TD></TD></TR>
  </TABLE>


--------------------------------------------------------





#getpmusers.new
#!/usr/bin/perl
#############
# getusers - finds out whos online through the portmaster
#   by Michael Brownlow for Central Telecommunications, Inc. (6/1999)
#
# $Id: getusers,v 1.7 1999/06/10 06:30:37 mike Exp mike $
#
#  $Log: getusers,v $
#  Revision 1.7  1999/06/10 06:30:37  mike
#  Greps out ESTABLISHED connects
#
#  Revision 1.6  1999/06/10 06:26:58  mike
#  *** empty log message ***
#
#  Revision 1.5  1999/06/10 06:26:18  mike
#  Added log.
#

$rootfailsafe = "0";
$debug    = "";
$host = "abc1";
$port     = "4351"; #telnet port (obscured here)
$prompt   = '/prompt>\ $/';
$username = "!root";
$password = "mypassword";
$showuser = "show sessions";
$separator = "/--\ Press\ Return\ for\ More\ --/";
$response = "\n";
$pages    = 3;

if($rootfailsafe eq "1") {
  die "Only root can run this script...\n" if ($< != 0);
}

use Getopt::Std;
use Net::Telnet ();

$help = <<EOF;
usage: getusers [-u username] [-p password]
EOF

die $help if( ($ARGV[0] eq "-?") ||
              ($ARGV[0] eq "-h") ||
              ($ARGV[0] eq "-H") ||
              ($ARGV[0] eq "--help") );

getopts('u:p:');

if($opt_u) {
  $username = $opt_u;
}
if($opt_p) {
  $password = $opt_p;
}

$t = new Net::Telnet (Timeout => 10,
                          Prompt => "$prompt",
			Port => $port);
$t->open($host);
$t->login($username,$password);

@users = $t->cmd(String => "$showuser",
                 Prompt => "$separator",
                 Timeout => 10);
for $user (grep /^S.*ESTABLISHED/, @users) {
  print $user;
}

for($i=0;$i<($pages-2);$i++) {
  @users = $t->cmd(String => "$response",
                 Prompt => "$separator",
                 Timeout => 10);
  for $user (grep /^S.*ESTABLISHED/, @users) {
    print $user;
  }
}

@users = $t->cmd(String => "$response",
                 Prompt => "$prompt",
                 Timeout => 10);
for $user (grep /^S.*ESTABLISHED/, @users) {
  print $user;
}

$t->errmode("return");
$t->cmd("exit");

exit(0);


--------------------------------------

#3413pmuserfilter
#
#!/usr/bin/perl -w
$linecount=0;
while($line=<STDIN>){
    if($line=~/^S(\d+)\s/ && $1 <23) {$linecount++;}
}
print $linecount,"\n",$linecount,"\n";

----------------------------------------------
On Thu, 14 Nov 2002, Mark Radabaugh wrote:

> Date: Thu, 14 Nov 2002 17:45:09 -0500
> From: Mark Radabaugh <mark@amplex.net>
> To: Jim McAtee <jmcatee@mediaodyssey.com>, portmaster-users@portmasters.com
> Subject: Re: (PM) Monitoring Line Usage
> 
> Take a look in pmlines.pl.
> 
> If you stare at it for a while you will see where pmlines just adds up the
> number of sessions in use.  If you hack at it to start at line 1 and only go
> to line 24 you can graph that and then make up another copy for lines 25 to
> 48.
> 
> Mark Radabaugh
> Amplex
> (419) 720-3635
> 
> ----- Original Message -----
> From: "Jim McAtee" <jmcatee@mediaodyssey.com>
> To: <portmaster-users@portmasters.com>
> Sent: Thursday, November 14, 2002 2:40 PM
> Subject: (PM) Monitoring Line Usage
> 
> 
> > Can anyone tell how (or if) you can use SNMP to monitor the number of
> active
> > connections on each of the two lines connected to a PM3?  I'm using mrtg
> and
> > pmlines.pl to get total connections without a problem, but the two lines
> are
> > from separate providers and independent of each other, I'd like to see the
> usage
> > for each individually.
> >
> > Thanks,
> > Jim
> >

-
To unsubscribe, email 'majordomo@portmasters.com' with
'unsubscribe portmaster-users' in the body of the message.
List archive: <URL:http://www.portmasters.com/archives/>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic