#!/usr/bin/perl -w
# -*- perl -*-

#  A simple Perl script to munge the SNMP return values of NetApp MIB queries.
#
#  Network READ and WRITE
#
#  For some reason, Network Appliance decided to return kilobytes per second, 
#  rather than the default octets per second for network reads and writes.
#  Due to the behavior of the network read and write counters, it is assumed
#  that the counters are 32bit octet counters that are simply being divided 
#  by 1024. In this script, the return values are simply being multiplied 
#  by 1024, before being returned to Cricket. (Note: This script would not 
#  be necessary, if the SCALE operator also worked for datasources.)
#

#  Author: Matthew Stier
#  Email: Matthew.Stier@fnc.fujitsu.com


BEGIN {
	$gInstallRoot = (($0 =~ m:^(.*/):)[0] || "./") . "..";
}

use lib "$gInstallRoot/lib";
use strict;

use snmpUtils;

if ($#ARGV+1 < 1 || $#ARGV+1 > 2) {
	print STDERR "usage: $0 hostname [community]\n";
	print STDERR "\tcommunity will default to public if you don't give it.\n";
	exit 1;
}

my($filer) = $ARGV[0];
my($community) = "public";
$community = $ARGV[1] unless (! defined($ARGV[1]));
my($snmp) = "$community\@$filer";

my($netsent)	= "1.3.6.1.4.1.789.1.2.2.3.0";
my($netrcvd)	= "1.3.6.1.4.1.789.1.2.2.2.0";

my(@ret)	= snmpUtils::get($snmp, $netsent, $netrcvd);

print $ret[0] * 1024 . "\n";
print $ret[1] * 1024 . "\n";

