Index: /palm/trunk/SCRIPTS/hlrn_watchdog
===================================================================
--- /palm/trunk/SCRIPTS/hlrn_watchdog	(revision 1029)
+++ /palm/trunk/SCRIPTS/hlrn_watchdog	(revision 1029)
@@ -0,0 +1,159 @@
+#!/bin/ksh
+#------------------------------------------------------------------------------!
+# Current revisions:
+# -----------------
+# Initial revision
+#
+# Former revisions:
+# -----------------
+# $Id$
+#
+#
+# Description:
+# ------------
+# The hlrn_watchdog works for jobs on HLRN in Hannover/Berlin and with KDE.
+# It can be used for monitoring currently submitted jobs and will display
+# Running, Idle and Blocked jobs in a separate window, which is updated every
+# 10 minutes. 
+# Starting: "hlrn_watchdog start <your hlrn username>"
+# Stopping: "hlrn_watchdog stop"
+#------------------------------------------------------------------------------!
+
+    cd $PALM_BIN
+
+    gate_h="hicegate.hlrn.de"
+    gate_b="bicegate.hlrn.de"
+    update_frequency=600
+
+#   trap strg+c
+    trap 'killall kdialog; exit' 2
+
+
+#   start/stop routine
+    if [[ $1 == "stop" ]]
+    then
+       result=`ps aux|grep -c "./hlrn_watchdog"`
+       if (( $result > 2 ))
+       then
+          result=`ps aux|grep -m1 "./hlrn_watchdog"`
+          killid=`echo $result | tr -s " " | cut -d" " -s -f2`
+          kill -9 $killid > /dev/null
+          killall kdialog
+          echo "*** hlrn_watchdog stopped."
+       else
+          echo "+++ hlrn_watchdog is not running."
+       fi
+       exit
+    elif [[ $1 == "start" ]]
+    then
+        result=`ps aux|grep -c "hlrn_watchdog"`
+        if (( $result > 2 ))
+        then
+           echo "+++ hlrn_watchdog is already running."
+        else
+           nohup ./hlrn_watchdog $2 1> /dev/null 2> /dev/null &
+           echo "\n*** hlrn_watchdog starting..."
+        fi
+        exit
+    else
+
+#      login via ssh and collect information in .watchdog_report.x
+       while true
+       do
+          ssh  $gate_h -l $1 "showq | egrep \"($1)\"" > .watchdog_report.x
+          ssh  $gate_b -l $1 "showq | egrep \"($1)\"" >> .watchdog_report.x
+
+          i=0
+          j=0
+          cat .watchdog_report.x|while read variable
+          do
+#            analyze output
+             comid[$i]=`echo $variable | tr -s " " | cut -d" " -s -f1`
+             jobid[$i]=`echo ${comid[$i]} | tr -s " " | cut -d"." -s -f2`
+             complex[$i]=`echo ${comid[$i]} | tr -s " " | cut -d"." -s -f1`
+             username[$i]=`echo $variable | tr -s " " | cut -d" " -s -f2`
+             status[$i]=`echo $variable | tr -s " " | cut -d" " -s -f3`
+             nodes[$i]=`echo $variable | tr -s " " | cut -d" " -s -f4`
+             walltime[$i]=`echo $variable | tr -s " " | cut -d" " -s -f5`  
+             day[$i]=`echo $variable | tr -s " " | cut -d" " -s -f6`   
+             month[$i]=`echo $variable | tr -s " " | cut -d" " -s -f7`   
+             date[$i]=`echo $variable | tr -s " " | cut -d" " -s -f8`
+             subtime[$i]=`echo $variable | tr -s " " | cut -d" " -s -f9`   
+             ((i = i + 1))
+          done
+          rm .watchdog_report.x
+
+#         check for terminated jobs and status changes
+          k=0
+          cat .watchdog_status.x|while read variable
+          do
+#            analyze output
+             old_comid[$k]=`echo $variable | tr -s " " | cut -d" " -s -f1`
+             old_status[$k]=`echo $variable | tr -s " " | cut -d" " -s -f2` 
+             ((k = k + 1))
+          done
+          rm .watchdog_status.x
+
+          info=""
+          for ((m=0;m<$k;m++))
+          do
+             found=0
+             for ((n=0;n<$i;n++))
+             do        
+                if [[ ${old_comid[$m]} == ${comid[$n]} ]]
+                then
+                   if [[ ${old_status[$m]} != ${status[$n]} ]]
+                   then
+                       info="$info ${old_comid[$m]} has changed status from ${old_status[$m]} to ${status[$n]}.\n"
+                   fi
+                   found=1
+                   break
+                fi
+             done
+             if (( $found == 0 ))
+             then
+                info="$info ${old_comid[$m]} has been terminated (Status was ${old_status[$m]}).\n"
+             fi
+          done
+
+#         get estimated starting time for all idle jobs and write watchdog output in .watchdog_report.x
+          while (( $j < $i ))
+          do
+             if [[ ${status[$j]} == "Idle" ]]
+             then
+                if [[ ${complex[$j]} == "hannover" ]]
+                then
+                   eststart[$j]=`ssh $gate_h -l $1 "showstart ${comid[$j]}|grep \"based start in\""`
+                else
+                   eststart[$j]=`ssh $gate_b -l $1 "showstart ${comid[$j]}|grep \"based start in\""`
+                fi
+                eststart[$j]="Start in: "`echo ${eststart[$j]} | tr -s " " | cut -d" " -s -f6`   
+             else
+                eststart[$j]=""
+             fi
+
+#            write final output line
+             ((k = j + 1))
+             printf "%-9s%8s%3s%04i%13s%11s%2s%-s%3s%-20s\n" "Job: $k:" "${status[$j]}" " @ " "${nodes[$j]}" " nodes, time:" "${walltime[$j]}" " (" "${comid[$j]}" "). " "${eststart[$j]}" >> .watchdog_report.x
+             printf "${comid[$j]} ${status[$j]}\n" >> .watchdog_status.x
+             ((j = j + 1))
+          done
+
+#         kill all windows
+          killall kdialog
+
+          timestamp=`date`
+
+#         create window and show information
+          kdialog --textbox .watchdog_report.x 550 150 --title "HLRN watchdog  (last update: $timestamp)" &
+
+#         in case of status changes and terminated jobs, inform the user
+          if [[ $info != "" ]]
+          then
+             kdialog --msgbox "$info" --title "HLRN Job Information" &
+          fi
+
+          sleep $update_frequency
+       done
+
+    fi
Index: /palm/trunk/SCRIPTS/hlrn_watchdog.kwinrule
===================================================================
--- /palm/trunk/SCRIPTS/hlrn_watchdog.kwinrule	(revision 1029)
+++ /palm/trunk/SCRIPTS/hlrn_watchdog.kwinrule	(revision 1029)
@@ -0,0 +1,18 @@
+[HLRN watchdog rule]
+Description=HLRN watchdog rule
+desktop=-1
+desktoprule=4
+position=
+positionrule=4
+skippager=true
+skippagerrule=3
+skipswitcher=true
+skipswitcherrule=3
+skiptaskbar=true
+skiptaskbarrule=3
+title=HLRN watchdog
+titlematch=2
+types=32
+wmclass=kdialog
+wmclasscomplete=false
+wmclassmatch=1
