Novell Home

Getting SNMP Values from Multiple POAs on the Same Node

Novell Cool Solutions: Tip
By Uffe Bager

Digg This - Slashdot This

Posted: 7 Nov 2006
 

Problem

When using Groupwise on a Novell Netware cluster, SNMP is limited to the first loaded agent. If you have 2 POA's on the same node, SNMP will only return the SNMP values from the first loaded node.

Solution

Instead of using the SNMP.NLM, I built a Perl Script to get the needed information from Groupwise HTTP interface. This script works on POA, MTA and GWIA agents - WebAccess doesn't have an http interface. All POA, MTA and GWIA's need separate IP and HTTP ports for the HTTP interface to work in a cluster.

You can use any parameter in MRTG.CFG that you can see in the HTTP interface; see the parameters on http://agent_ip:http_port/snmp. I use the MRTG on Netware, but the Perl script also works on Linux. Edit your MRTG.CFG as in the example below, changing the parameters to include your needs.

Note: You need Perl installed on the server running MRTG. For the Netware/Groupwise serveres there are no special needs, besides the Groupwise Agents needing HTTP enabled.

MRTG.CFG Example

Here's a sample of MRTG.CFG, showing bytes in/out on a GWIA, as well as total and closed MTA's (this needs to be the primary domain):

Title[Mailgate1.smtpb]: AMT-MAILGATE1 SMTP - Number of Bytes
Target[Mailgate1.smtpb]: `perl --noscreen sys:mrtg/bin/gwstats.pl gwiaStatBytesOut&gwiaStatBytesIn@host_ip:http_port`
Options[Mailgate1.smtpb]: perminute, integer, growright
MaxBytes[Mailgate1.smtpb]: 10000000
XSize[Mailgate1.smtpb]: 500
YSize[Mailgate1.smtpb]: 200
PageTop[Mailgate1.smtpb]: 

Number of Bytes Through AMT-MAILGATE1 SMTP

YLegend[Mailgate1.smtpb]: Bytes Transmitted
ShortLegend[Mailgate1.smtpb]: Bytes
LegendI[Mailgate1.smtpb]: Bytes Out: 
LegendO[Mailgate1.smtpb]: Bytes In:  
Title[pdom.doms]: AMT-PDOM MTA - Domains
Target[pdom.doms]: `perl --noscreen sys:mrtg/bin/gwstats.pl mtaTotalDomains&mtaClosedDomains@host_ip:http_port`
Options[pdom.doms]: gauge, integer, growright
MaxBytes[pdom.doms]: 10000000
XSize[pdom.doms]: 500
YSize[pdom.doms]: 200
PageTop[pdom.doms]: 

Total and Closed Domains - AMT-PDOM MTA

YLegend[pdom.doms]: Number
ShortLegend[pdom.doms]: Domains
LegendI[pdom.doms]: Total Domains:&nbsp
LegendO[pdom.doms]: Closed Domains:&nbsp

Perl Script Example

To use the Perl script, edit the HTTP Username and Password in line 5 and 6; then copy the gwstats.pl file to MRTG/bin.

---------------------
gwstat.pl
---------------------
require 5.005;

use LWP::UserAgent;
              
  $usr = "HTTP Username";
  $pwd = "HTTP Password";

sub Validate() {
  if ((scalar(@ARGV) < 1) || ($ARGV[0] eq '')) {
     print "ERR: invalid arguments.\n";
     exit;
  }
} 

  Validate();

  $l = length($ARGV[0]);
  $ta = index($ARGV[0],"&");
  $tb = index($ARGV[0],"@");

  $host = substr($ARGV[0],$tb+1,$l - $tb);

  @type = ( substr($ARGV[0],0,$ta), substr($ARGV[0],$ta+1,$tb-$ta-1));

  @result = (-1,-1);

  $ua = new LWP::UserAgent;

  $ua->credentials("$host", "GroupWise Agent", "$usr" => "$pwd");
   
  $req = new HTTP::Request "GET","http://$host/snmp";
  $req->content_type('text/xml');
  $res = $ua->request($req);

  $r = $res->content;


  $line = $r;

  $tu = index($line,"Uptime");
  
  if ($tu ne -1 ) { 
    $uptime = substr($line,$tu+20);
    $uptime = substr($uptime,0,index($uptime,"<")-2);
  };
  
  $tu = index($line,"TimeUp");
  
  if ($tu ne -1 ) { 
    $uptime = substr($line,$tu+20);
    $uptime = substr($uptime,0,index($uptime,"<")-2);
  };


  for($i=0;$i<=1;$i++){
    $tv = index($line,$type[$i]);
    if ( $tv eq "-1") {
      next;}
    
    $result[$i] = substr($line,$tv+length($type[$i])+14);
    $result[$i] = substr($result[$i],0,index($result[$i],"<")-1);

    if ($type[$i] eq "null") {$result[$i]="0";}
  }

  print "$result[0]\n";
  print "$result[1]\n";
  print "$uptime\n";
  print "$host\n";
--------------------------


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell