a simple NTP server status web-page

A quick how-to create a simple NTP server status web-page.

I will be using apache to serve the status web-page, but any cgi capable web-server will do.

The NTP server status script.

#g0 2013  , http://ipduh.com/contact
#simple ntp server status web-page
#Prerequisites: ntpdate & ntptrace
use strict;
my $myNTPIP="";
my $myNTPDNS="ntp.ipduh.awmn";
my $ntptrace="/usr/bin/ntptrace";
my $ntpdate="/usr/sbin/ntpdate";
#configure END

my $epoch=time();
my @ntptrace=`$ntptrace $myNTPIP`;
my @date=`$ntpdate -q $myNTPIP`;
my @fields=();
my $liin;
my @ntptrace_out=();
foreach my $li(@ntptrace){
 $fields[0]="<a href=http://ipduh.com/apropos/?$fields[0]>$fields[0]</a>";

print <<"TOP";
Content-type: text/html \n\n
<!doctype html><html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name='description' content='$myNTPIP - $myNTPDNS NTP server status web-page' /> 
p { padding-left: 0px; font-family:  Fixed, monospace; font-weight: 1em; }
.little { padding-left: 0px; font-family:  monospace; font-weight: .4em; }
.board { position:absolute; top:100px; left:100px; }
a.goto:link { color:#000000; text-decoration:underline; }
a.goto:visited { color:#000000; text-decoration:underline; }
a.goto:hover {color:#000000;text-decoration:none;background:yellow;}
a.goto:active {color:#00FF00;text-decoration:none;background:yellow;
<div class=board>
print "<p> $myNTPIP - $myNTPDNS </p><pre> @date <br /> @ntptrace_out </pre>";
print <<'BOT';
|__________   ________________________________________________________________________|
           \ |
        |   /\________/\   |
        |  /____    ____\  |
        |_/     \__/     \_|
        [_       __       _]
          \_____/  \_____/
           \    ____    / 
            |   \__/   |   
          _  \________/  _
          \\  /|    |\  //

print <<"TOEND";
<center><p class=little> &copy; <a href=http://ipduh.com>ipduh</a> <a href="http://ipduh.com/epoch/?$epoch" class=goto>$epoch</a>
</p></center><br /><br /><br /><br /></div></body></html>


A sample apache2 virtual host configuration.

        DocumentRoot "/var/www/ntp.ipduh.awmn/www/"
        ServerName  ntp.ipduh.awmn
        ScriptAlias /cgi-bin2/ "/var/www/ntp.ipduh.awmn/www/"
        AddHandler cgi-script .pl

<Directory "/var/www/ntp.ipduh.awmn/www">
        AllowOverride None
        Options       ExecCGI
        Order         allow,deny
        Allow         from all
        DirectoryIndex index.pl index.html index.htm

ErrorLog  "|/usr/sbin/rotatelogs /var/www/ntp.ipduh.awmn/logs/error/ntp.ipduh.awmn-error_log.%Y%m%d 86400"
CustomLog "|/usr/sbin/rotatelogs /var/www/ntp.ipduh.awmn/logs/access/ntp.ipduh.awmn-access_log.%Y%m%d 86400" combined

To install the ntp-status-page put the ntp-status script to a cgi directory. You can get the ntp-status script from http://kod.ipduh.com/lib/ntp-status-web.pl
If you are planning on using an apache2 virtual host similar to the one above just for this you could do the following.
$ cd /path/to/vhost-web-root
$ wget http://kod.ipduh.com/lib/ntp-status-web.pl
$ mv ntp-status-web.pl index.pl
$ chmod 755 index.pl

A simple NTP status web-page script