Search This Blog

Wednesday, February 7, 2007

Simple, but nice PerlEx report for WAN status

<%use CGI;
use Net::Ping;
my $cgi = new CGI;
#print "Content-type: text/html\n\n";
print "<html><head>\n";
print "<title>WAN health</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FFFFFF\"
vlink=\"#FFFFFF\">\n";
#print "WAN status...";
$p = Net::Ping->new(); %>
<TABLE border="1"><TR><TH>Site<TH>Status
<TR><TD>Bulgaria<TD><%
if ($p->ping("192.168.5.1")) { print "<a
href=\"WAN_detail.aspl\"><img src=\"images/ok.png\"></a>";}
else { print "<a href=\"WAN_detail.aspl\"><img
src=\"images/not_ok.png\"></a>";}%>
<TR><TD>Greece<TD><%
if ($p->ping("192.168.4.1")) { print "<a
href=\"WAN_detail.aspl\"><img src=\"images/ok.png\"></a>";}
else { print "<a href=\"WAN_detail.aspl\"><img
src=\"images/not_ok.png\"></a>";}%>
<TR><TD>Macedonia<TD><%
if ($p->ping("192.168.3.1")) { print "<a
href=\"WAN_detail.aspl\"><img src=\"images/ok.png\"></a>";}
else { print "<a href=\"WAN_detail.aspl\"><img
src=\"images/not_ok.png\"></a>";}%>
<TR><TD>Turkey<TD><%
if ($p->ping("192.168.2.6")) { print "<a
href=\"WAN_detail.aspl\"><img src=\"images/ok.png\"></a>";}
else { print "<a href=\"WAN_detail.aspl\"><img
src=\"images/not_ok.png\"></a>";}
$p->close();%>
</TABLE></body></html>

No comments: