Location: PHPKode > projects > Monolith - MySQL DBA Console > monolith-1.4-release/graph.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('html_errors', true);

$host_id = $_GET['host'];
$range = $_GET['range'];

include ("/var/www/html/monolith/inc/functions.php");
include ("/var/www/html/monolith/graphs/src/jpgraph.php");
include ("/var/www/html/monolith/graphs/src/jpgraph_bar.php");

function query_rate($host_id,$range) {
  $sql5 = "select host_id,Uptime,Questions,Creation_time from reporting_variables where host_id='$host_id' and DATE_SUB(CURDATE(),INTERVAL $range DAY)
 <= Creation_time order by Creation_time";
  $rowstack5 = (monitor_sql_exec("$sql5"));
  $count5 = count($rowstack5);
  for ($e = 0; $e < $count5; $e++) {
    $row5 = ($rowstack5[$e]);
    $Uptime = $row5['Uptime'];
    $Questions = $row5['Questions'];
    $Timestamp[] = $row5['Creation_time'];
    $QR[] = round(($Questions/$Uptime));
  }
  
  $leg=$Timestamp;
  $data=$QR;

  $graph = new Graph(380,160,"auto");
  $graph->SetScale("textlin"); 
  $graph->img->SetMargin(50,30,50,50);
  $graph->SetBackgroundImage("/var/www/html/monolith/images/main_bg_inv.jpg",BGIMG_FILLFRAME); //adding image                               
  $graph->SetShadow();
  $graph->title->Set('"Query Rate/sec - '.$range.' days"');
  $graph->xaxis->HideLabels(); //no xaxis labels 
  //$graph->xgrid->SetColor('lightblue'); 
  //$graph->xaxis->SetTickLabels($leg); //show bottom labels as referenced in array
  
  $bplot = new BarPlot($data);
  //  $bplot->SetFillColor("lightblue"); // Fill color solid                                                                                     
  $bplot->SetFillGradient("navy","lightsteelblue",GRAD_HOR); //blue gradient fil
  //$bplot->value->Show();
  //$bplot->value->SetFont(TTF_FONTFILE);                                                                                        
  //$bplot->value->SetAngle(90);                                                                                                     
  //$bplot->value->SetColor("black","black");
  
  $graph->Add($bplot);
  $graph->Stroke();

}

query_rate($host_id,$range);
Return current item: Monolith - MySQL DBA Console