MGM: Maxwell's Generalized Monitoring Tool

Most Recent Change: Sun Oct 31 21:54:06 1999 UTC.

MGM is written in Perl 5 using the Tk toolkit. I develop and test it under Red Hat Linux, though it should run under any version of Unix. I'm providing the MGM source code and a needed Perl library.

The code is nearly complete. When finished, it will be released under the GPL.


MGM is a simple but amazingly useful little tool -- it acts like a thousand tools in one. (NOW how much would you pay? But wait! There's more!) I originally wrote it as a quick hack to watch /proc/interrupts on my Linux box. In honor of that heritage, if you run
	mgm
(no arguments), you see this:

[MGM
watching /proc/interrupts]

The interrupt counts update every second, and the window automatically resizes to fit around its input (even as the file's contents change).

Now, I knew there would be other files I'd be interested in watching -- for instance, sometimes I'd want a window to help me keep an eye on the system's load average. So I can type

	mgm -f /proc/loadavg
and this is what I see (again, updated every second):

[MGM watching /proc/loadavg]

The cool part was when I realized that, thanks to Perl's nifty file-opening semantics, I could also watch the output of processes simply by appending a "|" to the filename:

	mgm -f 'date|' -t Clock

[MGM as a clock]

-- a cheap clock (remember, it updates every second -- Web pages can't show everything ...). In the same vein, here's a cheap printer queue that updates every 15 seconds:

	mgm -f 'lpq|' -t 'Print Queue' -d 15

[MGM as a printer queue display]

Yet another application involves watching /var/log/messages:

	mgm -f 'tail -20 /var/log/messages|' -t 'System Messages' -d 10

[MGM watching
the tail of /var/log/messages]

(We told this one to update every 10 seconds.)

Cool, eh? Here are some more tricks MGM can play:

	# Who's on, and what are they doing?
	mgm -f 'w|'

	# How much disk space is free, and where is it?
	# (Updated once every thirty seconds.)
	mgm -f 'df|' -t 30

	# How much memory is free?
	mgm -f 'free -k|'

	# A more informative (but more CPU-intensive) version
	# of the above:
	mgm -f /proc/meminfo

	# Show me a fortune once per minute.
	mgm -f 'fortune|' -d 60 -t 'Fortune of the Minute'

	# You can even put multiple commands in the pipeline.
	# This watches what root is doing:
	mgm -f 'ps auxw|grep ^root|' -t 'Eye on Root'

To me, the really amazing part is how little code I had to write to make this work. Though it's not finished, MGM currently comprises fewer than 300 lines of code, including blank lines and comments. (When I quit fiddling with this Web page and finish the script, it should still be under 400 lines.) Perl/Tk is kinda neat.


Up.

[Support Free Speech Online] [Best Viewed with Any Browser] [Made with Emacs!] [Boycott Micro$oft] [Page Counter]

s-max@pacbell.net