From f5fb8c8428068ff43fc18c3f29bbdd9c9392eb41 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 30 Jul 2010 14:34:36 +0000 Subject: [PATCH] Added stats actions to management and class ldap git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19299 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 6 ++++++ gosa-core/include/class_management.inc | 7 +++++++ gosa-core/include/class_stats.inc | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index ba2dafe6d..425058b5d 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -235,6 +235,7 @@ class LDAP{ } $this->log("LDAP operation: time=".(microtime(true)-$start)." operation=search('".LDAP::fix($this->basedn)."', '$filter')"); + stats::log('ldap', $class = get_class($this), $action = __FUNCTION__, $amount = 1, $duration = (microtime(TRUE) - $start)); return($this->sr[$srp]); }else{ $this->error = "Could not connect to LDAP server"; @@ -268,6 +269,7 @@ class LDAP{ } $this->log("LDAP operation: time=".(microtime(true) - $start)." operation=ls('".LDAP::fix($basedn)."', '$filter')"); + stats::log('ldap', $class = get_class($this), $action = __FUNCTION__, $amount = 1, $duration = (microtime(TRUE) - $start)); return($this->sr[$srp]); }else{ @@ -584,12 +586,14 @@ class LDAP{ return (0); } if($this->hascon){ + $start = microtime(TRUE); if ($this->reconnect) $this->connect(); $r = @ldap_modify($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); if(!$this->success()){ $this->error.= $this->makeReadableErrors($this->error,$attrs); } + stats::log('ldap', $class = get_class($this), $action = __FUNCTION__, $amount = 1, $duration = (microtime(TRUE) - $start)); return($r ? $r : 0); }else{ $this->error = "Could not connect to LDAP server"; @@ -600,12 +604,14 @@ class LDAP{ function add($attrs) { if($this->hascon){ + $start = microtime(TRUE); if ($this->reconnect) $this->connect(); $r = @ldap_add($this->cid, LDAP::fix($this->basedn), $attrs); $this->error = @ldap_error($this->cid); if(!$this->success()){ $this->error.= $this->makeReadableErrors($this->error,$attrs); } + stats::log('ldap', $class = get_class($this), $action = __FUNCTION__, $amount = 1, $duration = (microtime(TRUE) - $start)); return($r ? $r : 0); }else{ $this->error = "Could not connect to LDAP server"; diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index a7d1fec84..0c74ff20f 100644 --- a/gosa-core/include/class_management.inc +++ b/gosa-core/include/class_management.inc @@ -92,6 +92,10 @@ class management $this->headpage = $headpage; $this->ui = $ui; $this->config = $config; + $this->initTime = microtime(TRUE); + + stats::log('management', $class = get_class($this), $action = __FUNCTION__, $amount = 1, + $duration = (microtime(TRUE) - $this->initTime)); if($this->cpHandler) $this->headpage->setCopyPasteHandler($this->cpHandler); if($this->snapHandler) $this->headpage->setSnapshotHandler($this->snapHandler); @@ -437,6 +441,9 @@ class management if(isset($this->actions[$action['action']])){ $func = $this->actions[$action['action']]; if(!isset($action['targets']))$action['targets']= array(); + stats::log('management', $class = get_class($this), $action['action'], $amount = count($action['targets']), + $duration = (microtime(TRUE) - $this->initTime)); + return($this->$func($action['action'],$action['targets'],$action)); } } diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc index 4076e202f..54420e9d9 100644 --- a/gosa-core/include/class_stats.inc +++ b/gosa-core/include/class_stats.inc @@ -81,7 +81,7 @@ class stats $TABLE_NAME = 'stats'; $query = "SELECT * FROM {$TABLE_NAME} ORDER BY MTIMESTAMP"; $query = "SELECT PLUGIN, ACTION, MAX(DURATION) as 'DURATION' FROM {$TABLE_NAME} WHERE ACTION='modify' GROUP BY PLUGIN,ACTION "; - $query = "SELECT * FROM {$TABLE_NAME} ORDER BY MTIMESTAMP"; + $query = "SELECT * FROM {$TABLE_NAME} ORDER BY ID DESC LIMIT 20"; $res = sqlite_query($query, $res); echo "
";
         foreach(sqlite_fetch_all($res) as $entry){
-- 
2.30.2