Index: /trunk/tools/eam/neb-apache-check.20241219/check.apache.connections.sh
===================================================================
--- /trunk/tools/eam/neb-apache-check.20241219/check.apache.connections.sh	(revision 42767)
+++ /trunk/tools/eam/neb-apache-check.20241219/check.apache.connections.sh	(revision 42767)
@@ -0,0 +1,62 @@
+#!/bin/csh
+
+set tmpfile = `mktemp`
+
+### old, hard-wired servers
+# set names = (ippx089 ippx090 ippx093 ippx097 ippx099 ippx101)
+# set Nvals = (      0       0       0       0       0       0)
+
+### load Nebulous servers from common source
+source ~ippps1/ippconfig/nebservers.csh
+
+# echo $nebservers
+# echo $#nebservers
+
+set names = (`echo $nebservers | sed "s|http://||g" | sed "s|/nebulous||g"`)
+set Nvals = (`echo $nebservers | sed "s|http://||g" | sed "s|/nebulous||g"`)
+
+# echo $names
+# echo $Nvals
+
+# exit 2
+
+while (1)
+  (mysql -h ippdb11 -u ipp -pipp nebulous -e "show processlist" > $tmpfile) >& /dev/null
+
+  set i = 1
+  while ($i <= $#names)
+    set Nvals[$i] = `grep $names[$i] $tmpfile | wc -l`
+    @ i++
+  end
+
+  set now = `date +"%Y/%m/%d %H:%M:%S"`
+  echo "$now $Nvals"
+
+  set myWarning = ""
+  set myRestart = ""
+
+  set i = 1
+  while ($i <= $#names)
+    if ($Nvals[$i] < 32) then
+      set myWarning = "$myWarning $names[$i]"
+    endif
+
+    if ($Nvals[$i] < 5) then
+      set myRestart = "$myRestart $names[$i]"
+      ssh $names[$i] "sudo -A systemctl restart apache2.service"
+    endif
+    @ i++
+  end
+
+  if ("$myWarning" != "") then
+    echo "too few apache servers on $myWarning : $now $Nvals"
+    echo "too few apache servers on $myWarning : $now $Nvals" | mail -s "WARNING: nebulous apache servers" magnier@hawaii.edu
+  endif
+
+  if ("$myRestart" != "") then
+    echo "critically few apache servers, restarting on $myRestart"
+    echo "critically few apache servers, restarting on $myRestart" | mail -s "WARNING: nebulous apache servers" magnier@hawaii.edu
+  endif
+
+  sleep 300
+end
