Overview\n"; $sql = "SELECT system, COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, NULL AS pct_util, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(account)) AS accounts 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 "\n"; ob_flush(); flush(); $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."
\n"; } 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 ""; } echo "\n"; ob_flush(); flush(); } if ( $_POST['system']=="%" ) { $sql = "SELECT 'TOTAL', COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, 'N/A' AS pct_util, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(account)) AS accounts FROM Jobs WHERE system LIKE '".$_POST['system']."' AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." )"; $result = db_query($db,$sql); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."
\n"; } while ($result->fetchInto($row)) { $rkeys=array_keys($row); echo ""; foreach ($rkeys as $rkey) { $data[$rkey]=array_shift($row); echo ""; } echo "\n"; ob_flush(); flush(); } } echo "
systemjobscpuhours%utilusersgroupsaccounts
".$data[$rkey]."
".$data[$rkey]."
\n"; # by institution # NOTE By-institution jobstats involves 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"; if ( isset($_POST['table']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date']); if ( PEAR::isError($result) ) { 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']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."
\n"; } metric_as_csv($result,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['xls']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."
\n"; } metric_as_xls($result,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['ods']) ) { $result=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date']); 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 "

Usage By Account

\n"; if ( isset($_POST['table']) ) { $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date']); if ( PEAR::isError($result) ) { 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']); if ( PEAR::isError($result) ) { echo "
".$result->getMessage()."
\n"; } metric_as_csv($result,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['xls']) ) { $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date']); 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']); 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 "

Software Usage

\n"; $first=1; $sql = "SELECT * FROM ( "; foreach ( $packages as $pkg ) { if ( $first==1 ) { $first=0; } else { $sql .= "UNION\n"; } $sql .= "SELECT '".$pkg."', COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(account)) AS accounts 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 .= " ) AS usgsofttmp WHERE jobs>0 ORDER BY ".$_POST['order']." DESC"; #echo "
\n".$sql."
\n"; $columns = array("package","jobs","cpuhours","users","groups"); 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); bookmarkable_url(); } else { begin_form("usage-summary.php"); system_chooser(); date_fields(); $orders=array("jobs","cpuhours","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(); ?>