[mrtg-developers] MRTG RRD data retreival
Israel Brewster
israel at frontierflying.com
Tue Jan 16 21:47:37 MET 2007
I have what I hope will be a simple question. Forgive me if it is too
simple, but this is my first time working with MRTG beyond a basic
monitoring setup.
the short version:
I am attempting to write a shell script that will retrieve the latest
values from a MRTG rrd file, which, as I understand it, should be the
average traffic in/out of a given port over the interval specified in
the mrtg config. The question I have, in a nutshell, is what is the
easiest way to pull these values from the rrd file mrtg creates? I
know I need to use a rrdtool fetch command on the file, and then
parse the results, but I am having a little trouble figuring out what
rrdtool command exactly to use and how to parse the results.
The long version:
What I currently have in my script is the following two lines (thanks
to someone on another mailing list):
VALUEIN="$($RRDTOOL/rrdtool fetch $RRDFILES/$FILE AVERAGE -s-5minutes
| awk 'BEGIN { IFS=":" } NR==3 { printf("%d\n", $2 * 8) }')"
VALUEOUT="$($RRDTOOL/rrdtool fetch $RRDFILES/$FILE AVERAGE -
s-5minutes | awk 'BEGIN { IFS=":" } NR==3 { printf("%d\n", $3 * 8) }')"
The problem, though, is that the numbers these return don't appear to
match up with the numbers that routers2.cgi shows for cur In and Cur
Out. Sometimes they seem similar, other times they appear way off. I
have a number of hypotheses for why this might be, but I don't know
which (if any) are correct:
1) Looking at that command line, it looks like rrdtool is fetching
the average values for the last 5 minutes. I have no clue what
specifically the awk portion of the command is doing, other than the
obvious of parsing out a number. As I have the MRTG interval set to 1
minute, perhaps this is throwing things off? If so, I would need to
modify the command so it doesn't mater what the MRTG interval is set
to, it just gets the latest values. How would I do this? Looking at
the rrdtool man page, it would seem the command I want would be
rrdtool fetch <path/to/rrd/file> LAST, but trying this command on the
command line gives an "ERROR: the RRD does not contain an RRA
matching the chosen CF" error
2) The awk command isn't correctly parsing the results. As I have
never worked with awk before, and only have a vague idea what it is
doing in this case (as I said, these lines of code were given to me),
I have no idea on this one.
3) routers2 is returning the wrong results. Yeah. Right. Not likely.
4) Both results are correct, 51023 bps=15.31 k, and I'm just
completely insane. Ok, so you probably have me on the insanity part
regardless, but...
So, how can I make this work as expected? I am running MRTG 2.12.2 on
OpenBSD 4.0 with rrdtool 1.0.49 -yes, I know those versions are
somewhat old, but that is was came in the ports for OpenBSD. Thanks
for any assistance you can provide.
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service INC.
5245 Airport Industrial Rd
Fairbanks, AK 99709
-----------------------------------------------
--
Unsubscribe mailto:mrtg-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:mrtg-developers-request at list.ee.ethz.ch?subject=help
Archive http://lists.ee.ethz.ch/mrtg-developers
More information about the mrtg-developers
mailing list