Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2011-01-26 07:54:59 +0300
committerrobocoder <anthon.pang@gmail.com>2011-01-26 07:54:59 +0300
commit4bc0d4ab06bfac15cbfea6eebbf6a4d6cce027b9 (patch)
treed600cb416a2a8d3769e1396d7007524bc6b36b2f /plugins/DBStats/API.php
parent6801e847fa3a29c894e7aa2ec507022a51c06060 (diff)
fixes #2047 - p.s. the only workaround I can think of to get the "Opens" and "Queries per second avg" stats would be to pipe and parse the STATUS output from command line clients (i.e., mysql / mysqladmin)
git-svn-id: http://dev.piwik.org/svn/trunk@3810 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/DBStats/API.php')
-rw-r--r--plugins/DBStats/API.php43
1 files changed, 34 insertions, 9 deletions
diff --git a/plugins/DBStats/API.php b/plugins/DBStats/API.php
index 1b39ec30c4..9e07cfc223 100644
--- a/plugins/DBStats/API.php
+++ b/plugins/DBStats/API.php
@@ -29,18 +29,43 @@ class Piwik_DBStats_API
public function getDBStatus()
{
Piwik::checkUserIsSuperUser();
- $configDb = Zend_Registry::get('config')->database->toArray();
- // we decode the password. Password is html encoded because it's enclosed between " double quotes
- $configDb['password'] = htmlspecialchars_decode($configDb['password']);
- if(!isset($configDb['port']))
+
+ if(function_exists('mysql_connect'))
{
- // before 0.2.4 there is no port specified in config file
- $configDb['port'] = '3306';
+ $configDb = Zend_Registry::get('config')->database->toArray();
+ // we decode the password. Password is html encoded because it's enclosed between " double quotes
+ $configDb['password'] = htmlspecialchars_decode($configDb['password']);
+ if(!isset($configDb['port']))
+ {
+ // before 0.2.4 there is no port specified in config file
+ $configDb['port'] = '3306';
+ }
+
+ $link = mysql_connect($configDb['host'], $configDb['username'], $configDb['password']);
+ $status = mysql_stat($link);
+ mysql_close($link);
+ }
+ else
+ {
+ $db = Zend_Registry::get('db');
+
+ $fullStatus = $db->fetchAssoc('SHOW STATUS;');
+ if(empty($fullStatus)) {
+ throw new Exception('Error, SHOW STATUS failed');
+ }
+
+ $status = array(
+ 'Uptime: ' . $fullStatus['Uptime']['Value'],
+ 'Threads: ' . $fullStatus['Threads_running']['Value'],
+ 'Questions: ' . $fullStatus['Questions']['Value'],
+ 'Slow queries: ' . $fullStatus['Slow_queries']['Value'],
+ 'Opens: ', // not available via SHOW STATUS
+ 'Flush tables: ' . $fullStatus['Flush_commands']['Value'],
+ 'Open tables: ' . $fullStatus['Open_tables']['Value'],
+ 'Queries per second avg: ', // not available via SHOW STATUS
+ );
}
- $link = mysql_connect($configDb['host'], $configDb['username'], $configDb['password']);
- $status = mysql_stat($link);
- mysql_close($link);
return $status;
}