I took the liberty of expanding on this and came up with a useful top-like script (including filter links and formatted fields):
#!/usr/bin/perl -w use strict; use CGI 'param'; use CGI::Push qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); do_push( -nph => 0, -delay => 2, -next_page => sub { my($q, $count) = @_; my @return; my $command = "ps -auxwr"; $command .= " -U ".getpwuid(param("uid")) if param("uid") =~ /^[0-9]+$/; my @lines = split /\n/, `$command`; my @header = split /\s+/, shift @lines; my %format = ( "USER" => sub { my($value) = @_; my $uid = getpwnam($value); return $value if ($uid == param("uid") && defined param("uid")); return "<a href=\"$ENV{SCRIPT_NAME}?uid=$uid\">$value< +/a>"; }, "\%CPU" => sub { my($value) = @_; return ($value > 0.0) ? "<b>$value%</b>" : "$value%"; }, "\%MEM" => sub { my($value) = @_; return "$value%"; }, "VSZ" => sub { my($value) = @_; $value =~ s/(?<=\d)(?=(\d\d\d)+$)/,/g; return "$value&nbsp;kb"; }, "RSS" => sub { my($value) = @_; $value =~ s/(?<=\d)(?=(\d\d\d)+$)/,/g; return "$value&nbsp;kb"; } ); push @return, <<EOF; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <title>$ENV{SERVER_NAME}: $command</title> </head> <body> <table border="1"> <tr> EOF foreach(@header) { push @return, " <th>$_</th>\n"; } push @return, " </tr>\n"; foreach(@lines) { my @field = split(/\s+/, $_, $#header+1); push @return, " <tr>\n"; my $f=0; foreach(@field) { $_ = &{$format{$header[$f]}}($_) if(defined $format{$header[$f]}); push @return, " <td>$_</td>\n"; $f++; } push @return, " </tr>\n"; } push @return, <<EOF; </table> </body> </html> EOF return @return; }, );

In reply to Re: Server status through HTTP using CGI::Push (HTML version) by itodd
in thread Server status through HTTP using CGI::Push by itodd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.