diff --git a/condor_pool_statistics.sh b/condor_pool_statistics.sh index 2ed422c..fa925f6 100755 --- a/condor_pool_statistics.sh +++ b/condor_pool_statistics.sh @@ -9,8 +9,9 @@ fi export TMPDIR=$glideinWMSMonitor_OUTPUT_DIR/tmp_$$ mkdir $TMPDIR +OUTFILE=$1 -echo "{" +echo "{" > $OUTFILE pool_table() { # Collector1 has the negotiator, Collector2 is the HA backup. @@ -19,10 +20,17 @@ pool_table() { shift; shift NAME=$@ NOW=`/bin/date -u` + negotime=`condor_status -pool $COLLECTOR1 -nego -l | grep LastNegotiationCycleDuration0 | awk '{print int($3)}'` total1=`condor_status -schedd -total -pool $COLLECTOR1 | tail -1 | awk '{print int($2)}'` total2=`condor_status -schedd -total -pool $COLLECTOR2 | tail -1 | awk '{print int($2)}'` colldiff=`echo $total1 $total2 | awk '{print int($1-$2)}'` + + if [ -z $negotime ] ; then negotime=null ; fi + if [ -z $total1 ] ; then total1=null ; fi + if [ -z $total2 ] ; then total2=null ; fi + if [ -z $colldiff ] ; then colldiff=null ; fi + cat <>$OUTFILE +pool_table vocms097.cern.ch vocms099.cern.ch "Global" >>$OUTFILE +pool_table vocms97.cern.ch cmssrv119.fnal.gov "Production" >>$OUTFILE -cat <>$OUTFILE "Site Table": { "header": [ "Site","Maintenance", @@ -60,9 +74,9 @@ cat <=T1, then it is 5% of total pledge + totalpledge=` grep ^$site\, $PLEDGES | tail -1 | awk -F\, '{print int($2)}'` validityofpledge=`grep ^$site\, $PLEDGES | tail -1 | awk -F\, '{print $3}'` - totalpledge=`grep ^$site\, $PLEDGES | tail -1 | awk -F\, '{print int($2)}'` + if [ -z $totalpledge ] ; then totalpledge=null ; fi + if [ -z "$validityofpledge" ] ; then validityofpledge=null ; fi + if [ $totalpledge -eq 0 ] ; then totalpledge=null ; fi + echo $site | egrep '^T0|^T1' >> /dev/null if [ $? -eq 0 ] ; then - analysispledge=`echo $totalpledge 0 | awk '{print int($1/10.)}'` + analysispledge=`echo $totalpledge | awk '{print int($1/10.)}'` else - analysispledge=`echo $totalpledge 0 | awk '{print int($1/2.0)}'` + analysispledge=`echo $totalpledge | awk '{print int($1/2.0)}'` fi + if [ -z $analysispledge ] ; then analysispledge=null ; fi + if [ $analysispledge -eq 0 ] ; then analysispledge=null ; fi avgusageana=`grep ^$site\, $USAGEANA | awk -F\, '{print int($2)}'` maxusageana=`grep ^$site\, $USAGEANA | awk -F\, '{print int($3)}'` - avgusagetst=`grep ^$site\, $USAGETST | awk -F\, '{print int($2)}'` maxusagetst=`grep ^$site\, $USAGETST | awk -F\, '{print int($3)}'` - avgusagepro=`grep ^$site\, $USAGEPRO | awk -F\, '{print int($2)}'` maxusagepro=`grep ^$site\, $USAGEPRO | awk -F\, '{print int($3)}'` - avgusageall=`grep ^$site\, $USAGEALL | awk -F\, '{print int($2)}'` maxusageall=`grep ^$site\, $USAGEALL | awk -F\, '{print int($3)}'` + if [ -z $avgusageana ] ; then avgusageana=null ; fi + if [ -z $maxusageana ] ; then maxusageana=null ; fi + if [ -z $avgusagetst ] ; then avgusagetst=null ; fi + if [ -z $maxusagetst ] ; then maxusagetst=null ; fi + if [ -z $avgusagepro ] ; then avgusagepro=null ; fi + if [ -z $maxusagepro ] ; then maxusagepro=null ; fi + if [ -z $avgusageall ] ; then avgusageall=null ; fi + if [ -z $maxusageall ] ; then maxusageall=null ; fi + claimedana=` grep \{$site\} $CLAIMEDANA | awk '{print int($1)}'` runningana=` grep \{$site\} $RUNNINGANA | awk '{print int($1)}'` pressureana=`grep $site $DESIREDANA | wc -l` exclusivepressureana=`grep $site $DESIREDANA | awk -v site=$site '$1==site{print $0}' | wc -l` + if [ -z $claimedana ] ; then claimedana=null ; fi + if [ -z $runningana ] ; then runningana=null ; fi + if [ -z $pressureana ] ; then pressureana=null ; fi + if [ -z $exclusivepressureana ] ; then exclusivepressureana=null ; fi + claimedglo=` grep \{$site\} $CLAIMEDGLO | awk '{print int($1)}'` runningglo=` grep \{$site\} $RUNNINGGLO | awk '{print int($1)}'` pressureglo=`grep $site $DESIREDGLO | wc -l` exclusivepressureglo=`grep $site $DESIREDGLO | awk -v site=$site '$1==site{print $0}' | wc -l` + if [ -z $claimedglo ] ; then claimedglo=null ; fi + if [ -z $runningglo ] ; then runningglo=null ; fi + if [ -z $pressureglo ] ; then pressureglo=null ; fi + if [ -z $exclusivepressureglo ] ; then exclusivepressureglo=null ; fi + claimedpro=` grep \{$site\} $CLAIMEDPRO | awk '{print int($1)}'` runningpro=` grep \{$site\} $RUNNINGPRO | awk '{print int($1)}'` pressurepro=`grep $site $DESIREDPRO | wc -l` exclusivepressurepro=`grep $site $DESIREDPRO | awk -v site=$site '$1==site{print $0}' | wc -l` - unclaimed=`echo $claimed $running 0 | awk '{print int($2-$1)}'` + if [ -z $claimedpro ] ; then claimedpro=null ; fi + if [ -z $runningpro ] ; then runningpro=null ; fi + if [ -z $pressurepro ] ; then pressurepro=null ; fi + if [ -z $exclusivepressurepro ] ; then exclusivepressurepro=null ; fi - # still need to remove the comma on the last one - printf ' [ "%s","%s","%s",%i,%i,' $site "$downtime" "$validityofpledge" $totalpledge $analysispledge + printf ' ["%s","%s","%s",%s,%s,' $site "$downtime" "$validityofpledge" $totalpledge $analysispledge printf '%s,%s,' $avgusageana $maxusageana printf '%s,%s,' $avgusagetst $maxusagetst printf '%s,%s,' $avgusagepro $maxusagepro @@ -145,10 +185,12 @@ for site in $sites ; do printf '%s,%s,%s,%s,' $claimedana $runningana $pressureana $exclusivepressureana printf '%s,%s,%s,%s,' $claimedglo $runningglo $pressureglo $exclusivepressureglo printf '%s,%s,%s,%s],\n' $claimedpro $runningpro $pressurepro $exclusivepressurepro -done +done +} | sed '$s/,$//' | sed 's/\"null\"/null/g' >>$OUTFILE + # close the json file -cat <>$OUTFILE ] } } diff --git a/condor_pool_statistics_wrapper.sh b/condor_pool_statistics_wrapper.sh index 714773f..e134e3d 100755 --- a/condor_pool_statistics_wrapper.sh +++ b/condor_pool_statistics_wrapper.sh @@ -1,6 +1,16 @@ #!/bin/sh source /home/letts/Monitor/glideinWMSMonitor/bashrc OUTFILE=$glideinWMSMonitor_OUTPUT_DIR/monitor-glideinWMS-`/bin/date +%F-Z%R -u`.json +TMPFILE=${OUTFILE}.tmp alarm() { perl -e 'alarm shift; exec @ARGV' "$@"; } -alarm 600 $glideinWMSMonitor_RELEASE_DIR/condor_pool_statistics.sh > $OUTFILE +alarm 600 $glideinWMSMonitor_RELEASE_DIR/condor_pool_statistics.sh $TMPFILE +#check for errors? + +# copy output to final location and link it to latest.json +mv $TMPFILE $OUTFILE +LINK=$glideinWMSMonitor_OUTPUT_DIR/latest.json +if [ -L $LINK ] ; then + rm $LINK +fi +ln -s $OUTFILE $LINK exit diff --git a/monitor.html b/monitor.html new file mode 100644 index 0000000..fdce44a --- /dev/null +++ b/monitor.html @@ -0,0 +1,60 @@ + + + + + + + test + + + +

glideinWMS Pool Data

+ +

Site Table

+ +
+ +

AnaOps

+ +
+ +

Prodution

+ +
+ +

Global

+ +
+ + + + +