Location: PHPKode > projects > PACSPulse > pacspulse/serusage.php
<?php

/* 
PAC Pulse (PACS Perfomance optimization tool)
Copyright (C) 2001 Medical College of Wisconsin

This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

$mdate=date("F Y");
$ydate=date("Y");
$sdate=date("l M j");
switch ($T)
{
    case "M":
    $Dstr="month(timestamp)=month(CURRENT_DATE)";
    $Outstr="Monthly Server Usage Report for $mdate";
    $per="Monthly";
    break;
    case "Y":
    $Dstr="year(timestamp)=year(CURRENT_DATE)";
    $Outstr="Yearly Server Usage Report for $ydate";
    $per="Yearly";
    break;
    default:
    $Dstr="week(timestamp)=week(CURRENT_DATE)";
    $Outstr="Weekly Server Report for $sdate";
    $per="Weekly";

}    

include ("pagefunctions.php");
gentop("Server Analysis","$PHP_SELF?P=S");

$db = mysql_select_db("pulsetest", $connection) or dir ("Couldn't connect to Pacspulse");
$sql_command="select max(timestamp) from test";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$lastupdate=$row[0];
}
echo "<form method='post' action='serusage.php'>";
echo "<table border=1 cellspacing=1 cellpadding=1>";
echo "<tr><td colspan=2 align=middle><b>$Outstr</b></td></tr>";
echo "<tr><td>Last Update</td><td>$lastupdate</td></tr>";

$sql_command="select format(count(distinct StudyUID),0) from test where $Dstr and txrx='rx'";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$numStudies=$row[0];
}
echo "<tr><td>$per Number of Studies</td><td>$numStudies</td></tr>";
$sql_command="select  format(sum(size)/1000000,0) from test where txrx='rx' and $Dstr";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$dtsize=$row[0];
}
echo "<tr><td>$per Data Archived (GB)</td><td>$dtsize</td></tr>";



$sql_command="select format(count(distinct StudyUID),0) from test";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$numStudies=$row[0];
}
echo "<tr><td>Total Number of Studies</td><td>$numStudies</td></tr>";

$sql_command="select  format(sum(size)/1000000,0) from test where txrx='rx'";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$dtsize=$row[0];
}
echo "<tr><td>Total Data Archived (GB)</td><td>$dtsize</td></tr>";

$sql_command="select format(count(distinct StudyUID)*26,0) from test where txrx='rx'and dayofyear(timestamp)>(dayofyear(CURRENT_DATE)-14)";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$yearlystudy=$row[0];
}
$sql_command="select format(sum(size)*26/1000000,0) from test where txrx='rx'and dayofyear(timestamp)>(dayofyear(CURRENT_DATE)-14)";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$yearlyvolume=$row[0];
}
$sql_command="select sum(numObj) from test where txrx='rx'";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$numinc=$row[0];
}
$sql_command="select sum(numObj) from test where txrx='tx'";
$sql_result=mysql_query($sql_command,$connection) or die (mysql_error());
while ($row=mysql_fetch_array($sql_result)){
$numout=$row[0];
}
$utilratio=number_format($numout/$numinc,2);
if (IsSet($Q)){$T=$Q;}
else {$T=1;}
echo "<tr><td>Projected Yearly Study Num</td><td>$yearlystudy</td></tr>";
echo "<tr><td>Projected Yearly Volume (GB)</td><td>$yearlyvolume</td></tr>";
echo "<tr><td>Study Utilization Ratio</td><td>$utilratio</td></tr>";
echo "<tr><td colspan=2 align=middle><b>Select query to graph</b></td></tr>";
echo "<tr><td colspan=2 align=middle><select name='Q' onChange='submit();'>";
echo "<option selected value='none'>Choose....</option>";
echo "<option value=1>Volume and Performance by Week</option>";
echo "<option value=2>Volume and Performance by Hour</option>";
echo "<option value=4>Volume and Performance by Day of Week</option>";
echo "<option value=5>Volume and Performance by Day of Month</option>";
echo "<option value=3>Volume and Performance by Modality</option>";
echo "<option value=6>Performance as function of associations</option>";
echo "<option value=7>Performance Histogram</option>";
echo "</select></td></tr></table></form>";
echo "<table border=1 cellspacing=1 cellpadding=1><TR><TD><img src='chartsergen.php?Q=$T'></td></tr></table>";
genbottom();
?>
Return current item: PACSPulse