Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl -w # coded by Will Stockwell(waldo@cyberspace.org) use CGI qw(:standard :html3 -no_debug); use Time::CTime; $dir = "."; #Directory location of output files $refresh = 120; # Refresh rate of HTML page for browser $hostfile = "hostlist"; $htmlfile = "linkstat.html"; $pingcnt = "3"; open(HOSTLIST, $hostfile) || die "Couldn't open $hostfile: $!"; @hostlist = <HOSTLIST>; close(HOSTLIST); open(HTMLOUT, ">$dir/$htmlfile") || die "Couldn't open $dir/$htmlfile: + $!"; print HTMLOUT "<HTML><HEAD><TITLE>Link Status</TITLE>", "<META HTTP-EQUIV='refresh' CONTENT='$refresh; '>", "</HEAD><BODY BGCOLOR='lightblue' TEXT='black'>", h1("Link Status"); @headings = ('Node', 'Description', 'Status'); @rows = th(\@headings); foreach (@hostlist) { chomp; /:/ || next; # Check for colon to be sure this is not a blank +line ($host, $desc) = split(/:/); $pingout = `/sbin/ping -c $pingcnt $host 2>&1`; # grab the pin +g STDOUT and STDERR open(PINGOUT, ">$dir/$host.html") || die "Couldn't open $dir/$ +host.html: $!"; $time = ctime(time()); print PINGOUT start_html(-BGCOLOR=>'lightblue', -TEXT=>'black', -title=>"Results of ping execution for + $host"), h1("Results for $host at $time"), p($desc); foreach (split(/\n/, $pingout)) { print PINGOUT $_ . br; } print PINGOUT end_html(); close(PINGOUT); $host = a({-href=>"$host.html"}, "$host"); if($pingout =~ /unknown host/) { # This never shows when an IP + is not resolved push(@rows, td([$host, $desc, "<FONT COLOR='brown'>Unresol +ved IP</FONT>"])); } elsif($pingout =~ /100% packet loss/) { push(@rows, td([$host, $desc, "<FONT COLOR='red'>Down</FON +T>"])); } else { push(@rows, td([$host, $desc, "<FONT COLOR='green'>Running +</FONT>"])); } } $email = a({-href=>"mailto:waldo\@cyberspace.org"}, "waldo\@cyberspace +.org"); $time = ctime(time()); print HTMLOUT table({-border=>undef}, caption("Status check as of $tim +e"), Tr(\@rows)); print HTMLOUT h5("Generated by linkstat.pl, coded by Will Stockwell($e +mail)"); print HTMLOUT end_html(); close(HTMLOUT);

In reply to Network Link Status Report Generator by Big Willy

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (10)
    As of 2014-11-28 11:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (196 votes), past polls