mrtg is an extremely handy little graphing tool, contrary to its primary use (routers) I've been using it for graphing pretty much everything on my server and compiling a page of daily graphs to glance on now and then..
Sure, it may sound like a waste of time.. but the pretty little graphs saved my behind today..
Here's a graph image of my server's memory usage earlier today.. a perl script with a glaring bug in it caused this.. and would have probably caused a server crash if I hadn't noticed the increasing memory usage.
How hard is it to do this? Easier than making windows crash..
1. Download and install mrtg.
2. Create a small script to gather the 4 inputs mrtg is looking for.
3. Configure mrtg to call the above mentionied script and gather information and graph it.
That's about all..
If you promise not to laugh at my bad perl, you can take a look at my memory script here and the snipnet for mrtg configuration file here.
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/916
Isn't MRTG a wonderful tool? When I worked at ISP's we'd use it for monitoring everything from CPU temperatures to software (MySQL stats for example) to the usual router and switch interface statistics.
While the tool is good for immediate trends the longer term trends the graphs can bring out are of great help.
#Once you've discovered that there's something using an increasing amount of memory, what'd you do to isolate the perl script as the culprit?
#Well, in this case a simple ps revealed it, since the perl script was spawning other processes.
But if it's a single process.. top should do it.
Top then sort by memory (M)
#Another nice tool you could use for this is gkrellm.
#Just an FYI: opening and reading /proc/meminfo is more efficient than running free | grep. This is particularly important when your machine is running out of memory, or otherwise very busy.... :-)
I use mrtg to graph the offset and stability of my NTP network... http://persephone.cfrq.net/ntpd/
#Just like Bill Allaire, we use MRTG to graph *everything*. We have a central server just for this, and we use BigBrother on the other servers to send the data to the central point, and several small scripts to parse the BB data into the MRTG format. We graph http hits, e-mail deliveries and failures, server room temperature an everything in between. It's great and, best of all, free.
Why would a program with a memory leak cause a server crash? It's not like you're running Windows...
#Have you seen what happens to some unix services when the server runs out of ram?
#Yeah, MRTG comes in handy for seeing trends. I remember using it to track the amount of traffic a file on my home webserver was generating back in the days of Telocity. I never imagined that one set of files would cause a download frenzy that would max out a 256kbps upload channel nonstop... That file quickly moved off network.
As for the memory script... Perl... *shudder shudder*
#> Why would a program with a memory leak cause a server crash? It's not like you're running Windows...
When Linux runs out of VM, the OOM strategy is to randomly kill processes, until init is killed. So yes, one little perl script can easily bring down linux.
#After reading unix-girl's post on mrtg, I remembered using it a long time ago for a job. This may be able to help me with isolating why the colo box reboots every now and again. If i can isolate traffic...
(read more)
September 19, 2003 10:23 AM
I think, After exams are over (yes, I have *another* dose of midterms this week.. well one..), I might have to do a site update. The font sizes and other such items help to make my writing look very... unprofessional...
(read more)
November 11, 2003 04:56 AM