summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1da8db1)
raw | patch | inline | side by side (parent: 1da8db1)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Jul 2010 14:13:30 +0000 (14:13 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Jul 2010 14:13:30 +0000 (14:13 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19297 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_config.inc | patch | blob | history | |
gosa-core/include/class_plugin.inc | patch | blob | history | |
gosa-core/include/class_stats.inc | [new file with mode: 0644] | patch | blob |
index 7001880bfbefa983323db212d13d8e022c28900a..4480396be833ada67f0b01f57873bf67cd10b708 100644 (file)
var $filename = "";
var $last_modified = 0;
+ var $gosaUUID = "";
+
private $jsonRPChandle = NULL;
public $configRegistry = NULL;
$this->parser = xml_parser_create();
$this->basedir= $basedir;
+ $this->gosaUUID = uniqid();
+
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, "tag_open", "tag_close");
}
+ function getGOsaUUID()
+ {
+ return($this->gosaUUID);
+ }
+
+
/*! \brief Check and reload the configuration
*
* This function checks if the configuration has changed, since it was
index 4660c375c35f1bbac6dce9c2020ceb126f5a2b89..bdb9c7aca00cf17dbf717a42babebd706f0365b7 100644 (file)
*/
function plugin (&$config, $dn= NULL, $object= NULL)
{
+
+ $this->initTime = microtime(TRUE);
+ stats::log('plugin', $class = get_class($this), $action = 'open', $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
+
/* Configuration is fine, allways */
$this->config= &$config;
$this->dn= $dn;
session::set('LOCK_VARS_USED_REQUEST',array());
pathNavigator::registerPlugin($this);
+ stats::log('plugin', $class = get_class($this), $action = 'view', $amount = 1, $duration = microtime(TRUE) - $this->initTime);
}
/*! \brief Removes object from parent
*/
if($this->initially_was_account){
$this->handle_pre_events('remove');
+ stats::log('plugin', $class = get_class($this), $action = 'remove', $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
}
}
if($this->is_new){
$this->handle_pre_events('add');
+ stats::log('plugin', $class = get_class($this), $action = 'create', $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
}else{
$this->handle_pre_events('modify');
+ stats::log('plugin', $class = get_class($this), $action = 'modify', $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
}
}
return(TRUE);
}
+ stats::log('plugin', $class = get_class($this), $action = 'move', $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
/* Try to move the entry instead of copy & delete
*/
diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+
+class stats
+{
+
+
+
+
+ static function checkDatabase()
+ {
+ $TABLE_NAME = 'stats';
+
+ // Check for modules
+ // php5-sqlite
+
+
+ // Try to create database, if it exists just open it.
+ $res = sqlite_open('/var/spool/gosa/stats', 0666, $error);
+ if(!$res){
+ return($res);
+ }
+
+ // Delete Table
+ $query = "DROP TABLE '{$TABLE_NAME}'";
+# $ret = sqlite_query($query, $res);
+
+ // List Tables an check if there is already everything we need.
+ $query = "SELECT name FROM sqlite_master WHERE type='table' and name='{$TABLE_NAME}'";
+ $ret = sqlite_query($query, $res);
+ if(!count(sqlite_fetch_all($ret))){
+
+ // Check for table existance
+ $query = "
+ CREATE TABLE {$TABLE_NAME} (
+ ID INTEGER PRIMARY KEY,
+ ACTID INTEGER,
+ TYPE TEXT,
+ PLUGIN TEXT,
+ ACTION TEXT,
+ UUID TEXT,
+ TIMESTAMP INTEGER,
+ MTIMESTAMP INTEGER,
+ AMOUNT INTEGER,
+ DURATION INTEGER
+ )";
+ $ret = sqlite_query($query, $res);
+ }
+
+ return($res);
+ }
+
+
+
+ static function log($type, $plugin, $action, $amount = 1, $duration = 0)
+ {
+ global $config;
+ global $clicks;
+ $type = sqlite_escape_string($type);
+ $plugin = sqlite_escape_string($plugin);
+ $action = sqlite_escape_string($action);
+ $timestamp = time();
+ $mtimestamp = microtime(TRUE);
+ $uuid = $config->getGOsaUUID();
+ $amount = sqlite_escape_string($amount);
+ $duration = sqlite_escape_string($duration);
+ $clicks = sqlite_escape_string($clicks);
+
+ $res = stats::checkDatabase();
+ $TABLE_NAME = 'stats';
+ $query = "
+ INSERT INTO {$TABLE_NAME}
+ (ACTID, TYPE, PLUGIN, ACTION, UUID, MTIMESTAMP, TIMESTAMP, AMOUNT, DURATION)
+ VALUES
+ ('{$clicks}','{$type}','{$plugin}','{$action}','{$uuid}','{$mtimestamp}','{$timestamp}','{$amount}','{$duration}')";
+ sqlite_query($query, $res);
+ }
+
+ static function show()
+ {
+ $res = stats::checkDatabase();
+ $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";
+ $res = sqlite_query($query, $res);
+ echo "<pre>";
+ foreach(sqlite_fetch_all($res) as $entry){
+ foreach($entry as $key => $str){
+ if(is_numeric($key)) continue;
+
+ if($key == "DURATION"){
+ $str = sprintf("%0.4f", $str);
+ echo str_pad($str,20,' ', STR_PAD_LEFT)."|";
+ }else{
+ echo str_pad($str,20,' ')."|";
+ }
+ }
+ echo "\n";
+ }
+ echo "</pre>";
+ echo sqlite_error_string($res);
+ }
+}
+
+
+?>