]> Sergey Matveev's repositories - sgmon.git/commitdiff
Move failed probes to the beginning
authorSergey Matveev <stargrave@stargrave.org>
Tue, 29 Mar 2022 15:42:15 +0000 (18:42 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 29 Mar 2022 15:45:25 +0000 (18:45 +0300)
status.sh

index d3eec5b61b1f87e0f08202b02b8128e1666bc787..d0c724378f3216ae9ffc015a149507dd7f295e2f 100755 (executable)
--- a/status.sh
+++ b/status.sh
@@ -10,6 +10,9 @@ 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>
@@ -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>"