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.
/proc/interrupts on my Linux box. In honor of that
heritage, if you run
mgm(no arguments), you see this:
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/loadavgand this is what I see (again, updated every second):
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
-- 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
Yet another application involves watching
/var/log/messages:
mgm -f 'tail -20 /var/log/messages|' -t 'System Messages' -d 10
(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.
s-max@pacbell.net