Sunday, November 06, 2005
The good news is: I can fix it!
We use MRTG to monitor bandwidth at The Company. I've recently been tasked with taking over the monitoring machines for the network overall. I had to reinstall the operating system on one of the two monitoring systems, and once I get things settled with that server, I can then move on to reinstalling the other monitoring server.
If I weren't so darned diplomatic, I'd call MRTG a piece of XXXX, but I'm not like that, so let's just say that MRTG has it's problems.
I installed MRTG a few weeks ago but you'd never know it as random logfiles seem to get truncated mysteriously. So, now that things have more or less returned to normal, I start looking into this.
MRTG is buggier than a flea circus. I get a lot of this:
Use of uninitialized value in concatenation (.) or string at /usr/bin/mrtg line 1197.
Oh, guess what? MRTG is written in Perl.
Lovely.
Checking out the offending line:
print HTML <<"TEXT"; <!-- maxin $peri $$maxin{$peri}{$router} --> <!-- maxout $peri $$maxout{$peri}{$router} --> TEXT
So, it's unlikely that $peri
is undefined due to the context
(it's the index of the loop this code appears in), so that leaves
$router
, %maxin
or the hash referenced by
$maxin{$peri}
. It doesn't really hurt the program
that one of these is undefined (since in a string context, Perl returns an
empty string for an undefined reference or scalar or whatever is undefined
at this point) but I get the warning anyway because the programmer
added a use strict
, which is used to track down such problems
(I guess, otherwise, why use it?). I'm guessing that this isn't normally
supposed to happen, and is indicative of a deeper problem in the code.
Somewhere.
And it's not like it happens on the same log file. No, that would be too easy. Nope. It just randomly changes on which log file it's spewing this out on.
I thought that it might have something to do with the 95th percentile patch, but nope. That's been temporarily disabled and the errors are still cropping up.
Another lovely error I keep seeing:
Rateup WARNING: /usr/bin/rateup Can't rename uplink.tmp to uplink.log updating log file
MRTG uses a
program called rateup
to store the actual information. This
time, rateup is a C program and the error code is less than
stellar—why couldn't you rename the file? Would it have been
that hard to print out the system error?
But this is open source, right? I can modify the code myself to include
more information. So I grab the source code to the version of MRTG that's installed, and go
to compile rateup
…
checking for gd.h... no ** Ooops, one of many bad things happened: a) You don't have the GD library installed. Get it from http://www.boutell.com, compile it and use either --with-gd-lib=DIR and --with-gd-inc=DIR to specify its location. You might also have to use --with-z-inc, --with-z-lib and --with-png-inc, --with-png-lib for gd versions 1.6 and higher. Check config.log for more information on the problem. b) You have the GD library installed, but not the gd.h header file. Download the source (see above) and use --with-gd-inc=DIR to specify where the file can be found. c) You have the library and the header file installed, but you also have a shared GD library in the same directory. Remove the shared library files and/or links (e.g. libgd.so.2.0.0, libgd.so and libgd.so.2). This is especially likely if you're using a recent (post 1.8.4) version of GD and didn't configure it with --disable-shared. d) You have gd library installed and also it's headers, but you are missing libpng (and headers) or freetype (and headers) (mrtg does not use freetype, but if your copy of gd is precompiled against it, you have to install it ... Consider following the instructions in doc/mrtg-unix-guide.txt
Okay, but this is a fresh Fedora Core install, so I should be able to use the package manager to install the GD developer libraries. All I need to do is find out what it's called:
GenericUnixPrompt# yum search gd
Ten minutes later, nine of which were spent updating the master list with a bazillion packages that have been added and/or updates since I installed about three weeks ago (and it seemed like it upated the master list multiple times no less!) I finally got a list of a few zillion matches.
So I run the command again, only this time redirect the output to a file that I can search. I find the package I need:
GenericUnixPrompt# yum install gd-devel
A minute goes by while it updates the half-zillion packages that have suddenly upgraded in the past two minutes, and it's asking me if I want to install half a dozen development libraries, including the X Windows development libraries!
No!
No!
I don't care for the X Windows development libraries.
But the package maintainers don't care about my wants! They, in their infinite wisdom, have decreed that if one wishes to develop using GD, then one must also with to develop with X Windows.
Sigh. What's another 10 megabytes of wasted disk space?
Hack. Hack. Hack. Compile. Install the new rateup
.
Now I get:
Rateup WARNING: /usr/bin/rateup Can't rename uplink.log to uplink.old updating log file [No such file or directory]
Okay … so what happened to the log file?
And a missing log file only rates a warning?
This is some well written software here.
Ah well … back to debugging other people's code.