File chrony-graph.patch of Package chrony-graph

--- /dev/null
+++ b/bin/copy-to-website
@@ -0,0 +1,24 @@
+#!/bin/bash
+test -z "${OUTPUT_DIR}" && exit 1
+test -d "${OUTPUT_DIR}" || exit 1
+files=(
+`
+sed -n '
+/img src=/{
+s@^.*img src="@@
+s@".*$@@
+p
+}
+/a href=.*\.png/{
+s@^.*a href="@@
+s@".*$@@
+p
+}
+' index.html
+`
+index.html
+)
+for i in ${files[@]}
+do
+	mv -t "${OUTPUT_DIR}" "$i"
+done
--- a/bin/foreach-stat
+++ b/bin/foreach-stat
@@ -11,7 +11,7 @@ for stat in statistics.*; do
   date=`tail -1 $stat | cut -d" " -f1`
   echo $date $stat
 done | grep -v NMEA | sort -n | while read date file; do
-  title=`grep "^$file " ../titles 2> /dev/null | cut -d" " -f2`
+  title=`grep "^$file " "${TITLES}" 2> /dev/null | cut -d" " -f2`
   if [ -z "$title" ]; then
     title=${file#statistics.}
   fi
--- a/bin/index
+++ b/bin/index
@@ -3,6 +3,9 @@
 use strict;
 use Cwd;
 use File::Basename;
+use Sys::Hostname;
+
+my $HOST = hostname;
 
 my $RUN=cwd();
 $RUN = basename($RUN);
@@ -10,14 +13,12 @@ $RUN = basename($RUN);
 open(NOTES,"<","notes");
 my $NOTES=join("",<NOTES>);
 close(NOTES);
-$NOTES =~ s/</&lt;/g;
-$NOTES =~ s/>/&gt;/g;
-$NOTES =~ s/&/&amp;/g;
 
 my $time = scalar(gmtime());
 
 open(TMPL,"<","index.html.tmpl");
 while(<TMPL>) {
+  s/__HOST__/$HOST/g;
   s/__RUN__/$RUN/g;
   s/__NOTES__/$NOTES/g;
   s/__TIME__/$time/g;
--- a/bin/local-clock-graph
+++ b/bin/local-clock-graph
@@ -1,10 +1,13 @@
 #!/bin/sh
 
+lc() {
+	local sz=$1
+	local png=$2
 gnuplot <<EOF
-set terminal png size 900,600
+set terminal png size ${sz}
 set xdata time
 set timefmt "%s"
-set output "local-clock.png"
+set output "${png}"
 set grid
 set xlabel "Time"
 set format x "%d-%H:%M"
@@ -19,6 +22,9 @@ plot \
  "tracking.log" using 1:(\$6*1000000) title "offset" with linespoints, \
  "tracking.log" using 1:4 title "local clock error" with linespoints axis x1y2
 EOF
+}
+lc '900,600' 'local-clock.png'
+lc '12345,800' 'l.local-clock.png'
 
 NINETYFIVE=`../bin/percentile 8 95 tracking.log | ../bin/mul 1000000`
 NINETYNINE=`../bin/percentile 8 99 tracking.log | ../bin/mul 1000000`
@@ -34,6 +40,7 @@ set output "local-clock-stddev.png"
 set grid
 set xlabel "Time"
 set format x "%d-%H:%M"
+set logscale y
 set xtic rotate by -45 scale 0
 set ytics format "%1.2f us" nomirror
 set title "local clock stddev"
@@ -54,6 +61,9 @@ plot \
  $ONE title "1st percentile"
 EOF
 
+lc_skew() {
+	local sz=$1
+	local png=$2
 NINETYFIVE=`../bin/percentile 4 95 tracking.log`
 NINETYNINE=`../bin/percentile 4 99 tracking.log`
 FIVE=`../bin/percentile 4 5 tracking.log`
@@ -61,10 +71,10 @@ ONE=`../bin/percentile 4 1 tracking.log`
 NF_M_F=`echo $NINETYFIVE - $FIVE | bc`
 NN_M_O=`echo $NINETYNINE - $ONE | bc`
 gnuplot <<EOF
-set terminal png size 900,600
+set terminal png size ${sz}
 set xdata time
 set timefmt "%s"
-set output "local-clock-skew.png"
+set output "${png}"
 set grid
 set xlabel "Time"
 set format x "%d-%H:%M"
@@ -87,3 +97,6 @@ plot \
  $FIVE title "5th percentile", \
  $ONE title "1st percentile"
 EOF
+}
+lc_skew '900,600' 'local-clock-skew.png'
+lc_skew '12345,800' 'l.local-clock-skew.png'
--- a/bin/offset-graph
+++ b/bin/offset-graph
@@ -6,8 +6,8 @@
 echo 
 ) | gnuplot
 
-if [ -f ../titles ]; then
-  titles=$(cat ../titles)
+if [ -f "${TITLES}" ]; then
+  titles=$(cat "${TITLES}")
 else
   titles=$(
     for stat in statistics.*; do
--- a/bin/plot
+++ b/bin/plot
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-export GDFONTPATH=/usr/share/fonts/liberation
+export GDFONTPATH=/usr/share/fonts/truetype
 export GNUPLOT_DEFAULT_GDFONT=LiberationSans-Regular
 
 ../bin/local-clock-graph
@@ -159,5 +159,3 @@ EOF
 if [ -x custom-plot ]; then
   ./custom-plot
 fi
-
-../bin/copy-to-website
--- a/bin/run
+++ b/bin/run
@@ -1,14 +1,13 @@
 #!/bin/sh
 
+declare -i LOGDAYS=7
 if [ -x startime ]; then
   STARTIME=`./startime`
 else
   NOW=`date +%s`
-  # 604800 seconds = 7 days
-  STARTIME=`expr $NOW - 604800`
+  STARTIME=`expr $NOW - $(( 60 * 60 * 24 * ${LOGDAYS} ))`
 fi
 
-LOGDAYS=7
 if [ -n "$CHRONY_LOGDIR" ]; then
   LOGDIR=$CHRONY_LOGDIR
 else
@@ -29,26 +28,21 @@ function limit_time {
 function cat_logfiles {
   file_pattern="$1"
 
-  find $LOGDIR -name "$file_pattern" \! -name \*.gz -mtime -$LOGDAYS | xargs -r cat 
-# un-comment this next line if you compress your logs
-# find $LOGDIR -name "$file_pattern".gz -mtime -$LOGDAYS | xargs -r zcat
+  find $LOGDIR -name "$file_pattern" \! -name \*.?z -mtime -$LOGDAYS -exec cat '{}' +
+  find $LOGDIR -name "$file_pattern".xz -mtime -$LOGDAYS -exec xzcat '{}' +
 }
 
 rm -f statistics*
-echo statistics.log `date`
 # split the statistics logs based on the source IP
 cat_logfiles statistics.log\* | ../bin/timestamps | limit_time | sort -n | ../bin/split statistics ../aliases
 
 rm -f measurements.*
-echo measurements.log `date`
 # measurements logs - also split based on source IP
 cat_logfiles measurements.log\* | ../bin/timestamps | limit_time | sort -n | ../bin/split measurements ../aliases
 
-echo tracking.log `date`
 # local clock info goes in one logfile
 cat_logfiles tracking.log\* | ../bin/timestamps | limit_time | sort -n >tracking.log
 
-echo done `date`
 
 # optional GPS log processing
 if [ -f log/gps-lock ]; then
@@ -68,3 +62,20 @@ fi
 ../bin/index >index.html
 
 ../bin/plot
+
+> .tmp
+for i in `ls -1d remote-statistics.*.png | sort -V`
+do
+   SERVER_NAME="${i%.png}"
+   SERVER_NAME="${SERVER_NAME#remote-statistics.}"
+   echo "<img src=\"${i}\" alt='Remote Clock: ${SERVER_NAME}'><br>" >> .tmp
+done
+sed -i '
+/remote-statistics.SET_IP_HERE.png/{
+s@^.*@@
+r .tmp
+}' index.html
+
+rm .tmp
+
+../bin/copy-to-website
--- a/bin/split
+++ b/bin/split
@@ -11,8 +11,8 @@ my(%aliases);
 if(-f $alias_file) {
   open(ALIAS,"<",$alias_file);
   while(<ALIAS>) {
-    if(/(\S+) (\S+)/) {
-      $aliases{$1} = $2;
+    if(/(\S+)(\s+)(\S+)/) {
+      $aliases{$1} = $3;
     }
   }
   close(ALIAS);
@@ -20,9 +20,14 @@ if(-f $alias_file) {
 
 while(<>) {
   if(/^(\d+) (\S+)/) {
+    my $key;
+    my $alias;
     my($host) = $2;
-    if(defined($aliases{$host})) {
-      $host = $aliases{$host};
+    foreach $key (keys %aliases) {
+      $alias = $aliases{$key};
+      if ($host =~ /${key}$/) {
+        $host = $alias
+      }
     }
     open(OUT,">>$filename.$host");
     print OUT $_;
--- a/runX/index.html.tmpl
+++ b/runX/index.html.tmpl
@@ -1,18 +1,22 @@
 <!DOCTYPE html>
 <html>
-<head><title>NTP Run __RUN__</title>
-<meta http-equiv="refresh" content="1800" />
+<head><title>NTP __HOST__ __RUN__</title>
+<meta http-equiv="refresh" content="3333" />
 <meta charset="utf-8" />
 </head>
 <body>
 <p>
-Last update - __TIME__ GMT
+Last update - __TIME__ UTC
 </p>
+<a href="l.local-clock.png" target="_blank">
 <img src="local-clock.png" alt="Local Clock: Frequency + Offset"><br>
+</a>
 <img src="percentiles.png" alt="Local Clock: Frequency detail"><br>
 <img src="percentiles-offset.png" alt="Local Clock: Offset detail"><br>
 <img src="offset-histogram.png" alt="Local Clock: Offset histogram"><br>
+<a href="l.local-clock-skew.png" target="_blank">
 <img src="local-clock-skew.png" alt="Local Clock: Skew"><br>
+</a>
 <img src="local-clock-stddev.png" alt="Local Clock: stddev"><br>
 <img src="all-diff-freq.png" alt="Remote Clocks: Frequency Difference"><br>
 <img src="all-offset.png" alt="Remote Clocks: Offsets"><br>
@@ -24,6 +28,6 @@ __NOTES__
 </pre>
 <p>
 Git repository for chrony-graph:
- <a href="https://github.com/ddrown/chrony-graph">https://github.com/ddrown/chrony-graph</a>
+ <a href="https://github.com/ddrown/chrony-graph" target="_blank">https://github.com/ddrown/chrony-graph</a>
 </p>
 </body></html>
openSUSE Build Service is sponsored by