September 13, 2003
Graphs are a good thing

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.

Posted September 13, 2003 08:37 PM in Geek Stuff
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/916
Comments
On September 13, 2003 10:36 PM Bill Allaire added:

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.

#
On September 14, 2003 01:46 AM Rob Speicher added:

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?

#
On September 14, 2003 01:48 AM kasia added:

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)

#
On September 14, 2003 06:39 AM Ben added:

Another nice tool you could use for this is gkrellm.

#
On September 14, 2003 11:07 AM Harald added:

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/

#
On September 14, 2003 12:05 PM Wilson added:

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.

#
On September 14, 2003 11:55 PM Jeremy Zawodny added:

Why would a program with a memory leak cause a server crash? It's not like you're running Windows...

#
On September 15, 2003 09:59 AM kasia added:

Have you seen what happens to some unix services when the server runs out of ram?

#
On September 16, 2003 03:10 PM Jeremy aka bad-magic-number added:

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*

#
On September 18, 2003 06:43 PM Captain James added:

> 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.

#
Trackbacks
notebook:mrtg is a good thing
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
The Nameless Site:Site Updates, don't forget about stacy's mom, 'cause she has it going on.
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