]> Sergey Matveev's repositories - sgmon.git/blobdiff - status.sh
Cycle through all addresses
[sgmon.git] / status.sh
index d3eec5b61b1f87e0f08202b02b8128e1666bc787..e9a37e744505d0460e1f0422648a71aaaefeaa67 100755 (executable)
--- a/status.sh
+++ b/status.sh
@@ -10,11 +10,14 @@ catfiles() {
 SGMONDIR="$(dirname "$(realpath -- "$0")")"
 . "$SGMONDIR"/rc
 probes="$("$SGMONDIR"/probelist.sh)"
+gut=`mktemp`
+bad=`mktemp`
+trap "rm -fr $gut $bad" HUP PIPE INT QUIT TERM EXIT
 cat <<EOF
 <!DOCTYPE html>
 <html><head><title>sgmon status $(date -Iseconds)</title></head><body>
 <table border=1>
-<tr><th>Status</th><th>probe</th><th>Last</th><th>Message</th></tr>
+<tr><th>Status</th><th>Probe</th><th>Last</th><th>Message</th></tr>
 EOF
 for probe in $probes ; do
     if [ -s $probe/state/attempts ] ; then
@@ -24,6 +27,7 @@ for probe in $probes ; do
         [ "$attempts" -lt "$max_attempts" ] &&
             status="<b>Prefail</b>" || status="<b>FAIL</b>"
         status="$status (${attempts}/${max_attempts})"
+        list=$bad
     else
         if [ -r $probe/state/ok ] ; then
             mtime=$(stat -t "%F %T" -f %Sm $probe/state/ok)
@@ -32,8 +36,9 @@ for probe in $probes ; do
             mtime=
             status="???"
         fi
+        list=$gut
     fi
-    cat <<EOF
+    cat >>$list <<EOF
 <tr>
     <td>$status</td>
     <td><tt><a name="$probe">$probe</a></tt></td>
@@ -42,4 +47,5 @@ for probe in $probes ; do
 </tr>
 EOF
 done
+cat $bad $gut
 echo "</table></body></html>"