[rrd-developers] Error storing data in RRD
Markus PISTAUER (CISC)
m.pistauer at cisc.at
Mon Jan 29 23:31:55 MET 2001
Hello,
I have a problem to store data correctly within the RRD data base. A
sequence of '1' and '0' will be stored in a a sequence of '0.87...' and
'0.12' (some averaging). The code to do this is below (also the log file
where I read data from) - the code is not the best but I did a lot of
testing on it - sorry for that but I have no idea how to figure out why
this problem occours.
I know that averaging is done using the RRD but as the setup of the rrd data
base shows it should not and also a max and min value is stored (to be sure)
(see image with wrong data created and attached)
Any help VERY !!! appreciated
Markus
You can cut/paste the code in file, the same for the data (select file
name xxx1.log), you will get the image xxx1.gif ...
---8<------- The CODE (Perl) ----------------
#! /usr/bin/perl
#
# MAKE RRD Database for testing purposes
###############################################################################
### --- USE the perl library for the RRD perl module
use lib qw( /usr/local/rrd/lib/perl );
use RRDp; # load RRD perl module
### --- Set global definitions and names
$main::DEBUG=0;
$STEP = 1350;
$START = 974887159;
$START = $START - $STEP;
$RRD = "./xxx1.rrd";
$GIF = "./xxx1.gif";
$ASCII = "./xxx1.log";
### --- Start rrdtool (this is a MUST !)
if ( -x "/usr/local/rrd/bin/rrdtool") {
RRDp::start "/usr/local/rrd/bin/rrdtool";
} elsif ( -x "../bin/rrdtool") {
RRDp::start "../bin/rrdtool";
} else {
RRDp::start "../src/rrdtool";
}
#*** Read log data file
open(RRD_FILE, "<$ASCII") or not_found($ASCII);
#*** Read file (line by line)
while(<RRD_FILE>) {
next if /^#/; # first line is for documentation only
push(@log_file_lines, $_); # save lines in array
}
close RRD_FILE;
print "(1) Creating RRD Data Base ... ";
RRDp::cmd "create $RRD -b $START -s $STEP
DS:anz:GAUGE:1500:U:U
DS:inoct:GAUGE:1500:U:U
DS:diffoct:GAUGE:1500:U:U
DS:outoct:GAUGE:1500:U:U
DS:pa:GAUGE:1500:U:U
DS:pm:GAUGE:1500:U:U
DS:pu:GAUGE:1500:U:U
DS:speed:GAUGE:1500:U:U
DS:traf:GAUGE:1500:U:U
DS:up:GAUGE:1500:U:U
RRA:AVERAGE:0.5:1:700
RRA:AVERAGE:0.5:8:868
RRA:AVERAGE:0.5:48:875
RRA:MAX:0.5:1:700
RRA:MAX:0.5:8:868
RRA:MAX:0.5:48:87
RRA:MIN:0.5:1:700
RRA:MIN:0.5:8:868
RRA:MIN:0.5:48:875";
$answer = RRDp::read;
print "\nAnswer RRD Create: >$answer< \n";
### ------------------------------------------
### --- (2) FILL DATA in RRD Data-Basea ---
###
print "\n(2) Filling RRD Data Base '$RRD' with some stuff ...\n";
my $step = 0;
for $logline (@log_file_lines) {
chomp;
#--- Get fields
my($anz, $stat, $inoct, $upd, $diffoct, $outoct, $pa, $pm, $pu,
$speed, $traf, $up) = split /\s+/, $logline;
$step = $step + 1;
print "\n($step) Time:$upd ANZ:$anz STAT:$stat";
$anz = $anz+0.5;
$rrd_cmdline = "update $RRD
$upd:".$anz.":".$inoct.":".$diffoct.":".$outoct.":".$pa.":".$pm.":".$pu.":".$spe
ed.":".$traf.":".$up;
RRDp::cmd $rrd_cmdline;
$answer = RRDp::read;
}
### --- (3) Create Image ---
###
print "\n(3) Creating the image '$GIF' $upd
...\n\n";
$END = $START+$step*$STEP;
RRDp::cmd "graph $GIF ", "--title 'Logins' ",
"--height 170 --vertical-label '#' ".
"--start $START",
"--end $END",
"--color ARROW#bfbfbf",
"--lower-limit 0",
"DEF:lima=$RRD:anz:MAX",
"DEF:limi=$RRD:anz:MIN",
"DEF:liav=$RRD:anz:AVERAGE",
"AREA:lima#0a22f1:Logins(MAX)",
"LINE3:limi#3a7791:Logins(MIN)",
"LINE1:liav#000000:Logins(Aver)\\c",
"COMMENT:'\\s'",
"COMMENT:'\\s'",
"COMMENT:'Graph created on: ".localtime(time())."\\c'";
$answer = RRDp::read;
### --- (4) END the RRD Tool
###
RRDp::end;
---8<------- End of Code -------------
---8<------- The log file ------------
#anz_login fetchstatus inoctets last_update octsdiff outoctets pavail
pused speed traffic up
0 ok 2837826554 974887159 130100 3826179405 0.1 0.00290851685525464 1
0.00102053222991391 1
0 ok 2837868231 974887585 73618 3826211346 0.1 0.0018278036828522 1
0.000641334625562174 1
0 ok 2837868231 974887945 73618 3826211346 0.1 0.0018278036828522 1
0.000641334625562174 1
0 ok 2837878416 974888950 30114 3826231275 0.1 0.000761922897662961 1
0.000267341367601039 1
0 ok 2837892571 974889980 36526 3826253646 0.1 0.000916415735900964 1
0.000321549381017882 1
0 ok 2838200932 974890699 329524 3826274809 0.1 0.00742750803238658 1
0.00260614316925845 1
0 ok 2838200932 974890768 329524 3826274809 0.1 0.00742750803238658 1
0.00260614316925845 1
0 ok 2838408881 974891781 229928 3826296788 0.1 0.0049952912926648 1
0.00175273378689993 1
1 ok 2838518204 974892803 131082 3826318547 0.1 0.00288455471890049 1
0.00100516261370499 1
1 ok 2838651837 974893813 162620 3826347534 0.1 0.00373125156603451 1
0.00130224922673447 1
0 ok 2838761756 974894871 133352 3826370967 0.1 0.0028960847367218 1
0.00101617008306028 1
0 ok 2838870921 974895921 131144 3826392946 0.1 0.00285703125447892 1
0.00100246710683471 1
0 ok 2838995870 974896912 149548 3826417545 0.1 0.00330649857933884 1
0.00116017494011889 1
0 ok 2839107079 974897942 132570 3826438906 0.1 0.00304740185106768 1
0.00106926380739217 1
0 ok 2839216244 974898532 130646 3826460387 0.1 0.00291974985296999 1
0.00102447363262105 1
1 ok 2839325469 974899644 130886 3826482048 0.1 0.00288934789022455 1
0.00100684442820466 1
0 ok 2839439516 974900672 137802 3826505803 0.1 0.00304502340547193 1
0.00106842926507787 1
0 ok 2839548839 974901703 131022 3826527502 0.1 0.00290342174576484 1
0.00101874447219819 1
0 ok 2839658004 974902742 130706 3826549043 0.1 0.0028958563390957 1
0.00101608994354235 1
1 ok 2839658004 974903538 130706 3826549043 0.1 0.00291569760893697 1
0.00101608994354235 1
0 ok 2839870705 974904492 237270 3826573612 0.1 0.0051053736245069 1
0.00179135916649365 1
0 ok 2839980028 974905461 131082 3826595371 0.1 0.00287665274221804 1
0.00100935183937475 1
0 ok 2840089095 974906493 130330 3826616634 0.1 0.00296544483808192 1
0.0010405069607305 1
1 ok 2840198320 974907066 130886 3826638295 0.1 0.00288678410776999 1
0.00100594485541358 1
---8<---------------------------------
-- Attached file removed by Listar and put at URL below --
-- Type: image/gif
-- Size: 22k (23062 bytes)
-- URL : http://www.ee.ethz.ch/~slist/pantomime/07-xxx1.gif
--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-developers
mailing list