CGI Script to turn PMWHO into a MODEM STATUS

Mike Jipping (jipping@cs.hope.edu)
Mon, 23 Oct 1995 10:00:50 -0400

> ps: Does anyone have any cgi tools which allows a user to check the
> amount of time they have accumulated?
>
> -----------------------------------------------------------------------------
> Jeff Wheat jeff@cetlink.net Network Systems Engineer
> Computer Enhancement Technologies, Inc, South Carolina +1.803.327.2754
> -----------------------------------------------------------------------------

Well...no I don't have this (and would love one), BUT I recently wrote a cool little
script that turns the output of "pmwho" (from the "pmwho.c" floating around) into
a "modem usage" page.

I have included the CGI Perl script below.

For a demo, check out "http://www.macatawa.org/cgi-bin/mstat.pl". Pretty cool for
our users.

-- Mike

-------------------------------------------------------------
Mike Jipping | jipping@cs.hope.edu
Hope College | (616) 395-7509
Department of Computer Science |

"... Dogs are the leaders of the planet. If you see two life
forms, one of them's making a poop, the other's carrying it for
him, who would you assume is in charge?"
-- Jerry Seinfeld, "SeinLanguage"

============================================
#!/usr/contrib/bin/perl

sub gen_header
{
print 'Content-type: text/html

<META HTTP-EQUIV="Refresh" CONTENT=900>
MAFN Modem Usage Statistics

MAFN Modem Usage Statistics

Here is a visual representation of the current usage status of the MAFN modem bank.

Busy Modem
Unused Modem

' } sub gen_modem_count { open(PMWHO, "/usr/local/bin/pmwho |"); $line = 0; while () { chop(); if ($line > 1) { ($port,$rest) = split(/ /); } $modem{$port} = 1; $line ++; } $count = 0; for ($line=0; $line<16; $line ++) { if ($modem{"S".$line}) { $count ++; print ' '; } else { print ' '; } } } sub gen_modem_stats { $util = $count / 16 * 100; $date = `date`; print "

Time of sample: $date
"; printf("Utilization = %5.1f%%\n

", $util); } sub close_doc { print " "
}

&gen_header();
&gen_modem_count();
print '<BR><BR><IMG SRC="/hoz_rule.gif" ALT=>';
&gen_modem_stats();
&close_doc();