#!/bin/sh # # # Author: Bernhard Kuehl # Universitaet Osnabrueck # Mon Jun 23 12:34:36 MET DST 1997 # File: xntpdiff2 # Description: # PATH=/usr/local/gnu/bin:/usr/bin:/bin:.:/usr/local/bin export PATH usage () { echo `basename $0` '[applied|lehre|praxis]' 1>&2 exit 1 } fatal () { echo ${1+"$@"} >&2 exit 1 } { [ $# != 1 ] && usage #for i in isolde artemis tristan merlin bobby min artos portos for i in `getHosts "$1"` do echo processing $i >&2 echo processing $i xntpdc -p $i 2>&1 echo '=======================================================================' done } | sed 's/[ ][ ]*/:/g' | gawk -F':' ' function insertHost(maxHost, max, host, offset) { for(i=0;i<5;i++) if(offset*offset>max[i]*max[i]) break; if(i<5) { for(j=3;j>=i;j--) { max[j+1]=max[j] maxHost[j+1]=maxHost[j] } max[i]=offset maxHost[i]=host } } BEGIN { for(i=0;i<5;i++0) maxHost[i]="" max[i]=0 } /^processing/ { errorHost=0 host=$2 next } $2=="remote" { getline # ============ weglesen offset=0 while(getline>0) { if( $0 ~ /^========/) break if($7*$7>offset*offset) offset=$7 } insertHost(maxHost, max, host, offset) next } { # alles andere sind Probleme (Rechner steht, kein xntpd ist aktiv, ...) if(errorHost==0) { print host,"hat Probleme" | "cat 1>&2" errorHost=1 } } END { if(NR==0) exit 1 # richtigen Exit-Code setzen close("cat 1>&2") # Pipe schliessen for(i=0;i<5;i++) if(maxHost[i] != "") print maxHost[i],"hat einen Abstand von", max[i],"Sekunden" } ' exit 0