summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1ce082)
raw | patch | inline | side by side (parent: d1ce082)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Aug 2010 10:21:51 +0000 (10:21 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Aug 2010 10:21:51 +0000 (10:21 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19356 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_stats.inc | patch | blob | history |
index 6a55a7c6b76dda7ab428a684e215dc3cee7a40b1..73dc76ca16337cf549ee1dde59a1f460834b9474 100644 (file)
static protected $statsEnabled = FALSE;
- static function prepareFloatForWriting($float){
- return(floor($float * 1000));
- }
-
- static function prepareFloatForReading($int){
- return($int / 1000);
- }
-
+ /*! \brief This method tries to connect the GOsa-stats database and
+ * then returns a database handle on success else NULL.
+ *
+ * (The GOsa-stats database has to be enabled : statsDatabaseEnabled/statsDatabaseFile)
+ *
+ * This database will then contain information about the use of GOsa,
+ * no customer data will be stored.
+ *
+ * @return handle Returns a sqlite database handle.
+ */
static function getDatabaseHandle()
{
// Try to return last valid handle.
return($handle);
}
- /*! \brief |
- * @param |
- * @return |
+
+ /*! \brief Check whether the qlite extension is available or not.
+ * @return boolean TRUE on success else FALSE
*/
static function checkSQLiteExtension()
{
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief Drops the current stats table and thus enforces a recreation.
+ * @param handle The database handle to use.
*/
static function dropTable($handle)
{
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief Returns the currently used amount of memory form the PHP process.
+ * @return int The amount of bytes used for the PHP process.
*/
static function get_memory_usage()
{
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief Returns the current CPU load.
+ * The result will be cached and one updated every 5 seconds.
+ * @return float The current 'cpu_load'.
*/
static function get_cpu_load()
{
$cur = time();
- if(empty(stats::$lastCpuLoad) || (($cur - stats::$lastCpuLoadTimestamp) >=2 )){
+ if(empty(stats::$lastCpuLoad) || (($cur - stats::$lastCpuLoadTimestamp) >= 5 )){
list($one, $five, $ten) =preg_split("/ /",shell_exec('cat /proc/loadavg'));
stats::$lastCpuLoad = $one;
stats::$lastCpuLoadTimestamp = $cur;
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief This method checks if the 'stats' table is already present,
+ * if it is not then it will be created.
+ * @param handle The sqlite database handle
*/
static function createDatabaseOnDemand($handle)
{
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief Creates a new 'stats' table entry.
+ * -> Logs a GOsa action/activity in the sqlite stats table.
+ * @param string type The action type, e.g. ldap/plugin/management
+ * @param string plugin The plugin name, e.g. userManagement/user/posixAccount
+ * @param string category The plugin category e.g. users/servers/groups
+ * @param string action The action done e.g. edit/view/open/move
+ * @param int amount The amount, e.g. for multiple edit
+ * @param float duration The elapsed time.
+ * @param string info Some infos form the action, e.g. the used hashing mehtod for pwd changes.
*/
static function log($type, $plugin, $category, $action, $amount = 1, $duration = 0, $info ='')
{
// Get database handle, if it is invalid (NULL) return without creating stats
$res = stats::getDatabaseHandle();
-# stats::dropTable($res);
if(!$res) return;
// Ensure that 'clicks' and 'overallRenderTimer' are present and set correctly,
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief This method returns all entries of the GOsa-stats table.
+ * You can limit the result by setting the from/to parameter (timestamp).
+ * @param int from The timestamp to start the result from.
+ * @param int to The timestamp to end the request.
+ * @return array An array containing the requested entries.
*/
static function dumpTables($from = NULL, $to = NULL)
{
}
- /*! \brief |
- * @param |
- * @return |
+ /*! \brief This is just a dummy output/debug method
+ * It directly prints some stats and table infos on the screen.
*/
static function show()
{
-
- stats::dumpTables();
-
- return;
-
$res = stats::getDatabaseHandle();
# stats::dropTable($res);
if(!$res) return;
echo "</pre>";
}
-}
+ /*! \brief Somehow sqlite can not work with float values when it comes to AVG() SUM().
+ * We use this methods to convert float values to int and vice versa.
+ * The database will then contain 'int' intead of 'float'.
+ * prepareFloatForReading -> Used for reading 'float' values.
+ * prepareFloatForWriting -> Used for writing 'float' values.
+ * @param float The 'float' value to convert.
+ * @return int The converted float value.
+ */
+ static function prepareFloatForWriting($float)
+ {
+ return(floor($float * 1000));
+ }
+
+
+
+ /*! \brief Somehow sqlite can not work with float values when it comes to AVG() SUM().
+ * We use this methods to convert float values to int and vice versa.
+ * The database will then contain 'int' intead of 'float'.
+ * prepareFloatForWriting -> Used for writing 'float' values.
+ * @param float The 'int' value read from the table.
+ * @return int The converted int value.
+ */
+ static function prepareFloatForReading($int)
+ {
+ return($int / 1000);
+ }
+}
+
?>