Overview\n"; $sql = "SELECT system, COUNT(jobid) AS jobs, SUM(nproc*TIME_TO_SEC(walltime))/3600.0 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); 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(nproc*TIME_TO_SEC(walltime))/3600.0 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); 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 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'); if ( isset($_POST['xls']) ) { $xlsresult=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date']); metric_as_xls($xlsresult,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['ods']) ) { $odsresult=get_metric($db,$_POST['system'],'institution','usage',$_POST['start_date'],$_POST['end_date']); metric_as_ods($odsresult,'institution','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } ob_flush(); flush(); } # by account if ( isset($_POST['account']) ) { echo "

Usage By Account

\n"; $result=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date']); metric_as_table($result,'account','usage'); if ( isset($_POST['xls']) ) { $xlsresult=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date']); metric_as_xls($xlsresult,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } if ( isset($_POST['ods']) ) { $odsresult=get_metric($db,$_POST['system'],'account','usage',$_POST['start_date'],$_POST['end_date']); metric_as_ods($odsresult,'account','usage',$_POST['system'],$_POST['start_date'],$_POST['end_date']); } ob_flush(); flush(); } # software usage if ( isset($_POST['software']) ) { echo "

Software Usage

\n"; echo "\n"; echo "\n"; ob_flush(); flush(); $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(nproc*TIME_TO_SEC(walltime))/3600.0 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"; $result = db_query($db,$sql); 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 "
packagejobscpuhoursusersgroupsaccounts
".$data[$rkey]."
\n"; if ( isset($_POST['xls']) ) { $xlsresult = db_query($db,$sql); $columns = array("package","jobs","cpuhours","users","groups"); result_as_xls($xlsresult,$columns,$_POST['system']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } if ( isset($_POST['ods']) ) { $odsresult = db_query($db,$sql); $columns = array("package","jobs","cpuhours","users","groups"); result_as_ods($odsresult,$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 Excel files for supplemental reports","xls"); checkbox("Generate ODF files for supplemental reports","ods"); end_form(); } page_footer(); ?>