Overview\n";
$sql = "SELECT system, COUNT(jobid) AS jobcount, SUM(nproc*TIME_TO_SEC(walltime))/3600.0 AS cpuhours, NULL AS pct_util, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."' AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." ) GROUP BY system ORDER BY ".$_POST['order']." DESC";
#echo "
\n".$sql."
\n";
echo "\n";
echo "system | jobcount | cpuhours | %util | users | groups |
\n";
ob_flush();
flush();
$result = db_query($db,$sql);
while ($result->fetchInto($row))
{
$data=array();
$rkeys=array_keys($row);
echo "";
foreach ($rkeys as $rkey)
{
if ( $row[$rkey]==NULL )
{
$ndays=ndays($db,$row[0],$_POST['start_date'],$_POST['end_date']);
if ( $ndays[1]>0 )
{
$data[$rkey]=sprintf("%6.2f",100.0*$row[2]/$ndays[1]);
}
else
{
$data[$rkey]="N/A";
}
}
else
{
$data[$rkey]=$row[$rkey];
}
echo "".$data[$rkey]." | ";
}
echo "
\n";
ob_flush();
flush();
}
if ( $_POST['system']=="%" )
{
$sql = "SELECT 'TOTAL', COUNT(jobid) AS jobcount, SUM(nproc*TIME_TO_SEC(walltime))/3600.0 AS cpuhours, 'N/A' AS pct_util, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."' AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." )";
$result = db_query($db,$sql);
while ($result->fetchInto($row))
{
$rkeys=array_keys($row);
echo "";
foreach ($rkeys as $rkey)
{
$data[$rkey]=array_shift($row);
echo "".$data[$rkey]." | ";
}
echo "
\n";
ob_flush();
flush();
}
}
echo "
\n";
# by institution
# NOTE By-institution jobstats involves OSC site-specific logic. You may
# want to comment out the following statement.
$inst_summary=true;
if ( isset($_POST['institution']) && isset($inst_summary) && $inst_summary==true )
{
echo "Usage By Institution\n";
$result=get_metric($db,$_POST['system'],'institution','usage',$_POST[start_date],$_POST[end_date]);
metric_as_table($result,'institution','usage');
ob_flush();
flush();
}
# software usage
if ( isset($_POST['software']) )
{
echo "Software Usage
\n";
echo "
\n";
echo "package | jobcount | cpuhours | users | groups |
\n";
ob_flush();
flush();
$first=1;
$sql = "";
foreach ( $packages as $pkg )
{
if ( $first==1 )
{
$first=0;
}
else
{
$sql .= "UNION\n";
}
$sql .= "SELECT '".$pkg."', COUNT(jobid) AS jobcount, SUM(nproc*TIME_TO_SEC(walltime))/3600.0 AS cpuhours, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."' AND ( ";
if ( isset($pkgmatch[$pkg]) )
{
$sql .= $pkgmatch[$pkg];
}
else
{
$sql .= "script LIKE '%".$pkg."%' OR software LIKE '%".$package."%'";
}
$sql .= " ) AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." )";
$sql .= "\n";
}
$sql .= " ORDER BY ".$_POST['order']." DESC";
#echo "\n".$sql."
\n";
$result = db_query($db,$sql);
while ($result->fetchInto($row))
{
$rkeys=array_keys($row);
echo "";
foreach ($rkeys as $rkey)
{
$data[$rkey]=array_shift($row);
echo "".$data[$rkey]." | ";
}
echo "
\n";
ob_flush();
flush();
}
echo "
\n";
}
db_disconnect($db);
bookmarkable_url();
}
else
{
begin_form("usage-summary.php");
system_chooser();
date_fields();
$orders=array("jobcount","cpuhours","users","groups");
checkboxes_from_array("Supplemental reports",array("institution","software"));
$defaultorder="cpuhours";
pulldown("order","Order by",$orders,$defaultorder);
end_form();
}
page_footer();
?>