PHP 学习监控memcache 的代码(刚刚学习PHP,感觉功能挺强大的)
下面的代码是监控了memcache几个参数 ,通过入数据库,然后再次展示在页面中的代码.具体的代码如下所示:
Memcache montior ...Memcache Monitor perform. data!
//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 "
echo "
";echo "
curr_connections";echo "
total_connections";echo "
cmd_get";echo "
cmd_set";echo "
get_hits";echo "
get_misses";echo "
delete_hits";echo "
threads";echo "";
foreach ( $arrData as $k => $v ) {
echo"
{$v['curr_connections']}{$v['total_connections']}{$v['cmd_get']}{$v['cmd_set']}{$v['get_hits']}{$v['get_misses']}{$v['delete_hits']}{$v['threads']}";}
echo"
$mysql->mysql_close();
?>