#!/local/bin/perl

$qry = $ENV{'QUERY_STRING'};
$error = 0;

select(STDOUT); $| = 1;
print "Content-type: text/plain\n\n";

if ($qry) {
  ($var, $num) = split(/=/, $qry);
  if ($var eq 'srv') {
    if ($num =~ /^[0123]$/) {
      $name = "ntp$num.fau.de";
      print "Clock status of time server $name:\n\n";
      system("/local/NTP/bin/ntpq -c cl $name");
    } else {
      $error++;
    }
  } else {
    $error++;
  }
} else {
  $error++;
}

print "Nope.\n" if $error;
