I am trying to use MRTG on my own incremental data.
I am using the following mrtg.cfg:
Title[trans]: Database - Tester
MaxBytes[trans]: 25
AbsMax[trans]: 200
Options[trans]: nopercent noinfo
Target[trans]: `/tools/database/test`
PageTop[trans]: <h1> Database - Tester </h1>
ShortLegend[trans]: tx
Ylegend[trans]: Transactions
LegendI[trans]: Transactions
LegendO[trans]:
Legend1[trans]: Transactions
Legend2[trans]:
Legend3[trans]: Transactions
Legend4[trans]:
XSize[trans]: 350
YSize[trans]: 150
Directory[trans]: db_test
WithPeak[trans]: ymwd
Unscaled[trans]: ymwd
My test data is as follows:
#!/bin/bash
if [ -f test.ctr ]; then
oldnum=`cat test.ctr`
else
echo "0" > test.ctr
fi
increm='500'
newnum=$(($oldnum + $increm))
echo $newnum
echo $newnum
echo
echo "tester ctr"
echo "$newnum" > test.ctr
Basically, I'm trying to put 500 on MRTG every minute, but my logs shows 8:
1723253042 49337 49337
1723253042 8 8 8 8
1723252982 8 8 8 8
1723252800 8 8 8 8
1723252500 8 8 8 8
1723252200 8 8 8 8
I don't understand why I see 8 in the logs instead of 500. What am I doing wrong? Do I need to preprocess my data before sending it to MRTG?
I noticed that if you divide 500 by 60 (seconds), I get 8.333, which might be rounded to 8. Similarly, when I used 100 and posted every 60seconds, I got 2 from the logs, which is the rounded off 1.6666)
My data source is incremental. If I get the data 1 minute later, it is the increment after 1 minute and not after 1 second. What do I need to alter in my mrtg.cfg to make it work like that? I thought that was supposed to be the default behaviour.
You have identified the issue already.
As a result, a 500/min change is converted to 8/s (divide by 60 and rounding down). The reasoning for these defaults is because originally MRTG was designed for monitoring network traffic.
If you want your display to show in per-minute rather than per-second, you will need to multiply by 60, either at data collection time, or (better) at display time. To do this, use the Factor[]
directive to multiply by 60:
Factor[trans]: 60
ShortLegend[trans]: tx/min
The Best Practice with MRTG is to use RRDTool for storage, and store data in SI units (per-second in this case) and the do conversions at display time (in this case, multiplying by 60 to convert to per-minute). However, if using small numbers and MRTG storage, you can find this loses accuracy due to rounding.
An alternative is to set the perminute
option, which make the change at storage time, and has the same end effect on the graph. This is better if you are not using RRDTool for storage, and your rates are small, as this can handle non-integers better:
Options[trans]: perminute
ShortLegend[trans]: tx/min