Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w # coded by Will Stockwell( 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\"}, "waldo\@cyberspace"); $time = ctime(time()); print HTMLOUT table({-border=>undef}, caption("Status check as of $tim +e"), Tr(\@rows)); print HTMLOUT h5("Generated by, coded by Will Stockwell($e +mail)"); print HTMLOUT end_html(); close(HTMLOUT);

In reply to Network Link Status Report Generator by Big Willy

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (7)
    As of 2018-06-20 15:53 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.