Code

Added deperate statisitics plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Aug 2010 09:06:25 +0000 (09:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Aug 2010 09:06:25 +0000 (09:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19365 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/contrib/gosa.conf
gosa-core/plugins/generic/statistics/class_statistics.inc
gosa-core/plugins/generic/statistics/statistics.tpl

index 7adf02005a591cb7df56617fa129aa80cf40cac0..dd6838595bc22119ae48c98c8eba8441a10a6f15 100644 (file)
@@ -74,6 +74,7 @@
   <shortCutMenu>
       <plugin acl="all" class="welcome" />
       <!-- <plugin acl="all" class="dashBoard" />-->
+      <!-- <plugin acl="all" class="statistics" />-->
   </shortCutMenu>
 
   <!-- These entries will be rendered on the path navigator -->
index f6faff637d2a66431049deb67d285ee613ba4f1c..f925ea45def8a036a3c6cfac79a1514894e421c9 100644 (file)
@@ -6,6 +6,9 @@ class statistics extends plugin
     var $plDescription = 'GOsa usage statistics';
     var $plShortIcon = 'statistics.png';
     var $plIcon = 'plugin.png';
+    
+    var $receivedStats = array();
+
 
     function __construct($config)
     {
@@ -15,7 +18,63 @@ class statistics extends plugin
 
     function execute()
     {
+
+
+        if(isset($_POST['transmitStatistics'])){
+
+            // First try to retrieve values via RPC
+            if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
+                $tmp = stats::dumpTables();
+                $dump = array();
+                foreach($tmp as $entry){
+                    $dump[] = array_values($entry);
+                }
+
+                $rpc = $this->config->getRpcHandle(
+                        "http://10.3.64.59:4000",
+                        "65717fe6-9e3e-11df-b010-5452005f1250",
+                        "WyukwauWoid2",
+                        TRUE);
+                $rpc->updateInstanceStatus($dump);
+                if(!$rpc->success()){
+                    msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
+                }
+            }
+        }
+
+        // Transmit daily statistics to GOsa-Server
+        if(isset($_POST['receiveStatistics'])){
+
+            // First try to retrieve values via RPC
+            if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
+                $rpc = $this->config->getRpcHandle(
+                        "http://10.3.64.59:4000",
+                        "65717fe6-9e3e-11df-b010-5452005f1250",
+                        "WyukwauWoid2",
+                        TRUE);
+                $res = $rpc->getInstanceStats();
+                if(!$rpc->success()){
+                    msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
+                }
+
+                $all = array_sum($res['category_count']);
+                $tmp = array();
+                $tmpRendered = array();
+                foreach($res['category_count'] as $category => $count){
+                    $tmp[$category] = floor(($count / $all) * 10000) / 100;
+                    $tmpRendered[$category] = progressbar($tmp[$category]);
+                }
+                $this->receivedStats = $tmpRendered;
+            }
+        }
+
+
+
+
         $smarty = get_smarty();
+                $smarty->assign("receivedStats",$this->receivedStats);
+
+
         return($smarty->fetch(get_template_path('statistics.tpl', TRUE)));
     }
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7d1028293f56a185f0a1a62f163a729c3944db9e 100644 (file)
@@ -0,0 +1,19 @@
+<h3>{t}Transmit daliy stats{/t}
+
+<button name='transmitStatistics'>{t}Send{/t}</button>
+<button name='receiveStatistics'>{t}Receive{/t}</button>
+
+{if $receivedStats}
+    <h3>{t}Transmit daliy stats{/t}</h3>
+    <table summary="{t}Generated usage statistics{/t}">
+    {foreach from=$receivedStats key=key item=item}
+        <tr>
+            <td>{$key}</td>
+            <td>{$item}</td>
+        </tr>
+    {/foreach}
+    </table>
+{/if}
+
+<hr>
+