Location: PHPKode > projects > Monolith - MySQL DBA Console > monolith-1.4-release/graph-threads_now.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");
include ("/var/www/html/monolith/graphs/src/jpgraph_line.php");
include ("/var/www/html/monolith/graphs/src/jpgraph_utils.inc.php"); 

function query_rate($host_id,$range) {
  
  $sql5 = "select id,host_id,Threads_connected,Threads_running,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]);
    $Threads_connected[] = $row5['Threads_connected'];
    $Threads_running[] = $row5['Threads_running'];
    $Timestamp[] = $row5['Creation_time'];
  }
  
  $title="Threads - Usage";
  $legend1='Threads_connected';
  $legend2='Threads_running';

  $l1datay = $Threads_connected;
  $l2datay = $Threads_running;
  $datax=$Timestamp;

  // Create the graph.                                                                                                                       
  $graph = new Graph(380,160,"auto");
  $graph->SetScale("textlin");
  $graph->SetY2Scale("lin");

  $graph->img->SetMargin(50,50,50,50);
  $graph->SetBackgroundImage("/var/www/html/monolith/images/main_bg_inv.jpg",BGIMG_FILLFRAME); //adding image
  $graph->SetShadow();

  // Create the linear error plot                                                                                                            
  $l1plot=new LinePlot($l1datay);
  $l1plot->SetColor("red");
  $l1plot->SetWeight(1);
  $l1plot->SetLegend("$legend1");

  $l2plot=new LinePlot($l2datay);
  $l2plot->SetColor("blue");
  $l2plot->SetWeight(1);
  $l2plot->SetLegend("$legend2");

  // Create the bar plot                                                                                                        
  //$bplot = new BarPlot($l2datay);
  //$bplot->SetLegend("$legend2");
  //$bplot->SetFillGradient("navy","lightsteelblue",GRAD_HOR); //blue gradient fil

  // move legend over
  $graph->legend->Pos(0.26,.88,"right","center");
  $graph->xaxis->HideLabels(); //no xaxis labels

  $graph->Add($l1plot);
  $graph->AddY2($l2plot); 

  $graph->title->Set("$title - $range Day");
  $graph->xaxis->title->Set("");
  $graph->yaxis->title->Set("");

  $graph->yaxis->SetColor("red");
  $graph->y2axis->SetColor("navy");

  // Display the graph                                                                                                                       
  $graph->Stroke();
}

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