1 <?php
3 class statistics extends plugin
4 {
5 var $plHeadline = 'Statistics';
6 var $plDescription = 'GOsa usage statistics';
7 var $plShortIcon = 'statistics.png';
8 var $plIcon = 'plugin.png';
10 var $receivedStats = array();
13 function __construct($config)
14 {
15 plugin::plugin($config, NULL);
17 }
19 function execute()
20 {
23 if(isset($_POST['transmitStatistics'])){
25 // First try to retrieve values via RPC
26 if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
27 $tmp = stats::dumpTables();
28 $dump = array();
29 foreach($tmp as $entry){
30 $dump[] = array_values($entry);
31 }
33 $rpc = $this->config->getRpcHandle(
34 "http://10.3.64.59:4000",
35 "65717fe6-9e3e-11df-b010-5452005f1250",
36 "WyukwauWoid2",
37 TRUE);
38 $rpc->updateInstanceStatus($dump);
39 if(!$rpc->success()){
40 msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
41 }
42 }
43 }
45 // Transmit daily statistics to GOsa-Server
46 if(isset($_POST['receiveStatistics'])){
48 // First try to retrieve values via RPC
49 if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
50 $rpc = $this->config->getRpcHandle(
51 "http://10.3.64.59:4000",
52 "65717fe6-9e3e-11df-b010-5452005f1250",
53 "WyukwauWoid2",
54 TRUE);
55 $res = $rpc->getInstanceStats();
56 if(!$rpc->success()){
57 msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
58 }
60 $all = array_sum($res['category_count']);
61 $tmp = array();
62 $tmpRendered = array();
63 foreach($res['category_count'] as $category => $count){
64 $tmp[$category] = floor(($count / $all) * 10000) / 100;
65 $tmpRendered[$category] = progressbar($tmp[$category]);
66 }
67 $this->receivedStats = $tmpRendered;
68 }
69 }
74 $smarty = get_smarty();
75 $smarty->assign("receivedStats",$this->receivedStats);
78 return($smarty->fetch(get_template_path('statistics.tpl', TRUE)));
79 }
81 function check()
82 {
83 $messages = plugin::check();
84 return($messages);
85 }
87 function save_object()
88 {
89 plugin::save_object();
90 }
91 }
92 ?>