Skip to content

Commit

Permalink
Updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesletts committed Jun 4, 2014
1 parent fc71f54 commit e841d9d
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 27 deletions.
94 changes: 68 additions & 26 deletions condor_pool_statistics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <<EOF
"glideinWMS ${NAME} Pool": {
"Collector1": "${COLLECTOR1}",
Expand All @@ -36,22 +44,28 @@ pool_table() {
"header": ["Name","Machine","Total Running Jobs","Total Idle Jobs","Total Held Jobs"],
"data" : [
EOF
condor_status -schedd -pool ${COLLECTOR1} \
-format ' ["%s",' Name \
-format '"%s",' Machine \
-format '%i,' TotalRunningJobs \
-format '%i,' TotalIdleJobs \
-format '%i],\n' TotalHeldJobs | sed '$s/,$//'
{ condor_status -schedd -pool ${COLLECTOR1} \
-format ' ["%s",' Name \
-format '"%s",' Machine \
-format '%i,' TotalRunningJobs \
-format '%i,' TotalIdleJobs \
-format '%i],\n' TotalHeldJobs
if [ $? -ne 0 ] ; then
echo " [null,null,null,null,null],"
fi
} | grep -v ^$ | sed '$s/,$//'

echo " ]"
echo " }"
echo " },"
return
}

pool_table glidein-collector.t2.ucsd.edu glidein-collector-2.t2.ucsd.edu "Analysis Operations"
pool_table vocms097.cern.ch vocms099.cern.ch "Global"
pool_table vocms97.cern.ch cmssrv119.fnal.gov "Production"
pool_table glidein-collector.t2.ucsd.edu glidein-collector-2.t2.ucsd.edu "Analysis Operations" >>$OUTFILE
pool_table vocms097.cern.ch vocms099.cern.ch "Global" >>$OUTFILE
pool_table vocms97.cern.ch cmssrv119.fnal.gov "Production" >>$OUTFILE

cat <<EOF
cat <<EOF >>$OUTFILE
"Site Table": {
"header": [
"Site","Maintenance",
Expand All @@ -60,9 +74,9 @@ cat <<EOF
"Average Analysis Test Usage","Maximum Analysis Test Usage",
"Average Production Usage","Maximum Production Usage",
"Average Total Usage","Maximum Total Usage",
"Claimed Analysis","Unclaimed Analysis","Analysis Pressure","Exclusive Analysis Pressure",
"Claimed Global","Unclaimed Global","Global Pressure","Exclusive Global Pressure",
"Claimed Production","Unclaimed Production","Production Pressure","Exclusive Production Pressure",
"Claimed Pilots Analysis","Total Pilots Analysis","Analysis Pressure","Exclusive Analysis Pressure",
"Claimed Pilots Global","Total Pilots Global","Global Pressure","Exclusive Global Pressure",
"Claimed Pilots Production","Total Pilots Production","Production Pressure","Exclusive Production Pressure"
],
"data": [
EOF
Expand Down Expand Up @@ -94,61 +108,89 @@ DESIREDPRO=`get_DESIRED_Sites vocms97.cern.ch`

# Loop over sites for the table:
sites=`cat $SEDFILE | awk -F\/ '{print $3}' | sort | uniq`
{
for site in $sites ; do
downtime=` grep ^$site\, $DOWNTIME | awk -F\, '{print $2}'`
downtime=`grep ^$site\, $DOWNTIME | awk -F\, '{print $2}'`
if [ -z "$downtime" ] ; then downtime=null ; fi

# pledge is 50% unless site is >=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
printf '%s,%s,' $avgusageall $maxusageall
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 <<EOF
cat <<EOF >>$OUTFILE
]
}
}
Expand Down
12 changes: 11 additions & 1 deletion condor_pool_statistics_wrapper.sh
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions monitor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<style type="text/css" title="currentStyle">
@import "css/jquery.dataTables.css";
</style>
<script type="text/javascript" src="jslibs/jquery.js"></script>
<script type="text/javascript" src="jslibs/jquery.dataTables.js"></script>
<head>
<title>test</title>
</head>

<body style="font-family:'Courier'">
<h1>glideinWMS Pool Data</h1>

<h2>Site Table</h2>
<table cellpadding="1" cellspacing="0" border="0" class="display" id="site_table">
</table>

<h2>AnaOps</h2>
<table cellpadding="1" cellspacing="0" border="0" class="display" id="anaops_table">
</table>

<h2>Prodution</h2>
<table cellpadding="1" cellspacing="0" border="0" class="display" id="production_table">
</table>

<h2>Global</h2>
<table cellpadding="1" cellspacing="0" border="0" class="display" id="global_table">
</table>

<script type="text/javascript">

function create_header(data) {
var dic=[];
$.each( data["header"], function( key, val ) {
dic.push({ "title" : val} );
});
return dic;
}

function create_table(table_name, data) {
var mdata=data["data"];
var hdr=create_header(data);
$(table_name).DataTable({"data" : mdata, "columns" : hdr});
}

{
$.getJSON( "./latest.json",
function( data ) {
create_table("#site_table",data["Site Table"]);
create_table("#anaops_table",data["glideinWMS Analysis Operations Pool"]["Summary Table"]);
create_table("#production_table",data["glideinWMS Production Pool"]["Summary Table"]);
create_table("#global_table",data["glideinWMS Global Pool"]["Summary Table"]);
});
}

</script>

</body>
</html>

0 comments on commit e841d9d

Please sign in to comment.