[rrd-users] Re: Easy question? How to monitor a dsl-line
Daniel Herrington
danielh at ftc.agilent.com
Mon Nov 6 18:00:12 MET 2000
Rene,
I don't use snmp. Here's what I do. Hope this is not too verbose.
The key is in the "update_battery_rrd" script. You can use any script
or executable that returns numerical values to update your round-robin
database. I use the returned values from a program I wrote. These
values are returned to a perl variable, which is then parsed and used
in a call to RRDs::update. If you want to use "ping", then just
create a perl script that runs ping and gets the returned text
string. Parse it for the values you want to record, then call
RRDs::update with these values. It's that simple.
Steps:
------
I. First I create a set of scripts:
1. "/usr/local/bin/create_battery_rrd":
---------------------------------------
#! /usr/bin/perl
use lib qw( /usr/local/rrdtool-1.0.28/lib/perl ../lib/perl );
use RRDs;
my $start=time;
my $rrd="/home/httpd/html/rrds/battery.rrd";
my $name = $0;
$name =~ s/\.pl.*//g;
RRDs::create ($rrd, "--start",$start-1, "--step",600,
"DS:bat1:GAUGE:600:U:U",
"DS:bat2:GAUGE:600:U:U",
"DS:spy5:GAUGE:600:U:U",
"DS:spy12:GAUGE:600:U:U",
"DS:spyn12:GAUGE:600:U:U",
"DS:tmp1:GAUGE:600:U:U",
"DS:tmp2:GAUGE:600:U:U",
"DS:tmp3:GAUGE:600:U:U",
"RRA:AVERAGE:0.5:1:600",
"RRA:AVERAGE:0.5:3:700",
"RRA:AVERAGE:0.5:12:775",
"RRA:AVERAGE:0.5:144:797",
"RRA:MIN:0.5:1:600",
"RRA:MIN:0.5:3:700",
"RRA:MIN:0.5:12:775",
"RRA:MIN:0.5:144:797",
"RRA:MAX:0.5:1:600",
"RRA:MAX:0.5:3:700",
"RRA:MAX:0.5:12:775",
"RRA:MAX:0.5:144:797",
);
my $ERROR = RRDs::error;
die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
print "This script has created $rrd\n";
2. "/usr/local/bin/update_battery_rrd":
---------------------------------------
#! /usr/bin/perl
use lib qw( /usr/local/rrdtool-1.0.28/lib/perl ../lib/perl );
use RRDs;
my $t=time;
my $rrd="/home/httpd/html/rrds/battery.rrd";
$values = `/usr/local/bin/das`;
$values =~ s/\n$//;
#print $values . "\n";
RRDs::update $rrd, "$t:" . $values;
if ($ERROR = RRDs::error) {
die "$0: unable to update `$rrd': $ERROR\n";
}
3. "/usr/local/bin/rm_old_battery_graphs":
------------------------------------------
#!/bin/tcsh
rm -f /home/httpd/html/gifs/battery_day.gif
rm -f /home/httpd/html/gifs/supply_day.gif
rm -f /home/httpd/html/gifs/temperature_day.gif
rm -f /home/httpd/html/gifs/light_day.gif
rm -f /home/httpd/html/gifs/battery_week.gif
rm -f /home/httpd/html/gifs/supply_week.gif
rm -f /home/httpd/html/gifs/temperature_week.gif
rm -f /home/httpd/html/gifs/light_week.gif
rm -f /home/httpd/html/gifs/battery_month.gif
rm -f /home/httpd/html/gifs/supply_month.gif
rm -f /home/httpd/html/gifs/temperature_month.gif
rm -f /home/httpd/html/gifs/light_month.gif
II. Then I also create some html/cgi stuff:
1. "/home/httpd/html/index.html":
---------------------------------
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Herky Jerky's Pages</title>
<meta name="Owner" value="Daniel Herrington">
<meta name="Email" value="daniel at verinet.com">
<meta name="Author" value="Daniel Herrington">
<meta name="Keywords" value="homebrew, homemade, robot, motor, control,
autonomous, daniel, herrington, herky, jerky, speech, synthesis,
sonar, ultrasonic, range, circuit, board, mechanical, schematic,
netlist, linux, sensor, infrared, remote, power, control, avr,
at90s, program, software, dprg, layout, pcb, bump, ring, dc,
encoder, lm629, lmd18200t, spo256">
</head>
<body>
<center>
<h1>Herky Jerky the Robot</h1>
</center>
<a href="/cgi-bin/vital_signs_day.cgi">Vital Signs: Day View</a>
<p>
<a href="/cgi-bin/vital_signs_week.cgi">Vital Signs: Week View</a>
<p>
<a href="/cgi-bin/vital_signs_month.cgi">Vital Signs: Month View</a>
</body>
</html>
2. "/home/httpd/cgi-bin/vital_signs_day.cgi":
---------------------------------------------
#!/usr/local/rrdtool-1.0.28/bin/rrdcgi
<HTML>
<HEAD><TITLE>Vital Signs: Day View</TITLE></HEAD>
<BODY>
<RRD::GOODFOR 600>
<center>
<H1>Vital Signs: Day View</H1>
Current Time:<RRD::TIME::NOW %c>
<p>
Last Update:<RRD::TIME::LAST /home/httpd/html/rrds/battery.rrd %c>
<H2>Batteries</H2>
<RRD::GRAPH /home/httpd/html/gifs/battery_day.gif
--imginfo '<IMG SRC=/gifs/battery_day.gif>'
--start -1d --end now
--lower-limit 8
--upper-limit 16
--rigid
--lazy
--width 600
--height 300
DEF:battery1=/home/httpd/html/rrds/battery.rrd:bat1:AVERAGE
DEF:battery2=/home/httpd/html/rrds/battery.rrd:bat2:AVERAGE
LINE2:battery1#ff0000:Battery1
LINE2:battery2#0000ff:Battery2
>
<br>
<H2>Power Supplies</H2>
<RRD::GRAPH /home/httpd/html/gifs/supply_day.gif
--imginfo '<IMG SRC=/gifs/supply_day.gif>'
--start -1d --end now
--lower-limit -15
--upper-limit 15
--rigid
--lazy
--width 600
--height 300
DEF:supply5=/home/httpd/html/rrds/battery.rrd:spy5:AVERAGE
DEF:supply12=/home/httpd/html/rrds/battery.rrd:spy12:AVERAGE
DEF:supplyn12=/home/httpd/html/rrds/battery.rrd:spyn12:AVERAGE
LINE2:supply5#00ff00:+5V_Supply
LINE2:supply12#0000ff:+12V_Supply
LINE2:supplyn12#ff0000:-12V_Supply
>
<br>
<H2>Temperatures</H2>
<RRD::GRAPH /home/httpd/html/gifs/temperature_day.gif
--imginfo '<IMG SRC=/gifs/temperature_day.gif>'
--start -1d --end now
--lower-limit 50
--upper-limit 150
--rigid
--lazy
--width 600
--height 300
DEF:temp1=/home/httpd/html/rrds/battery.rrd:tmp1:AVERAGE
DEF:temp2=/home/httpd/html/rrds/battery.rrd:tmp2:AVERAGE
LINE2:temp1#ff0000:Temperature_1
LINE2:temp2#0000ff:Temperature_2
>
<br>
<H2>Light</H2>
<RRD::GRAPH /home/httpd/html/gifs/light_day.gif
--imginfo '<IMG SRC=/gifs/light_day.gif>'
--start -1d --end now
--lower-limit 0
--upper-limit 200
--rigid
--lazy
--width 600
--height 300
DEF:light1=/home/httpd/html/rrds/battery.rrd:tmp3:AVERAGE
LINE2:light1#ff0000:Light
>
</center>
</BODY>
</HTML>
3. "/home/httpd/cgi-bin/vital_signs_week.cgi":
----------------------------------------------
#!/usr/local/rrdtool-1.0.28/bin/rrdcgi
<HTML>
<HEAD><TITLE>Vital Signs: Week View</TITLE></HEAD>
<BODY>
<RRD::GOODFOR 600>
<center>
<H1>Vital Signs: Week View</H1>
Current Time:<RRD::TIME::NOW %c>
<p>
Last Update:<RRD::TIME::LAST /home/httpd/html/rrds/battery.rrd %c>
<H2>Batteries</H2>
<RRD::GRAPH /home/httpd/html/gifs/battery_week.gif
--imginfo '<IMG SRC=/gifs/battery_week.gif>'
--start -1wk --end now
--lower-limit 8
--upper-limit 16
--rigid
--lazy
--width 600
--height 300
DEF:battery1=/home/httpd/html/rrds/battery.rrd:bat1:AVERAGE
DEF:battery2=/home/httpd/html/rrds/battery.rrd:bat2:AVERAGE
LINE2:battery1#ff0000:Battery1
LINE2:battery2#0000ff:Battery2
>
<br>
<H2>Power Supplies</H2>
<RRD::GRAPH /home/httpd/html/gifs/supply_week.gif
--imginfo '<IMG SRC=/gifs/supply_week.gif>'
--start -1wk --end now
--lower-limit -15
--upper-limit 15
--rigid
--lazy
--width 600
--height 300
DEF:supply5=/home/httpd/html/rrds/battery.rrd:spy5:AVERAGE
DEF:supply12=/home/httpd/html/rrds/battery.rrd:spy12:AVERAGE
DEF:supplyn12=/home/httpd/html/rrds/battery.rrd:spyn12:AVERAGE
LINE2:supply5#00ff00:+5V_Supply
LINE2:supply12#0000ff:+12V_Supply
LINE2:supplyn12#ff0000:-12V_Supply
>
<br>
<H2>Temperatures</H2>
<RRD::GRAPH /home/httpd/html/gifs/temperature_week.gif
--imginfo '<IMG SRC=/gifs/temperature_week.gif>'
--start -1wk --end now
--lower-limit 50
--upper-limit 150
--rigid
--lazy
--width 600
--height 300
DEF:temp1=/home/httpd/html/rrds/battery.rrd:tmp1:AVERAGE
DEF:temp2=/home/httpd/html/rrds/battery.rrd:tmp2:AVERAGE
LINE2:temp1#ff0000:Temperature_1
LINE2:temp2#0000ff:Temperature_2
>
<br>
<H2>Light</H2>
<RRD::GRAPH /home/httpd/html/gifs/light_week.gif
--imginfo '<IMG SRC=/gifs/light_week.gif>'
--start -1wk --end now
--lower-limit 0
--upper-limit 200
--rigid
--lazy
--width 600
--height 300
DEF:light1=/home/httpd/html/rrds/battery.rrd:tmp3:AVERAGE
LINE2:light1#ff0000:Light
>
</center>
</BODY>
</HTML>
4. "/home/httpd/cgi-bin/vital_signs_month.cgi":
-----------------------------------------------
#!/usr/local/rrdtool-1.0.28/bin/rrdcgi
<HTML>
<HEAD><TITLE>Vital Signs: Month View</TITLE></HEAD>
<BODY>
<RRD::GOODFOR 600>
<center>
<H1>Vital Signs: Week View</H1>
Current Time:<RRD::TIME::NOW %c>
<p>
Last Update:<RRD::TIME::LAST /home/httpd/html/rrds/battery.rrd %c>
<H2>Batteries</H2>
<RRD::GRAPH /home/httpd/html/gifs/battery_month.gif
--imginfo '<IMG SRC=/gifs/battery_month.gif>'
--start -1m --end now
--lower-limit 8
--upper-limit 16
--rigid
--lazy
--width 600
--height 300
DEF:battery1=/home/httpd/html/rrds/battery.rrd:bat1:AVERAGE
DEF:battery2=/home/httpd/html/rrds/battery.rrd:bat2:AVERAGE
LINE2:battery1#ff0000:Battery1
LINE2:battery2#0000ff:Battery2
>
<br>
<H2>Power Supplies</H2>
<RRD::GRAPH /home/httpd/html/gifs/supply_month.gif
--imginfo '<IMG SRC=/gifs/supply_month.gif>'
--start -1m --end now
--lower-limit -15
--upper-limit 15
--rigid
--lazy
--width 600
--height 300
DEF:supply5=/home/httpd/html/rrds/battery.rrd:spy5:AVERAGE
DEF:supply12=/home/httpd/html/rrds/battery.rrd:spy12:AVERAGE
DEF:supplyn12=/home/httpd/html/rrds/battery.rrd:spyn12:AVERAGE
LINE2:supply5#00ff00:+5V_Supply
LINE2:supply12#0000ff:+12V_Supply
LINE2:supplyn12#ff0000:-12V_Supply
>
<br>
<H2>Temperatures</H2>
<RRD::GRAPH /home/httpd/html/gifs/temperature_month.gif
--imginfo '<IMG SRC=/gifs/temperature_month.gif>'
--start -1m --end now
--lower-limit 50
--upper-limit 150
--rigid
--lazy
--width 600
--height 300
DEF:temp1=/home/httpd/html/rrds/battery.rrd:tmp1:AVERAGE
DEF:temp2=/home/httpd/html/rrds/battery.rrd:tmp2:AVERAGE
LINE2:temp1#ff0000:Temperature_1
LINE2:temp2#0000ff:Temperature_2
>
<br>
<H2>Light</H2>
<RRD::GRAPH /home/httpd/html/gifs/light_month.gif
--imginfo '<IMG SRC=/gifs/light_month.gif>'
--start -1m --end now
--lower-limit 0
--upper-limit 200
--rigid
--lazy
--width 600
--height 300
DEF:light1=/home/httpd/html/rrds/battery.rrd:tmp3:AVERAGE
LINE2:light1#ff0000:Light
>
</center>
</BODY>
</HTML>
III. I then create a "/home/httpd/html/rrds" directory, and run the
previously-mentioned "create_battery_rrd". This generates the
initial round-robin database.
IV. Finally I set up a cron job to be performed every ten minutes.
Just log in as root, run "crontab -e", and add a line or two (see
the man page for crontab or cron for more details).
E.g. "crontab -e":
------------------
0-50/10 * * * * /usr/local/bin/update_battery_rrd
0-50/10 * * * * /usr/local/bin/rm_old_battery_graphs
V. So what does all of this do? It monitors my batteries, power
supplies, temperature sensors, and light sensor on my robot. It
updates the values in the database every 10 minutes, based on the
cron job. The program "/usr/local/bin/das" is a c-program that
does some IO reads to check a data-acquisition-system IC.
The results of the updates can be viewed by browsing the
(local) webpage for my robot. When I click on one of the
three choices, "Day View," "Week View", or "Month View," I get a
current set of graphs for the battery voltages, the power supply
voltages, the temperature sensors, and the light sensor.
Hope this helps,
Daniel Herrington
--
------------------------------------------------------------------
Agilent Technologies Email: danielh at ftc.agilent.com
4380 S. Ziegler Road Phone: 970-288-0661
MS 72 Fax: 970-288-6580
Fort Collins, CO 80525-9790 http://members.home.net/daniel.herrington/
------------------------------------------------------------------
=> Replying to Rene Hertell's message, "[rrd-users] Re: Easy question? How to monitor a dsl-line" (Nov 6):
>
> Thanks for the link. I just noticed that rrdtool probably uses only snmp for
> getting statistics. The only problem is that I have no clue in how to use
> snmp. Is it possible to use rrdtool with some common Linux tools (ping?).
>
> Regards, René
>
--
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