Location: PHPKode > projects > PACSPulse > usage.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
*/

include ("globalvars.php");
include ("pagefunctions.php");

$qstradd="";

//incoming variables are P (pagetype) T (datetype) F (Filter)
//T (datetype) filter to alter the query by 
switch ($T)
{
    case "M":
    $Dstr="month(timestamp)=month(CURRENT_DATE)";
    $Outstr="Monthly";
    break;
    case "Y":
    $Dstr="year(timestamp)=year(CURRENT_DATE)";
    $Outstr="Yearly";
    break;
    case "W":
    $Dstr="week(timestamp)=week(CURRENT_DATE)";
    $Outstr="Weekly";
    break;
    default:
    $Dstr="dayofyear(timestamp)=dayofyear(CURRENT_DATE)";
    $Outstr="Today's";

}

switch ($P) //Very important page type (network/device/modality)
{
    case "N":
        $Tname="Network"; //name
        if (IsSet($F) && ($F != '0')){
          $qstradd=" and typeMod='$F' ";
        }
        $filtername="Modality";
        $sql_command = "select reverse(right(reverse(ip),length(ip)-locate('.',reverse(ip)))),count(distinct StudyUID) as numStudy,format(sum(size)/1000,1) as totsize, format((sum(numObj)/count(distinct StudyUID)),1) as avgimages,";
        $sql_command .= "format(sum(size)/sum(numObj),1) as avgsize,format(avg(rate),1) as avgrate, format(avg(size)/(avg(numObj)*avg(rate)),1) as time1st,";
        $qstrx = $sql_command . " format((avg(size)/avg(rate)),1) as timetotal from test where txrx='rx' and $Dstr $qstradd group by reverse(right(reverse(ip),length(ip)-locate('.',reverse(ip))))";
        $qsttx = $sql_command . " format((avg(size)/avg(rate)),1) as timetotal from test where txrx='tx' and $Dstr $qstradd group by reverse(right(reverse(ip),length(ip)-locate('.',reverse(ip))))";
        $fltrsql = "select distinct typeMod from test order by typeMod";
   break;
    case "M":
        $Tname="Modality"; //name
        if (IsSet($F) && ($F != '0')){
          $qstradd=" and typeMod='$F' ";
        }
        $filtername="AE Title";
        $sql_command = "select typeMod,count(distinct StudyUID) as numStudy,format(sum(size)/1000,1) as totsize, format((sum(numObj)/count(distinct StudyUID)),1) as avgimages,";
        $sql_command .= "format(sum(size)/sum(numObj),1) as avgsize,format(avg(rate),1) as avgrate, format(avg(size)/(avg(numObj)*avg(rate)),1) as time1st,";
        $qstrx= $sql_command . " format((avg(size)/avg(rate)),1) as timetotal from test where txrx='rx' and $Dstr $qstradd group by typeMod ";
        $qsttx= $sql_command . " format((avg(size)/avg(rate)),1) as timetotal from test where txrx='tx' and $Dstr $qstradd group by typeMod ";       
        $fltrsql = "select distinct nameMod from test order by nameMod";
    break;
    case "D":
        $Tname="Device"; //name
        if (IsSet($F) && ($F != '0')){
          $qstradd=" and typeMod='$F' ";
        }
        $filtername="Modality";
        $sql_command = "select nameMod,count(distinct StudyUID) as numStudy,format(sum(size)/1000,1) as totsize, format((sum(numObj)/count(distinct StudyUID)),1) as avgimages,";
        $sql_command .= "format(sum(size)/sum(numObj),1) as avgsize,format(avg(rate),1) as avgrate, format(avg(size)/(avg(numObj)*avg(rate)),1) as time1st,";
        $qstrx= $sql_command . "format((avg(size)/avg(rate)),1) as timetotal from test where txrx='rx' and $Dstr $qstradd group by nameMod";
        $qsttx= $sql_command . "format((avg(size)/avg(rate)),1) as timetotal from test where txrx='tx' and $Dstr $qstradd group by nameMod";
        $fltrsql = "select distinct typeMod from test order by typeMod";
    break;
}

gentop("$Tname Usage","$PHP_SELF?P=$P");
$db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");

