umntTime = $umntTime; $this->mntTime = $mntTime; $this->x = $x; $this->y = $y; $this->serial = $serial; $this->partition = $partition; $this->read = $read; $this->written = $written; $this->moTime = $moTime; $this->barcode = $barcode; $this->loc = $x.",".$y; $this->use = true; } }; $backLoc = '/reportDriveUtilization.htm'; $reportType = "Drive Utilization"; // !?! Replace this code with the data we already read in the previous page - don't read it twice. // Now read through the new file and create data array $buffer = ''; $modBuf = ''; $chartLineWidth = 3; // The default size of the lines the charts are drawn with. if ($_SERVER[REQUEST_METHOD] == "POST") { error_log("_POST = ". print_r($_POST, true) ); // Load the passed in data $Range = $_POST['range']; $Group = $_POST['group']; $Attrib = $_POST['attrib']; $Type = $_POST['type']; $ChartType = $_POST['chartType']; $SelBy = $_POST['SelBy']; $StaticPoints = $_POST['staticPoints']; // The file to work with is $headerString = "Unmount Time, Mount Time, Module, Position, Serial, Partition, Reads (MB), Writes (MB), Motion Time, Barcode\n"; $fileNameOrig = "/home/embedded/library/CoreService/dat/DriveLog"; $fileNameT = "/tmp/DriveLogTmp"; $fileName = "/tmp/DriveLog.csv"; // Now copy the current DriveLog to tmp error_log("Creating the concatenated file out of all DriveLog archives"); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE cp ".$fileNameOrig." ".$fileNameT, $iRet); error_log("Call to system (cp DriveLog) returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE chmod 666 ".$fileNameT, $iRet); error_log("Call to system (chmod 666 DriveLog) returned a \"$iRet\" and the output was \"$sRet\""); // Now concatenate all the archive files into the new file in tmp $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE zcat -d ".$fileNameOrig.".* >> ". $fileNameT, $iRet); error_log("Call to system (zcat DriveLog.*) returned a \"$iRet\" and the output was \"$sRet\""); $today = time(); // Find the date for the date range compare switch($Range) { case 'R_all': $formatStr = "ym"; $theRangeStart = date('ym',strtotime("-2 years") ); $theRangeEnd = date('ym',$today); break; case 'R_3m': $formatStr = "ym"; $theRangeStart = date('ym',strtotime("-3 month") ); $theRangeEnd = date('ym',$today); break; case 'R_4w': $formatStr = "ymd"; $theRangeStart = date('ymd',strtotime("-28 days") ); $theRangeEnd = date('ymd',$today); break; case 'R_7d': $formatStr = "ymd"; $theRangeStart = date('ymd',strtotime("-7 days") ); $theRangeEnd = date('ymd',$today); break; } error_log("\nThe startDate = ". $theRangeStart ." | The endDate = ". $theRangeEnd ); // Process the file set_time_limit(0); // Turn off timelimit or php will complain with large amounts of data $outBuf = ""; if ($handle = fopen($fileNameT, 'rb')) { $i=0; while(!feof($handle) and (connection_status()==0)) { //print(fread($handle, 1024*1)); // Because we need to examin the date on each line we will use the fgets instead. $buffer = fgets( $handle, $buffersize ); $tData = split(",", $buffer ); if( $tData[0] == "" ) continue; // The last one seems to be blank - pass it up bit let the loop end normally $i++; // First see if this data item is in range or not. // If not - don't use it $timeStamp = strtotime($tData[0]); //error_log("Reading record ".$i." of the data. StartDate = ".$theRangeStart." | timeStampFormated = ".date($formatStr, $timeStamp )); if( date($formatStr, $timeStamp ) <= $theRangeStart) { //error_log("The date ". $tData[0] ." is out of range for ". $Range ." | ". date($formatStr, $timeStamp ) ." < ". $theRangeStart); continue; // Try the next one } //error_log("buffer = ". $buffer); $outBuf .= $buffer; //flush(); } } if($i = 0) { // There was no data - so let the iuser know $outBuf = "No data found in date range!\n"; } //flush(); fclose($handle); //error_log("outBuf size = ".sizeof($outBuf)."\nThe buffer = ".$outBuf."\n\n\n\n\n"); if( $fh = fopen($fileName, 'w')) { fwrite($fh, $headerString, strlen($headerString)); fwrite($fh, $outBuf, strlen($outBuf)); fclose($fh); } else { error_log("Could not open the output file for writing"); error_back(0x0b); } set_time_limit(30); // Set back to the default ////////////////////////////////////////////// // Now do the operation the user requested. ////////////////////////////////////////////// if( $_POST['whatsSelected'] == "save" ) { if (file_exists($fileName)) { $size = filesize($fileName); header("Pragma: "); header("Cache-Control: "); header("Content-Type: text/csv"); header("Content-Length: $size"); header('Content-Disposition: attachment; filename="' . basename($fileName) . '"'); header("Content-Location: $fileName"); header("Cache-Control: private"); $handle = fopen($fileName, "r"); //########################################################## //# NOTE: Not using fpassthru() here because it has a bug //# in it where it was adding on the HTML code from this //# page to the bottom of the TapeApletLog file. It worked //# fine on the DriveLog file. //# The current code works with all the log files. //########################################################## // fpassthru($handle); if ($handle = fopen($fileName, 'rb')) { $i=0; while(!feof($handle) and (connection_status()==0)) { print(fread($handle, 1024*1)); flush(); } } fclose($handle); return; } else { error_log("Could not open the log file: ".$fileName); echo ""; } } else if( $_POST['whatsSelected'] == "email" ) { $operationInProgress = true; $status = new ReturnStatus(); email_file( $user, $fileName, $_POST['emailAddress'], "Library Drive Log File"); print $status->out(); return; } } else { error_log("_GET = ". print_r($_GET, true) ); $Range = $_GET['range']; $Group = $_GET['group']; $Attrib = $_GET['attrib']; $Type = $_GET['type']; $ChartType = $_GET['chartType']; $SelBy = $_GET['SelBy']; } $emailConfig = get_email_configuration($user); if( isset($emailConfig) ) { if( trim($emailConfig->smtpServer) != '' ) $isEmailConfigured = "true"; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// function check_file_exists( $filename ) { global $fileNotFound; $fh = fopen( $filename, 'rb' ); if( $fh == false ) { $fileNotFound = "true"; } else { fclose( $fh ); } } ///////////////////////////////////////////////////////////////////////////////// // Color Code the Columns to show where the chart element is getting it's data ///////////////////////////////////////////////////////////////////////////////// $chartColors = array( '#ff0000', '#00ff00', '#0000ff' ); if( $CHARTTYPE == "Pie" ) { // We do not do color coding on the pie charts - there is no way to show it. $umntColor = '#809CA6'; $mntColor = '#809CA6'; $xColor = '#809CA6'; $yColor = '#809CA6'; $serialColor = '#809CA6'; $partColor = '#809CA6'; $motionColor = '#809CA6'; $barcodeColor = '#809CA6'; $readColor = '#809CA6'; $writeColor = '#809CA6'; $colTitle1 = ""; $colTitle2 = ""; } else { // Don't do the color coding of the titles yet. It has bugs and I don't want the CR's right now. // I'll finish implementing this in the future. $umntColor = ($Attrib == 'AT_MH' ? $chartColors[0] : '#809CA6'); $mntColor = ($Attrib == 'AT_MC' || $Attrib == 'AT_MH' ? $chartColors[0] : '#809CA6'); $xColor = '#809CA6'; $yColor = '#809CA6'; $serialColor = '#809CA6'; $partColor = '#809CA6'; $motionColor = ($Attrib == 'AT_MM' ? $chartColors[0] : '#809CA6'); $barcodeColor = '#809CA6'; $readColor = '#809CA6'; $writeColor = '#809CA6'; $colTitle1 = ""; $colTitle2 = ""; if( $Attrib == 'AT_RW' ) { $readColor = $chartColors[1]; $writeColor = $chartColors[0]; } else if( $Attrib == 'AT_T_RW' ) { $readColor = $chartColors[0]; $writeColor = $chartColors[0]; } } ///////////////////////////////////////////////////////////////////////////////// // Create the data we will use to display the chart from the data in the file. ///////////////////////////////////////////////////////////////////////////////// $title = "Drive Utilization Report"; // Default $useCol2 = true; $formatStr = ""; $today = time(); error_log("Today is: ". date('l dS \o\f F Y h:i:s A', $today) ); // Set the X Captions switch( $Group ) { case 'G_ALL_COORD': $group = "All Drives By Coordinate"; $xCaption = $group; $xCursorCaption = "Coordinate:"; break; case 'G_ALL_PSN': $group = "All Drives By Physical Serial Number"; $xCaption = $group; $xCursorCaption = "Serial Number:"; break; case 'G_ALL_PART': $group = "All Partitions"; $xCaption = $group; $xCursorCaption = "Partition:"; break; case 'G_SEL_COORD': $group = "Selected Drive By Coordinate ".$SelBy; $xCaption = ($Type=="TY_TREND"?"":"Barcodes - ").$group; $xCursorCaption = "Coordinate:"; break; case 'G_SEL_PSN': $group = "Selected Drive By Physical Serial Number ".$SelBy; $xCaption = ($Type=="TY_TREND"?"":"Barcodes - ").$group; $xCursorCaption = "Serial Number:"; break; case 'G_SEL_PART': $group = "Selected Partition ".$SelBy; $xCaption = ($Type=="TY_TREND"?"":"Drive Location - ").$group; $xCursorCaption = "Partition:"; break; } ///////////////////////////////////////////////////////////////////////////////// // Set the title of the report depending on the attribute setting. ///////////////////////////////////////////////////////////////////////////////// switch( $_GET['attrib'] ) { case 'AT_RW': $title = "Data Written / Read"; $colTitle1 = "Written"; $colTitle2 = "Read"; $yCaption = "MB"; $yCursorCaption = "MB:"; break; case 'AT_T_RW': $title = "Total Read and Write"; $colTitle1 = "Reads and Writes"; $colTitle2 = ""; $yCaption = "MB"; $yCursorCaption = "MB:"; break; case 'AT_MC': $title = "Mount Count"; $colTitle1 = "Mounts"; $colTitle2 = ""; $yCaption = "# of Mounts"; $yCursorCaption = "Mounts:"; break; case 'AT_MH': $title = "Mount Time"; $colTitle1 = "Mount Time"; $colTitle2 = ""; $yCaption = "Seconds"; $yCursorCaption = "Seconds:"; break; case 'AT_MM': $title = "Motion Time"; $colTitle1 = "Motion Time"; $colTitle2 = ""; $yCaption = "Seconds"; $yCursorCaption = "Seconds:"; break; } $range = ""; switch( $Range ) { case 'R_all': $range = "All Historical Data"; break; case 'R_3m': $range = "Last 3 Months"; break; case 'R_4w': $range = "Last 4 Weeks"; break; case 'R_7d': $range = "Last 7 Days"; break; } // Create the strings to show in the description of the page. $group = $xCaption; $attrib = $title; $theAction = $_SERVER[PHP_SELF]."?range=". $Range ."&group=". $Group ."&attrib=". $Attrib ."&type=". $Type ."&chartType=". $ChartType ."&SelBy=". $SelBy ."&staticPoints=1"; $StaticPoints = isset($StaticPoints)?'true':'false'; //////////////////////////////////////////////////////////////////////////////////////////////////// // Determine the orientation $isHorizontal = false; if( isset($_GET['orientation']) ) if( $_GET['orientation'] == horizontal ) $isHorizontal = true; $isHorizontal = false; ?> <?=$CHARTTYPE?> Chart Viewer
target="contentFrame"> >
Reports - Chart Viewer
Range: Attribute: Grouping: Chart: Type:


Unmount Time
Mount Time
Module
Position
Serial
Partition
Reads MB
Writes MB
Motion Time
Barcode
 

Note: Due to long load times, the table above contains only the last 1000 items. You can save or e-mail the complete data file by using the buttons below.

Retrieve the report data file:
  :