From 396806ea934ff76017406d4a78eef464bc0103d8 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 11 Apr 2016 13:45:54 +0200 Subject: [PATCH] dbs.php --- lib/php/db.php | 4 ++++ lib/php/db/types/mysql.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/php/db.php b/lib/php/db.php index 3a264c0d..55ebbcf3 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -649,6 +649,10 @@ EOF; } # << type.status + if (($call=$this->type('status_callback'))) { + $call($new); + } + #debug($new); foreach ($new as $k=>$v) { $status[] = array( diff --git a/lib/php/db/types/mysql.php b/lib/php/db/types/mysql.php index 5270796a..1133b837 100644 --- a/lib/php/db/types/mysql.php +++ b/lib/php/db/types/mysql.php @@ -32,6 +32,11 @@ $DB_TYPES['mysql'] = array ( 'Master_Server_Id', ) as $k) { if (isset($r[$k])) $row["SLAVE.$k"] = $r[$k]; } return $row; }, + 'SHOW STATUS' => create_function('&$r',join('',array( + 'if (preg_match("/(Threads.*|Conn.*|Max_used_connections|Table_.*|Open.*_tables)/",$r["Variable_name"]))' + .'return array("STATUS.".$r[0]=>$r[1]);' + #'if (preg_match("/(Threads_connected|Max_used_connections|Table_locks_immediate|Table_locks_waited|Open.*_tables)/",$r[0])) return $r;', + ))), 'SHOW GLOBAL STATUS' => create_function('&$r',join('',array( 'if (preg_match("/(Threads.*|Conn.*|Max_used_connections|Table_.*|Open.*_tables)/",$r["Variable_name"]))' .'return array("GLOBAL.".$r[0]=>$r[1]);' @@ -43,6 +48,15 @@ $DB_TYPES['mysql'] = array ( ))), ), +'status_callback' => function(&$status) { + #debug($status['GLOBAL.Open_tables']); + #debug($status['VAR.max_connections']); + return; + foreach($status as $k=>$v) { + debug("$k $v"); + } +}, + 'table.fields' => array ( 'sql' => 'SHOW COLUMNS FROM ``', 'fct' => create_function('&$r',join('',array( -- 2.47.3