Ignore:
Timestamp:
08/30/06 12:33:16 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/datacenter/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/jobmanager

    r7946 r7959  
    2929#
    3030
    31 
    3231source `dirname $0`/sourcefile
    3332printprocesslog "INFO starting $0"
     
    5453      dayofweek=`date +%u`
    5554      hour=`date +%k`
     55
    5656      source `dirname $0`/sourcefile
    5757      echo "script: ${scripts[$i]}" >> $jmscriptlog 2>&1
    5858#      echo " day: $dayofweek hour: $hour" >> $jmscriptlog 2>&1
    59       queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
    60       queued=`setzero $queued`
     59
     60      queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user` && ! [ $queued -eq 0 ]
     61      if [ "$queued" = "" ]
     62      then
     63         printprocesslog "WARN condor_q failed"
     64         echo `date`"ERROR condor_q failed" >> $jmerrorlog
     65         cont >> $jmscriptlog 2>&1
     66      fi
    6167      queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
    62       queuedscript=`setzero $queuedscript`
     68      if [ "$queuedscript" = "" ]
     69      then
     70         printprocesslog "WARN condor_q failed"
     71         echo `date`"ERROR condor_q failed" >> $jmerrorlog
     72         cont >> $jmscriptlog 2>&1
     73      fi
    6374      runningscript=`/usr/local/bin/condor_q -global | grep $user | grep ' R ' | grep -c ${scripts[$i]}`
    64       runningscript=`setzero $runningscript`
     75      if [ "$runningscript" = "" ]
     76      then
     77         printprocesslog "WARN condor_q failed"
     78         echo `date`"ERROR condor_q failed" >> $jmerrorlog
     79         cont >> $jmscriptlog 2>&1
     80      fi
    6581      stillinqueue=`echo $queuedscript - $runningscript | bc `
    6682
     
    85101      then
    86102         cont >> $jmscriptlog 2>&1
    87       else
    88          if [ "$queuedscript" -gt "$pnoscript" ]
    89          then
    90             cont >> $jmscriptlog 2>&1
    91          fi
     103      fi
     104      if [ "$queuedscript" -gt "$pnoscript" ]
     105      then
     106         cont >> $jmscriptlog 2>&1
    92107      fi
    93108
     
    111126      if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date -a dir=$runlogpath $scriptspath/run.condor 2>> $jmerrorlog
    112127      then
    113          date >> $jmerrorlog
    114          nail -s 'condor problem'  $erradrs < $jmerrorlog
     128         echo `date`"ERROR condor_submit failed" >> $jmerrorlog
    115129         echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
    116          printprocesslog "ERROR submitting ${scripts[$i]} to condor failed"
     130         printprocesslog "WARN submitting ${scripts[$i]} to condor failed"
    117131         sleep $errorsleeptime
    118132      fi
  • trunk/MagicSoft/Mars/datacenter/scripts/sourcefile

    r7954 r7959  
    3939webpath=/www/htdocs/datacenter
    4040
     41datetime=`date +%F-%H-%M-%S`
     42
     43
     44# function to make sure that a directory is made
     45function makedir()
     46{
     47   if [ ! -d $@ ]
     48   then
     49     mkdir -pv $@
     50     if [ ! -d $@ ]
     51     then
     52        echo "could not make dir "$@
     53        finish
     54     fi
     55   fi
     56}
     57
     58# logging paths for runlogs and processlog
    4159runlogpath=$logpath/run/`date +%Y/%m/%d`
    4260processlogpath=$logpath/processlog
    43 
    44 datetime=`date +%F-%H-%M-%S`
    45 
     61makedir $runlogpath
     62makedir $processlogpath
     63processlog=$processlogpath/process`date +%F`.log
     64
     65
     66# set checkvalue to ok at the beginning of the scripts
    4667check="ok"
    4768
     
    7394Ffillganymed=21
    7495
    75 #
    76 # setup for jobmanager
    77 #
    78 #log files (can't be defined in script itself, as script can run longer
    79 #than one day
     96
     97# setup for jobmanager:
     98#   log files (can't be defined in script itself, as script can run longer
     99#   than one day
    80100jmerrorlog=$runlogpath/jobmanager-error`date +%F`.log
    81101jmscriptlog=$runlogpath/jobmanager`date +%F`.log
     
    90110stillinqueue=0
    91111
    92 function setzero()
    93 {
    94    val=$@
    95    if [ "$val" == "" ]
    96    then
    97       test=`condor_q -global`
    98       if [ "$test" == "" ]
    99       then
    100          echo $max
    101       else
    102          echo 0
    103       fi
    104    else
    105       echo $val
    106    fi
    107 }
    108 
    109 
    110112
    111113# alias
    112114alias 'intgrep'='grep -E ^\\\(int\\\)[0-9]+$ | sed -e s\/\(int\)\/\/'
    113115
    114 # in the following the function, which are needed by several scripts, are
     116# in the following the functions, which are needed by several scripts, are
    115117# defined
    116 
    117 # function to make sure that a directory is made
    118 function makedir()
    119 {
    120    if [ ! -d $@ ]
    121    then
    122      mkdir -pv $@
    123      if [ ! -d $@ ]
    124      then
    125         echo "could not make dir "$@
    126         finish
    127      fi
    128    fi
    129 }
    130 makedir $runlogpath
    131 makedir $processlogpath
    132 processlog=$processlogpath/process`date +%F`.log
    133118
    134119function printprocesslog
     
    137122   echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] "$@ >> $processlog
    138123}
    139    
     124
    140125# function to exit a script properly
    141126function finish()
     
    143128   rm -v $todofile
    144129   rm -v $lockfile
    145    date 
     130   date
    146131   printprocesslog "INFO finished $program"
    147132   exit
     
    158143# function to check if a process is already locked
    159144function checklock()
    160 { 
     145{
    161146   date > $lockfile
    162147   checklock0=$?
    163    case $checklock0 in 
     148   case $checklock0 in
    164149       0)   echo " checklock0=$checklock0 -> continue " ;;
    165150       1)   echo " checklock0=$checklock0 -> file $lockfile exists -> exit"
    166             date 
     151            date
    167152            exit;;
    168153       *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
     
    176161   year=`date +%Y`
    177162   date=NULL
    178    
     163
    179164   getstatuslogpath=$logpath/getstatus/$program/$year
    180165   getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
     
    219204function evalstatus()
    220205{
    221    case $@ in 
     206   case $@ in
    222207      start)   echo "setstatus start"
    223208               starttime="Now()"
     
    235220                      failedcode=$com
    236221                      if ! [ "$comadd" = "" ]
    237                       then 
     222                      then
    238223                         failedcodeadd=$comadd
    239224                      fi
     
    258243
    259244#   printstatusvalues
    260    # set status 
     245   # set status
    261246   setstatuslogpath=$logpath/setstatus/$program/$var1
    262247   makedir $setstatuslogpath
     
    298283{
    299284   echo "getting todolist..."
    300    getdbsetup 
     285   getdbsetup
    301286   getstepinfo
    302287   # get query
    303288   query=" select $primary from $table where "
    304    if ! echo $needs | grep '#' > /dev/null 
    305    then 
     289   if ! echo $needs | grep '#' > /dev/null
     290   then
    306291      for need in $needs
    307292      do
     
    322307   if [ "$process" = "" ]
    323308   then
    324       echo "  => nothing to do" 
    325       finish
    326    else 
     309      echo "  => nothing to do"
     310      finish
     311   else
    327312      todofile=$listpath/ToDo-$table-$column.txt
    328      
     313
    329314      if ls $todofile > /dev/null 2>&1
    330315      then
     
    343328   process=
    344329   echo "getting todo..."
    345    getdbsetup 
     330   getdbsetup
    346331   getstepinfo
    347332   # get query
    348333   query=" select $primary from $table where "
    349    if ! echo $needs | grep '#' > /dev/null 
    350    then 
     334   if ! echo $needs | grep '#' > /dev/null
     335   then
    351336      for need in $needs
    352337      do
     
    368353   if [ "$process" = "" ]
    369354   then
    370       echo "  => nothing to do -> exit" 
     355      echo "  => nothing to do -> exit"
    371356      finish
    372357   fi
     
    378363   numproc=
    379364#   echo "getting status..."
    380    getdbsetup 
     365   getdbsetup
    381366   column=${scriptscolname[$i]}
    382367   getstepinfo
    383368   # get query
    384369   query=" select count(*) from $table where "
    385    if ! echo $needs | grep '#' > /dev/null 
    386    then 
     370   if ! echo $needs | grep '#' > /dev/null
     371   then
    387372      for need in $needs
    388373      do
     
    394379   query=$query" group by $column "
    395380#   echo " QUERY: "$query
     381   numproc=0
    396382   if ! numproc=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "`
    397383   then
     
    407393   resetstatusvalues
    408394   evalstatus $@
    409    getdbsetup 
     395   getdbsetup
    410396   getstepinfo
    411397   # get query
     
    413399   if [ "$reset" = "no" ]
    414400   then
    415       echo "YOU CAN'T RESET $column for $var2!!!" 
     401      echo "YOU CAN'T RESET $column for $var2!!!"
    416402      printprocesslog "ERROR you can't reset $column for $var2"
    417403      finish
    418404   fi
    419405   query=" update $table set $column=$statustime"
    420    if ! echo $influences | grep '#' > /dev/null 
    421    then 
     406   if ! echo $influences | grep '#' > /dev/null
     407   then
    422408      for influence in $influences
    423       do 
     409      do
    424410         query=$query", $influence=NULL"
    425411      done
    426412   fi
    427413   if ! [ "$starttime" = "noreset" ]
    428    then 
     414   then
    429415      query=$query", fStartTime=$starttime"
    430416   fi
     
    433419   echo " QUERY: "$query
    434420   if ! mysql -s -u $us --password=$pw --host=hercules $db -e " $query "
    435    then 
     421   then
    436422      echo "ERROR could not insert status into db -> exit"
    437423      printprocesslog "ERROR could not set status in db (program: $program, function setstatus)"
     
    440426
    441427}
     428
Note: See TracChangeset for help on using the changeset viewer.