function genreport($direction,$qstr,$P,$T,$Tname){
  //Generates main table
  //direction separtes incoming from outgoing
  if($direction=='rx'){$dir="Incoming";}
  else {$dir="Outgoing";}
  global $connection;
  $sql_result = mysql_query($qstr,$connection) or die (mysql_error());
  echo "<table border=1 cellspacing=1 cellpadding=1>";
  echo "<tr><td colspan=8 align=middle><b>$dir traffic report</b></td></tr>";
  echo "<tr><td align=middle><b>$Tname</b></td><td><b>Studies</b></td><td><b>Volume(MB)</b></td><td><b>Im/Study</b></td>";
  echo "<td><b>ImgSize(KB)</b></td><td><b>Rate(KB/S)</b></td><td><b>AccTime</b></td><td><b>TotalTime</b></td></tr>";
  while ($row = mysql_fetch_array($sql_result)) {
    echo "<tr>";
    for ($x=0;$x<8;$x++){	
      echo "<td align=middle><a href='chartgen.php?P=$P&T=$T&Typ=$x&V=$row[0]&Dir=$direction'>$row[$x]</a></td>";
    }
  } 
  echo "</tr></table>";
}


//generates outline table

echo "<table width=450 border=1 cellspacing=1 cellpadding=1>";
echo "<tr><td colspan=3 align=middle><b>$Outstr $Tname Report</b></td></tr>";
echo "<form method='post' action='usage.php?P=$P&T=$T'>";
echo "<tr><td align=middle><b>$filtername</b></td>";
echo "<td align=middle><select name=F onChange='submit();'><option value=0>No Filter</option>";
$sql_result = mysql_query($fltrsql,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result)) {
 $name=$row[0];
 $sel="";
 if ($F==$name){$sel="selected";}
 echo "<option $sel value=$name>$name</option>";
}
echo "</select></td></tr>";
echo "</form>";
echo "</table>";

//call main function with either incoming or outgoing request
genreport("rx",$qstrx,$P,$T,$Tname);
genreport("tx",$qsttx,$P,$T,$Tname);

//Begin Glossary echo


echo "<br>";
echo "<table border=1 cellspacing=1 cellpadding=1 align='left' width='90%'>";
echo "<tr><td colspan=3 align=middle><h3>Glossary</h3></td></tr>";
echo "<tr><td><b>AccTime</b></td><td colspan=2>The time it takes to transfer one image (seconds).Click to graph AccTime</td></tr>";
echo "<tr><td><b>AE Title</b></td><td colspan=2>Application Entity (The name for each DICOM device). Click to graph entries with AE Title.</td></tr>";
echo "<tr><td><b>Device</b></td><td colspan=2>A single dicom device on the network. Click to viewthe AE logs of this device.</td></tr>";
echo "<tr><td><b>Im/Study</b></td><td colspan=2>The number of images per study. Click to graph images per study.</td></tr>";
echo "<tr><td><b>ImgSize</b></td><td colspan=2>The average image size being transferred in Kilobytes (KB). Click to graph the average images size per week.</td></tr>";
echo "<tr><td><b>Incoming</b></td><td colspan=2>To describe all data being imported to the server</td></tr>";
echo "<tr><td><b>Modality</b></td><td colspan=2>Imaging Modality (ie CT=Computed Tomography)</td></tr>";
echo "<tr><td><b>Outgoing</b></td><td colspan=2>To describe all data being exported from the server</td></tr>";
echo "<tr><td><b>Rate</b></td><td colspan=2>The study transfer rate in Kilobytes per Second (KB/S). Click to graph transfer rate per week.</td></tr>";
echo "<tr><td><b>Studies</b></td><td colspan=2>The number of studies. Click to graph the number of studies per week.</td></tr>";
echo "<tr><td><b>TotalTime</b></td><td colspan=2>The time it takes for the entire study to transfer (in seconds). Click to graph the average total transfer time per week.</td></tr>";
echo "<tr><td><b>Volume</b></td><td colspan=2>The raw amount of data being sent in Megabytes (MB). Click to graph the total number of gigabytes of data per week.</td></tr>";
echo "</table>";


//End Glossary echo


genbottom();
?>
Return current item: PACSPulse