/**
  * Plot graphic
  *
  * @param integer $serverid
  */
 public static function PlotGraphic($rrddbpath, $image_path, $r)
 {
     $graph = new RRDGraph(440, 180, CONFIG::$RRDTOOL_PATH);
     $graph->AddDEF("mem1", $rrddbpath, "swap", "AVERAGE");
     $graph->AddDEF("mem2", $rrddbpath, "swapavail", "AVERAGE");
     $graph->AddDEF("mem3", $rrddbpath, "total", "AVERAGE");
     $graph->AddDEF("mem4", $rrddbpath, "avail", "AVERAGE");
     $graph->AddDEF("mem5", $rrddbpath, "free", "AVERAGE");
     $graph->AddDEF("mem6", $rrddbpath, "shared", "AVERAGE");
     $graph->AddDEF("mem7", $rrddbpath, "buffer", "AVERAGE");
     $graph->AddDEF("mem8", $rrddbpath, "cached", "AVERAGE");
     $graph->AddCDEF("swap_total", "mem1,1024,*");
     $graph->AddVDEF("swap_total_min", "swap_total,MINIMUM");
     $graph->AddVDEF("swap_total_last", "swap_total,LAST");
     $graph->AddVDEF("swap_total_avg", "swap_total,AVERAGE");
     $graph->AddVDEF("swap_total_max", "swap_total,MAXIMUM");
     $graph->AddCDEF("swap_avail", "mem2,1024,*");
     $graph->AddVDEF("swap_avail_tot", "swap_avail,LAST");
     $graph->AddVDEF("swap_avail_min", "swap_avail,MINIMUM");
     $graph->AddVDEF("swap_avail_last", "swap_avail,LAST");
     $graph->AddVDEF("swap_avail_avg", "swap_avail,AVERAGE");
     $graph->AddVDEF("swap_avail_max", "swap_avail,MAXIMUM");
     $graph->AddCDEF("swap_used", "swap_total,swap_avail,-");
     $graph->AddVDEF("swap_used_min", "swap_used,MINIMUM");
     $graph->AddVDEF("swap_used_last", "swap_used,LAST");
     $graph->AddVDEF("swap_used_avg", "swap_used,AVERAGE");
     $graph->AddVDEF("swap_used_max", "swap_used,MAXIMUM");
     $graph->AddCDEF("mem_total", "mem3,1024,*");
     $graph->AddVDEF("mem_total_min", "mem_total,MINIMUM");
     $graph->AddVDEF("mem_total_last", "mem_total,LAST");
     $graph->AddVDEF("mem_total_avg", "mem_total,AVERAGE");
     $graph->AddVDEF("mem_total_max", "mem_total,MAXIMUM");
     $graph->AddCDEF("mem_avail", "mem4,1024,*");
     $graph->AddVDEF("mem_avail_min", "mem_avail,MINIMUM");
     $graph->AddVDEF("mem_avail_last", "mem_avail,LAST");
     $graph->AddVDEF("mem_avail_avg", "mem_avail,AVERAGE");
     $graph->AddVDEF("mem_avail_max", "mem_avail,MAXIMUM");
     $graph->AddCDEF("mem_free", "mem5,1024,*");
     $graph->AddVDEF("mem_free_min", "mem_free,MINIMUM");
     $graph->AddVDEF("mem_free_last", "mem_free,LAST");
     $graph->AddVDEF("mem_free_avg", "mem_free,AVERAGE");
     $graph->AddVDEF("mem_free_max", "mem_free,MAXIMUM");
     $graph->AddCDEF("mem_shared", "mem6,1024,*");
     $graph->AddVDEF("mem_shared_min", "mem_shared,MINIMUM");
     $graph->AddVDEF("mem_shared_last", "mem_shared,LAST");
     $graph->AddVDEF("mem_shared_avg", "mem_shared,AVERAGE");
     $graph->AddVDEF("mem_shared_max", "mem_shared,MAXIMUM");
     $graph->AddCDEF("mem_buffer", "mem7,1024,*");
     $graph->AddVDEF("mem_buffer_min", "mem_buffer,MINIMUM");
     $graph->AddVDEF("mem_buffer_last", "mem_buffer,LAST");
     $graph->AddVDEF("mem_buffer_avg", "mem_buffer,AVERAGE");
     $graph->AddVDEF("mem_buffer_max", "mem_buffer,MAXIMUM");
     $graph->AddCDEF("mem_cached", "mem8,1024,*");
     $graph->AddVDEF("mem_cached_min", "mem_cached,MINIMUM");
     $graph->AddVDEF("mem_cached_last", "mem_cached,LAST");
     $graph->AddVDEF("mem_cached_avg", "mem_cached,AVERAGE");
     $graph->AddVDEF("mem_cached_max", "mem_cached,MAXIMUM");
     $graph->AddComment('<b><tt>                      Minimum       Current       Average       Maximum</tt></b>\\j');
     $graph->AddArea("mem_shared", self::COLOR_MEM_SHRD, "<tt>Shared        </tt>");
     $graph->AddGPrint("swap_total_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_total_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_total_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_total_max", '<tt>%4.1lf %s</tt>\\j');
     $graph->AddArea("mem_buffer", self::COLOR_MEM_BUFF, "<tt>Buffer        </tt>", "STACK");
     $graph->AddGPrint("mem_buffer_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_buffer_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_buffer_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_buffer_max", '<tt>%4.1lf %s</tt>\\j');
     $graph->AddArea("mem_cached", self::COLOR_MEM_CACH, "<tt>Cached        </tt>", "STACK");
     $graph->AddGPrint("mem_cached_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_cached_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_cached_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_cached_max", '<tt>%4.1lf %s</tt>\\j');
     $graph->AddArea("mem_free", self::COLOR_MEM_FREE, "<tt>Free          </tt>", "STACK");
     $graph->AddGPrint("mem_free_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_free_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_free_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_free_max", '<tt>%4.1lf %s</tt>\\j');
     $graph->AddArea("mem_avail", self::COLOR_MEM_REAL, "<tt>Real          </tt>", "STACK");
     $graph->AddGPrint("mem_avail_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_avail_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_avail_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("mem_avail_max", '<tt>%4.1lf %s</tt>\\j');
     //$graph->AddGPrint("swap_avail_tot", '       Mem Total: %4.1lf%S\\j');
     $graph->AddLine(1, "swap_used", self::COLOR_MEM_SWAP, "<tt>Swap In Use   </tt>");
     $graph->AddGPrint("swap_used_min", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_used_last", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_used_avg", '<tt>%4.1lf %s</tt>');
     $graph->AddGPrint("swap_used_max", '<tt>%4.1lf %s</tt>\\j');
     // $graph->AddGPrint("swap_used_last", '            Swap Total:%4.1lf%S\\j');
     if (CONFIG::$RRD_DEFAULT_FONT_PATH) {
         $graph->AddFont("DEFAULT", "0", CONFIG::$RRD_DEFAULT_FONT_PATH);
     }
     $dt = date("M j, Y H:i:s");
     //
     // Plot graphics
     //
     $res = $graph->Plot($image_path, $r["start"], $r["end"], array("--step", $r["step"], "--pango-markup", "-v", "Memory Usage", "-t", "Memory Usage ({$dt})", "-l", "0", "-b", "1024", "--alt-autoscale-max", "--alt-autoscale-min", "--rigid", "--no-gridfit", "--slope-mode", "--x-grid", $r["x_grid"]));
     return true;
 }
 /**
  * Plot graphic
  *
  * @param integer $serverid
  */
 public static function PlotGraphic($rrddbpath, $image_path, $r)
 {
     $graph = new RRDGraph(440, 140, CONFIG::$RRDTOOL_PATH);
     $graph->AddDEF("la1", $rrddbpath, "la1", "AVERAGE");
     $graph->AddVDEF("la1_min", "la1,MINIMUM");
     $graph->AddVDEF("la1_last", "la1,LAST");
     $graph->AddVDEF("la1_avg", "la1,AVERAGE");
     $graph->AddVDEF("la1_max", "la1,MAXIMUM");
     $graph->AddDEF("la5", $rrddbpath, "la5", "AVERAGE");
     $graph->AddVDEF("la5_min", "la5,MINIMUM");
     $graph->AddVDEF("la5_last", "la5,LAST");
     $graph->AddVDEF("la5_avg", "la5,AVERAGE");
     $graph->AddVDEF("la5_max", "la5,MAXIMUM");
     $graph->AddDEF("la15", $rrddbpath, "la15", "AVERAGE");
     $graph->AddVDEF("la15_min", "la15,MINIMUM");
     $graph->AddVDEF("la15_last", "la15,LAST");
     $graph->AddVDEF("la15_avg", "la15,AVERAGE");
     $graph->AddVDEF("la15_max", "la15,MAXIMUM");
     $graph->AddComment('<b><tt>                              Minimum     Current     Average     Maximum</tt></b>\\j');
     $graph->AddArea("la15", self::COLOR_LA15, "<tt>15 Minutes system load:</tt>");
     $graph->AddGPrint("la15_min", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la15_last", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la15_avg", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la15_max", '<tt>%3.2lf</tt>\\j');
     $graph->AddLine(1, "la5", self::COLOR_LA5, "<tt> 5 Minutes system load:</tt>");
     $graph->AddGPrint("la5_min", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la5_last", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la5_avg", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la5_max", '<tt>%3.2lf</tt>\\j');
     $graph->AddLine(1, "la1", self::COLOR_LA1, "<tt> 1 Minute  system load:</tt>");
     $graph->AddGPrint("la1_min", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la1_last", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la1_avg", '<tt>%3.2lf</tt>');
     $graph->AddGPrint("la1_max", '<tt>%3.2lf</tt>\\j');
     if (CONFIG::$RRD_DEFAULT_FONT_PATH) {
         $graph->AddFont("DEFAULT", "0", CONFIG::$RRD_DEFAULT_FONT_PATH);
     }
     $dt = date("M j, Y H:i:s");
     $res = $graph->Plot($image_path, $r["start"], $r["end"], array("--step", $r["step"], "--pango-markup", "-v", "Load averages", "-t", "Load averages ({$dt})", "-l", "0", "--alt-autoscale-max", "--alt-autoscale-min", "--rigid", "--no-gridfit", "--slope-mode", "--alt-y-grid", "-X0", "--x-grid", $r["x_grid"]));
     return true;
 }
 /**
  * Plot graphic
  *
  * @param integer $serverid
  */
 public static function PlotGraphic($rrddbpath, $image_path, $r)
 {
     $graph = new RRDGraph(440, 100, CONFIG::$RRDTOOL_PATH);
     $graph->AddDEF("in", $rrddbpath, "in", "AVERAGE");
     $graph->AddDEF("out", $rrddbpath, "out", "AVERAGE");
     $graph->AddCDEF("in_bits", "in,8,*");
     $graph->AddCDEF("out_bits", "out,8,*");
     $graph->AddVDEF("in_last", "in_bits,LAST");
     $graph->AddVDEF("in_avg", "in_bits,AVERAGE");
     $graph->AddVDEF("in_max", "in_bits,MAXIMUM");
     $graph->AddVDEF("out_last", "out_bits,LAST");
     $graph->AddVDEF("out_avg", "out_bits,AVERAGE");
     $graph->AddVDEF("out_max", "out_bits,MAXIMUM");
     $graph->AddComment('<b><tt>           Current   Average   Maximum</tt></b>\\j');
     $graph->AddArea("in_bits", self::COLOR_INBOUND, "<tt>In:    </tt>");
     $graph->AddGPrint("in_last", '<tt>  %4.1lf%s</tt>');
     $graph->AddGPrint("in_avg", '<tt>  %4.1lf%s</tt>');
     $graph->AddGPrint("in_max", '<tt>  %4.1lf%s</tt>\\n');
     $graph->AddLine(1, "out_bits", self::COLOR_OUBOUND, "<tt>Out:   </tt>");
     $graph->AddGPrint("out_last", '<tt>  %4.1lf%s</tt>');
     $graph->AddGPrint("out_avg", '<tt>  %4.1lf%s</tt>');
     $graph->AddGPrint("out_max", '<tt>  %4.1lf%s</tt>\\n');
     if (CONFIG::$RRD_DEFAULT_FONT_PATH) {
         $graph->AddFont("DEFAULT", "0", CONFIG::$RRD_DEFAULT_FONT_PATH);
     }
     $dt = date("M j, Y H:i:s");
     $res = $graph->Plot($image_path, $r["start"], $r["end"], array("--step", $r["step"], "--pango-markup", "-v", "Bits per second", "-t", "Network usage ({$dt})", "-l", "0", "--alt-autoscale-max", "--alt-autoscale-min", "--rigid", "--no-gridfit", "--slope-mode", "--x-grid", $r["x_grid"]));
     return true;
 }
 /**
  * Plot graphic
  *
  * @param integer $serverid
  */
 public static function PlotGraphic($rrddbpath, $image_path, $r)
 {
     $graph = new RRDGraph(440, 160, CONFIG::$RRDTOOL_PATH);
     $graph->AddDEF("a", $rrddbpath, "user", "AVERAGE");
     $graph->AddDEF("b", $rrddbpath, "system", "AVERAGE");
     $graph->AddDEF("c", $rrddbpath, "nice", "AVERAGE");
     $graph->AddDEF("d", $rrddbpath, "idle", "AVERAGE");
     $graph->AddCDEF("total", "a,b,c,d,+,+,+");
     $graph->AddCDEF("a_perc", "a,total,/,100,*");
     $graph->AddVDEF("a_perc_last", "a_perc,LAST");
     $graph->AddVDEF("a_perc_avg", "a_perc,AVERAGE");
     $graph->AddVDEF("a_perc_max", "a_perc,MAXIMUM");
     $graph->AddCDEF("b_perc", "b,total,/,100,*");
     $graph->AddVDEF("b_perc_last", "b_perc,LAST");
     $graph->AddVDEF("b_perc_avg", "b_perc,AVERAGE");
     $graph->AddVDEF("b_perc_max", "b_perc,MAXIMUM");
     $graph->AddCDEF("c_perc", "c,total,/,100,*");
     $graph->AddVDEF("c_perc_last", "c_perc,LAST");
     $graph->AddVDEF("c_perc_avg", "c_perc,AVERAGE");
     $graph->AddVDEF("c_perc_max", "c_perc,MAXIMUM");
     $graph->AddCDEF("d_perc", "d,total,/,100,*");
     $graph->AddVDEF("d_perc_last", "d_perc,LAST");
     $graph->AddVDEF("d_perc_avg", "d_perc,AVERAGE");
     $graph->AddVDEF("d_perc_max", "d_perc,MAXIMUM");
     $graph->AddComment('<b><tt>               Current    Average    Maximum</tt></b>\\j');
     $graph->AddArea("a_perc", self::COLOR_CPU_USER, "<tt>user    </tt>");
     $graph->AddGPrint("a_perc_last", '<tt>    %3.0lf%%</tt>');
     $graph->AddGPrint("a_perc_avg", '<tt>     %3.0lf%%</tt>');
     $graph->AddGPrint("a_perc_max", '<tt>     %3.0lf%%</tt>\\n');
     $graph->AddArea("b_perc", self::COLOR_CPU_SYST, "<tt>system  </tt>", "STACK");
     $graph->AddGPrint("b_perc_last", '<tt>    %3.0lf%%</tt>');
     $graph->AddGPrint("b_perc_avg", '<tt>     %3.0lf%%</tt>');
     $graph->AddGPrint("b_perc_max", '<tt>     %3.0lf%%</tt>\\n');
     $graph->AddArea("c_perc", self::COLOR_CPU_NICE, "<tt>nice    </tt>", "STACK");
     $graph->AddGPrint("c_perc_last", '<tt>    %3.0lf%%</tt>');
     $graph->AddGPrint("c_perc_avg", '<tt>     %3.0lf%%</tt>');
     $graph->AddGPrint("c_perc_max", '<tt>     %3.0lf%%</tt>\\n');
     $graph->AddArea("d_perc", self::COLOR_CPU_IDLE, "<tt>idle    </tt>", "STACK");
     $graph->AddGPrint("d_perc_last", '<tt>    %3.0lf%%</tt>');
     $graph->AddGPrint("d_perc_avg", '<tt>     %3.0lf%%</tt>');
     $graph->AddGPrint("d_perc_max", '<tt>     %3.0lf%%</tt>\\n');
     if (CONFIG::$RRD_DEFAULT_FONT_PATH) {
         $graph->AddFont("DEFAULT", "0", CONFIG::$RRD_DEFAULT_FONT_PATH);
     }
     $dt = date("M j, Y H:i:s");
     $res = $graph->Plot($image_path, $r["start"], $r["end"], array("--step", $r["step"], "--pango-markup", "-v", "Percent CPU Utilization", "-t", "CPU Utilization ({$dt})", "-u", "100", "--alt-autoscale-max", "--alt-autoscale-min", "--rigid", "--no-gridfit", "--slope-mode", "--x-grid", $r["x_grid"]));
     return true;
 }