PHP监测Memcache服务端的运行状况(5)


// singleout
// when singleout is set, it only gives details for that server.
if (isset($_GET['singleout']) && $_GET['singleout']>=0 && $_GET['singleout'] <count($MEMCACHE_SERVERS)){
    $MEMCACHE_SERVERS = array($MEMCACHE_SERVERS[$_GET['singleout']]);
}

// display images
if (isset($_GET['IMG'])){
    $memcacheStats = getMemcacheStats();
    $memcacheStatsSingle = getMemcacheStats(false);

if (!graphics_avail()) {
  exit(0);
 }

function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
  global $col_black;
  $x1=$x+$w-1;
  $y1=$y+$h-1;

imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
  if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
  else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
  imagerectangle($im, $x, $y1, $x1, $y, $color1);
  if ($text) {
   if ($placeindex>0) {

if ($placeindex<16)
    {
     $px=5;
     $py=$placeindex*12+6;
     imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
     imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
     imagestring($im,2,$px,$py-6,$text,$color1);

} else {
     if ($placeindex<31) {
      $px=$x+40*2;
      $py=($placeindex-15)*12+6;
     } else {
      $px=$x+40*2+100*intval(($placeindex-15)/15);
      $py=($placeindex%15)*12+6;
     }
     imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
     imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
     imagestring($im,2,$px+2,$py-6,$text,$color1);
    }
   } else {
    imagestring($im,4,$x+5,$y1-16,$text,$color1);
   }
  }
 }


    function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {
  $r=$diameter/2;
  $w=deg2rad((360+$start+($end-$start)/2)%360);


  if (function_exists("imagefilledarc")) {
   // exists only if GD 2.0.1 is avaliable
   imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
   imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
   imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
  } else {
   imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
   imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
   imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
   imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))  * $r, $centerY + sin(deg2rad($end))  * $r, $color2);
   imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))  * $r, $centerY + sin(deg2rad($end))  * $r, $color2);
   imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
  }
  if ($text) {
   if ($placeindex>0) {
    imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
    imagestring($im,4,$diameter, $placeindex*12,$text,$color1);

} else {
    imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
   }
  }
 }
 $size = GRAPH_SIZE; // image size
 $image = imagecreate($size+50, $size+10);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8864f323703fffce391c0cd784e04a30.html