友善交流技术...

PHP 监控memcache

上一篇 / 下一篇  2011-07-28 18:17:33 / 个人分类:单元测试

PHP 学习监控memcache 的代码(刚刚学习PHP,感觉功能挺强大的)

下面的代码是监控了memcache几个参数 ,通过入数据库,然后再次展示在页面中的代码.具体的代码如下所示:

<html>
<title>Memcache montior ...</title>
<h1>Memcache Monitor perform. data!</br></h1>

<?php

//memcache t����
include 'cmysql.php';
$memcache = new Memcache();
$memcache->connect("10.1.71.102","11211");
$arrConn=$memcache->getstats();


$curr_connections = $arrConn["curr_connections"];
$total_connections = $arrConn["total_connections"];
$get_hits = $arrConn["get_hits"];
$get_misses = $arrConn["get_misses"];
$cmd_get = $arrConn["cmd_get"];
$cmd_set = $arrConn["cmd_set"];
$memcache->close();

//��ݿ�,ȡ��������
$mnow = time();

$sql = "insert into memcache(curr_connections,total_connections,get_hits,get_misses,cmd_get,cmd_set,mdate)values($curr_connections,$total_connections,$get_hits,$get_misses,$cmd_get,$cmd_set,$mnow)";
$mysql = new Mysql();
$mysql->mysql_conn();
$mysql->mysql_insert($sql);
$mysql->mysql_close();


//����ݿ�ȡ��ݣ�Ȼ��չʾ��4
$select_sql = "select * from memcache order by mdate limit 10";
$mysql = new Mysql();
$mysql->mysql_conn();
$arrData = $mysql->mysql_select($select_sql);

 

echo "<table border=\"20\" color=red>";    
      echo "<tr>";     
      echo "<td>curr_connections</td>";
      echo "<td>total_connections</td>";
      echo "<td>cmd_get</td>";
      echo "<td>cmd_set</td>";
      echo "<td>get_hits</td>";
      echo "<td>get_misses</td>";
      echo "<td>delete_hits</td>";
      echo "<td>threads</td>";
      echo "</font>";
      
 foreach ( $arrData as $k => $v ) {
  echo"<tr>
  <td>{$v['curr_connections']}</td>
  <td>{$v['total_connections']}</td>
  <td>{$v['cmd_get']}</td>
  <td>{$v['cmd_set']}</td>
  <td>{$v['get_hits']}</td>
  <td>{$v['get_misses']}</td>
  <td>{$v['delete_hits']}</td>
  <td>{$v['threads']}</td>
  </tr>";
 }
 echo"<table>";

 $mysql->mysql_close();


?>
</html>

 


TAG:

 

评分:0

我来说两句

Open Toolbar