[mrtg] Re: HELP: MRTG logging different values from external program
Alex van den Bogaerdt
alex at slot.hollandcasino.nl
Tue Nov 28 01:05:12 MET 2000
John Turner wrote:
> My problem: MRTG is not logging the same values that my external script is
> sending. In [target].log, the values are quite a bit different than what my
> scripts are sending. I know this from logging to a completely separate
> file, and comparing the two value lists.
MRTG should not store the same values in its log file. It works with
average rates in normalized time slots.
> To make matters stranger, I created a script that issues the same two
> numbers over and over and over, never changing. MRTG logged DIFFERENT
> values the very first time the script was called, but since has been logging
> the correct values.
This also is due to normalizing the data.
What now follows is a lengthy example, perhaps veterans should skip
the rest :)
Also, for people not using unix, you will need to change the
commands a bit. I will explain the commands.
Let's assume it takes 60 seconds to start mrtg, collect the data
and so forth. This means that the data you collect is not valid
for a time "t" but for "t+60". In the next round, you also will
have a 60 second delay, getting data on "t+60+300" not "t+300".
MRTG needs to massage the data into normalized time slots. How
will it do so? By calculating how much of the data is valid in
the current time slot and how much is valid for the next time slot.
If MRTG needs to calculate the average rate for time slot T to T+300
and so on while you are entering data at T+60, T+360, T+660 and so on,
this is what happens:
12:01:00 value 600
12:06:00 value 600
12:11:00 value 600
12:16:00 value 200
12:21:00 value 200
12:26:00 value 200
Let's feed this to rateup (MRTGs back end):
(do this before 23:00 or you will run into an error!)
rateup /tmp tmp t `date -d '23:01:00' +%s` g 600 600 20000
explanation:
calculate the unix time stamp for today, 23:01:00. You
need to find an equivalent for "date" on your OS if necessary.
The resulting number (975448860 in this case) is fed to
rateup together with some options. The total rateup command
becomes: use directory /tmp, use file base name tmp, use
time 975448860, store gauges 600,600 and set MaxBytes to 20000.
Not sure but my guess is that WinNT people should use something
like: \mrtg\rateup.exe \tmp tmp t 975448860 g 600 600 20000
head -5 /tmp/tmp.log
explanation:
show the first five lines of file /tmp/tmp.log
Just use "more < \tmp\tmp.log" if you have no head...
975448860 600 600 <--- note the time stamp
975448860 0 0 0 0
975367800 0 0 0 0
975367500 0 0 0 0
975367200 0 0 0 0
rateup /tmp tmp t `date -d '23:06:00' +%s` g 600 600 20000
head -5 /tmp/tmp.log
975449160 600 600
975449160 600 600 600 600 <--- time stamp
975448860 0 0 0 0
975448800 0 0 0 0
975448500 0 0 0 0
rateup /tmp tmp t `date -d '23:11:00' +%s` g 600 600 20000
head -5 /tmp/tmp.log
975449460 600 600
975449460 600 600 600 600
975449160 600 600 600 600
975449100 480 480 600 600 <--- See what happens?
975448800 0 0 0 0
rateup /tmp tmp t `date -d '23:16:00' +%s` g 600 600 20000
head -5 /tmp/tmp.log
975449760 200 200
975449760 200 200 200 200
975449460 600 600 600 600 <--- time stamp
975449400 600 600 600 600 <--- time stamp
975449100 480 480 600 600
rateup /tmp tmp t `date -d '23:21:00' +%s` g 600 600 20000
head -5 /tmp/tmp.log
975450060 200 200
975450060 200 200 200 200
975449760 200 200 200 200
975449700 280 280 600 600 <--- changed
975449400 600 600 600 600 <--- unchanged
As you can see, the values are modified. At 23:16:00 the value 200
was input, at 23:11:00 the value 600 was input. A normalized value
is input for time 23:15:00 which is 20% of 600 and 80% of 200. That
can be explained: during 20% of the time (23:10..23:11) the
value has been 600. During the other 80% of the time (23:11..23:15)
the value has been 200.
Hope this helps,
--
__________________________________________________________________
/ alex at slot.hollandcasino.nl alex at ergens.op.het.net \
| work private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. |
+----------------------------------------------------------------------+
| http://faq.mrtg.org/ |
| http://rrdtool.eu.org --> tutorial |
+----------------------------------------------------------------------+
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list