[rrd-users] heres my perl script as well
Jackson Lancaster
jlancaster at integrate-u.com
Thu Feb 21 22:27:09 MET 2002
use RRDs;
use SNMP::Util;
# Initialize MIB's
use SNMP::Util_env;
&SNMP::initMib();
&SNMP::loadModules(ALL);
$hostname = $ARGV[0];
$port='161';
$community='ICSread';
$rrd = $hostname;
$snmp->{$hostname} = new SNMP::Util(-device => $hostname,
-community => $community,
-timeout => 5,
-retry => 0,
-poll => 'on',
-poll_timeout => 5,
-verbose => 'off',
-errmode => 'return',
-delimiter => ' ',
)
;
my $flowsexec = 1;
while ($flowsexec=1) {
flows();
sleep 15;
}
sub flows {
# Check to see if intFlow(ip.ip.ip.ip).rrd file exists
if(!(-e "intFlow${hostname}.rrd")) {
RRDs::create ("intFlow${hostname}.rrd", "--start", now, "--step", 300,
"DS:intFlow0In:COUNTER:600:0:U",
"DS:intFlow0Out:COUNTER:600:0:U",
"DS:intFlow1In:COUNTER:600:0:U",
"DS:intFlow1Out:COUNTER:600:0:U",
"DS:intFlow2In:COUNTER:600:0:U",
"DS:intFlow2Out:COUNTER:600:0:U",
"DS:intFlow3In:COUNTER:600:0:U",
"DS:intFlow3Out:COUNTER:600:0:U",
"DS:intFlow4In:COUNTER:600:0:U",
"DS:intFlow4Out:COUNTER:600:0:U",
"DS:intFlow5In:COUNTER:600:0:U",
"DS:intFlow5Out:COUNTER:600:0:U",
"DS:intFlow6In:COUNTER:600:0:U",
"DS:intFlow6Out:COUNTER:600:0:U",
"DS:intFlow7In:COUNTER:600:0:U",
"DS:intFlow7Out:COUNTER:600:0:U",
"RRA:LAST:0.5:1:600",
"RRA:AVERAGE:0.5:1:24",
"RRA:AVERAGE:0.5:6:700",
"RRA:AVERAGE:0.5:24:775",
"RRA:AVERAGE:0.5:288:797",
"RRA:MAX:0.5:1:600",
"RRA:MAX:0.5:6:700",
"RRA:MAX:0.5:24:775",
"RRA:MAX:0.5:288:797"
);
}
# Get interface Flow Counters
@intFlowIndx = $snmp->{$hostname}->walk('e', "nsIfFlowIfIdx");
foreach $intFlow (@intFlowIndx) {
$intFlowInBytes =
$snmp->{$hostname}->get('e',"nsIfFlowInByte.$intFlow");
$intFlowOutBytes =
$snmp->{$hostname}->get('e',"nsIfFlowOutByte.$intFlow");
#-----debug
print STDOUT "$intFlow, $intFlowInBytes, $intFlowOutBytes\n";
print STDOUT "RRDs::update \"intFlow${hostname}.rrd\", \"-t\",
\"intFlow${intFlow}In:intFlow${intFlow}Out\", \"N:${int
FlowInBytes}:$intFlowOutBytes\" ";
RRDs::update "intFlow${hostname}.rrd", "-t",
"intFlow${intFlow}In:intFlow${intFlow}Out", "N:${intFlowInBytes}:$intFlow
OutBytes";
my $ERR=RRDs::error;
print STDOUT "update\n";
#RRDs::update("intFlow${hostname}.rrd", "-t",
"intFlow${intFlow}Out", "N:${intFlowOutBytes}");
RRDs::graph "intFlow$intFlow".".png",
"--title", "Interface Flow Statistics for Interface $intFlow",
"--start", "now-1h",
"--end", "now",
# "--lower-limit=.1",
# "--interlace",
"--imgformat","PNG",
# "--logarithmic",
"--height=400",
"--width=600",
"--vertical-label","Total Throughtput",
"DEF:a=intFlow${hostname}.rrd:intFlow${intFlow}In:AVERAGE",
"DEF:b=intFlow${hostname}.rrd:intFlow${intFlow}Out:AVERAGE",
"LINE1:a#FF0000: Flow In ",
"LINE1:b#0000FF: Flow Out"
;
die "Error while updating intFlow${hostname}.rrd: $ERR\n" if $ERR;
}
}
below is my dump
<!-- Round Robin Database Dump -->
<rrd>
<version> 0001 </version>
<step> 300 </step> <!-- Seconds -->
<lastupdate> 1014326664 </lastupdate> <!-- 2002-02-21 16:24:24
EST -->
<ds>
<name> intFlow0In </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow0Out </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow1In </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow1Out </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow2In </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> 533095462 </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow2Out </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> 2017334446 </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow3In </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
</ds>
<ds>
<name> intFlow3Out </name>
<type> COUNTER </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> U </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 264 </unknown_sec>
etc.....
--
Jackson Lancaster, CCNP
Integrated Computer Solutions
334.270.2892 x.15
http://www.integrate-u.com
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list