Overview\n"; $sql = "SELECT system, COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS cpuhours, SUM(".charges($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS charges, NULL AS pct_util, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(account)) AS accounts FROM Jobs WHERE ( ".sysselect($_POST['system'])." ) AND ( ".dateselect($_POST['datelogic'],$_POST['start_date'],$_POST['end_date'])." ) GROUP BY system ORDER BY ".$_POST['order']." DESC"; #echo "
\n".$sql."\n"; echo "
system | jobs | cpuhours | charges | %util | users | groups | accounts |
---|---|---|---|---|---|---|---|
".number_format(floatval($data[$rkey]),4)." | ";
}
# if an int, format appropriately
else if ( preg_match("/^-?\d+$/",$data[$rkey])==1 )
{
echo "".number_format(floatval($data[$rkey]))." | ";
}
# otherwise print verbatim
else
{
echo "".$data[$rkey]." | ";
}
}
echo "|||||
".number_format($data[$rkey],4)." | ";
}
# if an int, format appropriately
else if ( preg_match("/^-?\d+$/",$data[$rkey])==1 )
{
echo "".number_format($data[$rkey])." | ";
}
# otherwise print verbatim
else
{
echo "".$data[$rkey]." | ";
}
}
echo "
".$result->getMessage()."\n"; } metric_as_table($result,'institution','usage'); } if ( isset($_POST['csv']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_csv($result,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); } if ( isset($_POST['xls']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_xls($result,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); } if ( isset($_POST['ods']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_ods($result,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } ob_flush(); flush(); } # by account if ( isset($_POST['account']) ) { echo "
".$result->getMessage()."\n"; } metric_as_table($result,'account','usage'); } if ( isset($_POST['csv']) ) { $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_csv($result,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); } if ( isset($_POST['xls']) ) { $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_xls($result,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['ods']) ) { $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } metric_as_ods($result,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } ob_flush(); flush(); } # software usage if ( isset($_POST['software']) ) { echo "
\n".$sql."\n"; $columns = array("package","jobs","cpuhours","charges","users","groups", "accounts"); if ( isset($_POST['table']) ) { $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } result_as_table($result,$columns); } if ( isset($_POST['csv']) ) { $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } result_as_csv($result,$columns,$_POST['system']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } if ( isset($_POST['xls']) ) { $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } result_as_xls($result,$columns,$_POST['system']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } if ( isset($_POST['ods']) ) { $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."\n"; } result_as_ods($result,$columns,$_POST['system']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } } db_disconnect($db); page_timer(); bookmarkable_url(); } else { begin_form("usage-summary.php"); virtual_system_chooser(); date_fields(); $orders=array("jobs","cpuhours","charges","users","groups"); checkboxes_from_array("Supplemental reports",array("institution","account","software")); $defaultorder="cpuhours"; pulldown("order","Order results by",$orders,$defaultorder); checkbox("Generate HTML tables for supplemental reports","table",1); checkbox("Generate CSV files for supplemental reports","csv"); checkbox("Generate Excel files for supplemental reports","xls"); checkbox("Generate ODF files for supplemental reports","ods"); end_form(); } page_footer(); ?>