#!/usr/bin/perl

#developed from original script by Andrew Stringer 09/10/2005 onwards.
#written 14/12/2005 to report ntp stratum for server
#run as ssi include

use warnings;

sub ntpstratum
{
my $result1= `ntptrace -n -r 1 -t 1 127.0.0.1`;
#split on , to seperate out stratum for 127.0.0.1
@result2=split(/,/,$result1);
#split on : to seperate out stratum fron 127 address
@result3=split(/:/,$result2[0]);

#return result, 2nd half of 127 address line
return $result3[1];
#end sub with curly brace
}


MAIN:
#start of body of program
{

#call ntpstratum sub
my $stratum=&ntpstratum;

print "Content-type: text/html\n\n";

print <<ENDOFTEXT2 ;
$stratum
ENDOFTEXT2
}
exit (0);
