Code

Added stats actions to management and class ldap
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Jul 2010 14:34:36 +0000 (14:34 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Jul 2010 14:34:36 +0000 (14:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19299 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc
gosa-core/include/class_management.inc
gosa-core/include/class_stats.inc

index ba2dafe6db5e376595bf59764de6d1bcf6fcef87..425058b5dfa352f64849ae4cde4e3e5b4e926b76 100644 (file)
@@ -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";
index a7d1fec84ddfca166a7cd4a5684e66075b68f41a..0c74ff20f981bb7b44dabd4ef58ddb3f855cb9ab 100644 (file)
@@ -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));
     }
   } 
index 4076e202f03fd8c745031955ffae743e35697722..54420e9d91bb08142eb29727c7e69a052d1b6f4a 100644 (file)
@@ -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 "<pre>";
         foreach(sqlite_fetch_all($res) as $entry){