From 1506736d8812719cb7d888bbc4a9468a94cb0fe3 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 19 Dec 2014 18:13:47 +0100 Subject: [PATCH] Added modules in the treeview --- pandora_console/include/class/Tree.class.php | 68 +++++++++++++++++-- pandora_console/include/functions_modules.php | 3 +- 2 files changed, 65 insertions(+), 6 deletions(-) mode change 100644 => 100755 pandora_console/include/functions_modules.php diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index acba6e41b9..dad595b8e9 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -53,8 +53,8 @@ class Tree { case 'module_group': $this->getDataModuleGroup(); break; - case 'module': - $this->getDataModule(); + case 'agent': + $this->getDataModules(); break; case 'tag': $this->getDataTag(); @@ -220,6 +220,51 @@ class Tree { } } + public function getDataModules() { + $modules = + agents_get_modules($this->root, array('nombre', 'id_tipo_modulo')); + + if (empty($modules)) + $modules = array(); + + $this->tree = array(); + foreach ($modules as $id => $module) { + $temp = array(); + + $temp['type'] = 'module'; + $temp['id'] = $id; + $temp['name'] = $module['nombre']; + $temp['icon'] = modules_get_type_icon( + $module['id_tipo_modulo']); + $temp['value'] = modules_get_last_value($id); + switch (modules_get_status($id)) { + case AGENT_MODULE_STATUS_CRITICAL_BAD: + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + $temp['status'] = "critical"; + break; + default: + case AGENT_MODULE_STATUS_NORMAL: + case AGENT_MODULE_STATUS_NORMAL_ALERT: + $temp['status'] = "ok"; + break; + case AGENT_MODULE_STATUS_WARNING: + case AGENT_MODULE_STATUS_WARNING_ALERT: + $temp['status'] = "warning"; + break; + case AGENT_MODULE_STATUS_UNKNOWN: + $temp['status'] = "unknown"; + break; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + $temp['status'] = "not_init"; + break; + } + $temp['children'] = array(); + + $this->tree[] = $temp; + } + } + public function getDataAgents($type, $id) { switch ($type) { case 'group': @@ -279,6 +324,22 @@ class Tree { break; } + $agents[$iterator]['children'] = array(); + if ($agents[$iterator]['counters']['total'] > 0) { + + + switch ($this->childrenMethod) { + case 'on_demand': + $agents[$iterator]['children'] = 1; + break; + case 'live': + $modules = + agents_get_modules($agents[$iterator]['id_agente']); + // TO DO + break; + } + } + } return $agents; @@ -287,9 +348,6 @@ class Tree { public function getDataModuleGroup() { } - public function getDataModule() { - } - public function getDataTag() { } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php old mode 100644 new mode 100755 index e5746032bb..5c757042f1 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -875,7 +875,8 @@ function modules_is_string_type ($id_type) { * @return string The name of the icon. */ function modules_get_type_icon ($id_type) { - return (string) db_get_value ('icon', 'ttipo_modulo', 'id_tipo', (int) $id_type); + return (string) db_get_value ('icon', 'ttipo_modulo', 'id_tipo', + (int) $id_type); } /**