diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3c814f904e..d7d60b9199 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,19 @@ +2013-03-26 Miguel de Dios + + * include/functions_reporting.php, include/functions_groups.php: + changes for to use in the calls in mobile version. + + * mobile/index.php, mobile/operation/events.php, + mobile/operation/modules.php, mobile/operation/events, + mobile/operation/events/events.php, mobile/operation/agents.php, + mobile/operation/tactical.php, mobile/operation/alerts.php, + mobile/include/style/main.css, mobile/include/ui.class.php, + mobile/include/user.class.php: changes and improves in the code + of mobile. + + * mobile/operation/agents/*, mobile/operation/servers/*: removed + the old files from version pandora mobile 4. + 2013-03-26 Miguel de Dios * include/functions_tags.php, include/functions_reporting.php, diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index d1216b5c50..e00e891fc4 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -712,8 +712,8 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { $row[__('Group')] = $group['prefix']; - $row[__('Group')] .= ""; - $row[__('Group')] .= ui_print_group_icon ($id_group, true, "groups_small"); + $row[__('Group')] .= ""; + $row[__('Group')] .= ui_print_group_icon ($id_group, true, "groups_small", '', false); $row[__('Group')] .= ui_print_truncate_text($group['name']); $row[__('Group')] .= ""; } @@ -760,7 +760,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["total_agents"] > 0) { - $row[__('Agents')] = ""; + $row[__('Agents')] = ""; $row[__('Agents')] .= $data["total_agents"]; $row[__('Agents')] .= ""; } @@ -788,7 +788,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["agents_unknown"] > 0) { - $row[__('Agents unknown')] = ""; + $row[__('Agents unknown')] = ""; $row[__('Agents unknown')] .= $data["agents_unknown"]; $row[__('Agents unknown')] .= ""; } @@ -813,7 +813,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_unknown"] > 0) { - $row[__('Unknown')] = ""; + $row[__('Unknown')] = ""; $row[__('Unknown')] .= $data["monitor_unknown"]; $row[__('Unknown')] .= ""; } @@ -839,7 +839,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_not_init"] > 0) { - $row[__('Not init')] = ""; + $row[__('Not init')] = ""; $row[__('Not init')] .= $data["monitor_not_init"]; $row[__('Not init')] .= ""; } @@ -864,7 +864,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_ok"] > 0) { - $row[__('Normal')] = ""; + $row[__('Normal')] = ""; $row[__('Normal')] .= $data["monitor_ok"]; $row[__('Normal')] .= ""; } @@ -890,7 +890,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_warning"] > 0) { - $row[__('Warning')] = ""; + $row[__('Warning')] = ""; $row[__('Warning')] .= $data["monitor_warning"]; $row[__('Warning')] .= ""; } @@ -916,7 +916,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_critical"] > 0) { - $row[__('Critical')] = ""; + $row[__('Critical')] = ""; $row[__('Critical')] .= $data["monitor_critical"]; $row[__('Critical')] .= ""; } @@ -942,7 +942,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $ } else { if ($data["monitor_alerts_fired"] > 0) { - $row[__('Alerts fired')] = ""; + $row[__('Alerts fired')] = "";; $row[__('Alerts fired')] .= $data["monitor_alerts_fired"]; $row[__('Alerts fired')] .= ""; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 9dc1e03fdf..66d767ad5d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1100,9 +1100,23 @@ function reporting_get_stats_alerts($data) { global $config; // Link URLS - $urls = array(); - $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; - $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + $mobile = false; + if (isset($data['mobile'])) { + if ($data['mobile']) { + $mobile = true; + } + } + + if ($mobile) { + $urls = array(); + $urls['monitor_alerts'] = "index.php?page=alerts&status=all_enabled"; + $urls['monitor_alerts_fired'] = "index.php?page=alerts&status=fired"; + } + else { + $urls = array(); + $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; + $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + } // Alerts table $table_al = html_get_predefined_table(); @@ -1164,9 +1178,23 @@ function reporting_get_stats_agents_monitors($data) { global $config; // Link URLS - $urls = array(); - $urls['total_agents'] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; - $urls['monitor_checks'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; + $mobile = false; + if (isset($data['mobile'])) { + if ($data['mobile']) { + $mobile = true; + } + } + + if ($mobile) { + $urls = array(); + $urls['total_agents'] = "index.php?page=agents"; + $urls['monitor_checks'] = "index.php?page=modules"; + } + else { + $urls = array(); + $urls['total_agents'] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; + $urls['monitor_checks'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; + } // Agents and modules table $table_am = html_get_predefined_table(); diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index 67d236cb46..5a4fb140e3 100644 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -31,7 +31,8 @@ tr.group_view_crit, .group_view_crit { color: #000000 !important; } -tr.group_view_norm, .group_view_norm { +.group_view_normal, .group_view_normal *, +.group_view_norm, .group_view_norm * { background-color: #FFFFFF; color: #000000 !important; } @@ -39,7 +40,7 @@ tr.group_view_norm, .group_view_norm { color: #000000 !important; } -tr.group_view_ok, .group_view_ok { +.group_view_ok, .group_view_ok * { background-color: #00C000; color: #000000 !important; } @@ -71,21 +72,26 @@ tr.group_view_unk, .group_view_unk { tr.group_view_data, .group_view_data { color: #000000 !important; } -.group_view_data_unk { +.group_view_data_unk * { color: #303030 !important; } -.group_view_data_ok { +.group_view_data_ok * { color: #00C000 !important; } -.group_view_data_crit { +.group_view_data_crit * { color: #5C0000 !important; } -.group_view_data_alrm { +.group_view_data_alrm * { color: #5C1D00 !important; } -.group_view_data_warn { +.group_view_data_warn * { color: #5C5900 !important; } + +.group_view * { + text-shadow: none !important; + font-size: 12px !important; +} /*END-----------Groups styles-----------------------------------------*/ @@ -139,6 +145,20 @@ table#list_events th { } /*END-----------Events styles-----------------------------------------*/ +/*INIT-----------Agents styles----------------------------------------*/ +.red, .redb, .redi, .error { + color: #CC0000; +} + +.green { + color: #5A8629; +} + +.grey { + color: #808080; + font-weight: bold; +} +/*END-----------Agents styles-----------------------------------------*/ /*INIT---------Fix the square border in search input------------------*/ .ui-input-search { diff --git a/pandora_console/mobile/include/ui.class.php b/pandora_console/mobile/include/ui.class.php index 6c7b5d08ba..93c3389af3 100755 --- a/pandora_console/mobile/include/ui.class.php +++ b/pandora_console/mobile/include/ui.class.php @@ -717,6 +717,15 @@ class Table { $this->class_table = $class; } + public function setId($id = false) { + if (empty($id)) { + $this->id = uniqid(); + } + else { + $this->id = $id; + } + } + public function setRowClass($class = '', $pos = false) { if (is_array($class)) { $this->rowClass = $class; diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index 863ff3f32f..dd64898ad7 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -36,7 +36,16 @@ class User { public static function getInstance() { if (!(self::$instance instanceof self)) { - self::$instance = new self; + //Check if in the session + $system = System::getInstance(); + $user = $system->getSession('user', null); + + if (!empty($user)) { + self::$instance = $user; + } + else { + self::$instance = new self; + } } return self::$instance; @@ -182,7 +191,15 @@ class User { } public function getIdUser() { - return $this->user; + return $this->user; //Oldies methods + } + + public function isInGroup($access = "AR", $id_group = 0, $name_group = false) { + return (bool)check_acl($this->user, $id_group, $access); + } + + public function getIdGroups($access = "AR", $all = false) { + return array_keys(users_get_groups($this->user, $access, $all)); } } ?> diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 9d0bbc3229..1c8f703d66 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -30,17 +30,14 @@ require_once('operation/tactical.php'); require_once('operation/groups.php'); require_once('operation/events.php'); require_once('operation/alerts.php'); +require_once('operation/agents.php'); +require_once('operation/modules.php'); $enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); $system = System::getInstance(); -$user = $system->getSession('user', null); -if ($user == null) { - $user = User::getInstance(); -} -else { - $user->hackInjectConfig(); -} +$user = User::getInstance(); +$user->hackInjectConfig(); $action = $system->getRequest('action'); if (!$user->isLogged()) { @@ -57,6 +54,14 @@ switch ($action) { $events = new Events(); $events->ajax($parameter2); break; + case 'agents': + $agents = new Agents(); + $agents->ajax($parameter2); + break; + case 'modules': + $modules = new Modules(); + $modules->ajax($parameter2); + break; } return; break; @@ -102,6 +107,14 @@ switch ($action) { $alerts = new Alerts(); $alerts->show(); break; + case 'agents': + $agents = new Agents(); + $agents->show(); + break; + case 'modules': + $modules = new Modules(); + $modules->show(); + break; } break; } diff --git a/pandora_console/mobile/operation/agents.php b/pandora_console/mobile/operation/agents.php new file mode 100644 index 0000000000..2b83222619 --- /dev/null +++ b/pandora_console/mobile/operation/agents.php @@ -0,0 +1,375 @@ +list_status = array( + -1 => __('All'), + AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'), + AGENT_MODULE_STATUS_CRITICAL_ALERT => __('Alert'), + AGENT_MODULE_STATUS_NORMAL => __('Normal'), + AGENT_MODULE_STATUS_WARNING => __('Warning'), + AGENT_MODULE_STATUS_UNKNOW => __('Unknow')); + + if ($system->checkACL($this->acl)) { + $this->correct_acl = true; + } + else { + $this->correct_acl = false; + } + } + + public function ajax($parameter2 = false) { + $system = System::getInstance(); + + if (!$this->correct_acl) { + return; + } + else { + switch ($parameter2) { + case 'get_agents': + $this->getFilters(); + $page = $system->getRequest('page', 0); + + $agents = array(); + $end = 1; + + $listAgents = $this->getListAgents($page, true); + + if (!empty($listAgents['agents'])) { + $end = 0; + $agents = $listAgents['agents']; + } + + echo json_encode(array('end' => $end, 'agents' => $agents)); + break; + } + } + } + + private function getFilters() { + $system = System::getInstance(); + $user = User::getInstance(); + + $this->free_search = $system->getRequest('free_search', ''); + if ($this->free_search != '') { + $this->default = false; + } + + $this->status = $system->getRequest('status', __("Status")); + if (($this->status === __("Status")) || ($this->status == -1)) { + $this->status = -1; + } + else { + $this->default = false; + } + + $this->group = (int)$system->getRequest('group', __("Group")); + if (!$user->isInGroup($this->acl, $this->group)) { + $this->group = 0; + } + if (($this->group === __("Group")) || ($this->group == 0)) { + $this->group = 0; + } + else { + $this->default = false; + } + } + + public function show() { + if (!$this->correct_acl) { + $this->show_fail_acl(); + } + else { + $this->getFilters(); + $this->show_agents(); + } + } + + private function show_fail_acl() { + $ui = Ui::getInstance(); + + $ui->createPage(); + + $options['type'] = 'onStart'; + $options['title_text'] = __('You don\'t have access to this page'); + $options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.

Please know that all attempts to access this page are recorded in security logs of Pandora System Database'); + $ui->addDialog($options); + + $ui->showPage(); + } + + private function show_agents() { + $ui = Ui::getInstance(); + + $ui->createPage(); + $ui->createDefaultHeader(__("PandoraFMS: Agents")); + $ui->showFooter(false); + $ui->beginContent(); + $filter_title = sprintf(__('Filter Agents by %s'), + $this->filterEventsGetString()); + $ui->contentBeginCollapsible($filter_title); + $ui->beginForm("index.php?page=agents"); + $system = System::getInstance(); + $groups = users_get_groups_for_select( + $system->getConfig('id_user'), "AR", true, true, false, 'id_grupo'); + $options = array( + 'name' => 'group', + 'title' => __('Group'), + 'label' => __('Group'), + 'items' => $groups, + 'selected' => $this->group + ); + $ui->formAddSelectBox($options); + + $options = array( + 'name' => 'status', + 'title' => __('Status'), + 'label' => __('Status'), + 'items' => $this->list_status, + 'selected' => $this->status + ); + $ui->formAddSelectBox($options); + + $options = array( + 'name' => 'free_search', + 'value' => $this->free_search, + 'placeholder' => __('Free search') + ); + $ui->formAddInputSearch($options); + + $options = array( + 'icon' => 'refresh', + 'icon_pos' => 'right', + 'text' => __('Apply Filter') + ); + $ui->formAddSubmitButton($options); + $html = $ui->getEndForm(); + $ui->contentCollapsibleAddItem($html); + $ui->contentEndCollapsible(); + $this->listAgentsHtml(); + $ui->endContent(); + $ui->showPage(); + } + + private function getListAgents($page = 0, $ajax = false) { + $system = System::getInstance(); + + $total = 0; + $agents = array(); + + $search_sql = ''; + if (!empty($this->free_search)) { + $search_sql = " AND ( + nombre COLLATE utf8_general_ci LIKE '%" . $this->free_search . "%' + OR direccion LIKE '%" . $this->free_search . "%' + OR comentarios LIKE '%" . $this->free_search . "%') "; + } + + $total = agents_get_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status), + array ('COUNT(*) AS total'), 'AR', false); + $total = isset($total[0]['total']) ? $total[0]['total'] : 0; + + $order = array('field' => 'nombre COLLATE utf8_general_ci', + 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + $agents_db = agents_get_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status, + 'offset' => (int) $page * $system->getPageSize(), + 'limit' => (int) $system->getPageSize()), + array ('id_agente', + 'id_grupo', + 'id_os', + 'nombre', + 'ultimo_contacto', + 'intervalo', + 'comentarios description', + 'quiet', + 'normal_count', + 'warning_count', + 'critical_count', + 'unknown_count', + 'notinit_count', + 'total_count', + 'fired_count'), + 'AR', $order); + + if (empty($agents_db)) + $agents_db = array(); + + foreach ($agents_db as $agent) { + $row = array(); + + $row[0] = $row[__('Agent')] = io_safe_output($agent['nombre']); + $row[1] = $row[__('Description')] = ui_print_truncate_text($agent["description"], 'description', false, true); + $row[2] = $row[__('OS')] = ui_print_os_icon ($agent["id_os"], false, true); + $row[3] = $row[__('Interval')] = human_time_description_raw($agent["intervalo"]); + $row[4] = $row[__('Group')] = ui_print_group_icon ($agent["id_grupo"], true); + $row[5] = $row[__('Modules')] = reporting_tiny_stats($agent, true); + $row[6] = $row[__('Status')] = agents_tree_view_status_img ($agent["critical_count"], + $agent["warning_count"], $agent["unknown_count"]); + $row[7] = $row[__('Alerts')] = agents_tree_view_alert_img ($agent["fired_count"]); + $last_time = strtotime ($agent["ultimo_contacto"]); + $now = time (); + $diferencia = $now - $last_time; + $time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt')); + $style = ''; + if ($diferencia > ($agent["intervalo"] * 2)) + $row[8] = $row[__('Last contact')] = ''.$time.''; + else + $row[8] = $row[__('Last contact')] = $time; + + if (!$ajax) { + unset($row[0]); + unset($row[1]); + unset($row[2]); + unset($row[3]); + unset($row[4]); + unset($row[5]); + unset($row[6]); + unset($row[7]); + unset($row[8]); + } + + $agents[$agent['id_agente']] = $row; + + } + + return array('agents' => $agents, 'total' => $total); + } + + private function listAgentsHtml($page = 0) { + $system = System::getInstance(); + $ui = Ui::getInstance(); + + $listAgents = $this->getListAgents($page); + + if ($listAgents['total'] == 0) { + $ui->contentAddHtml('

' . __('No agents') . '

'); + } + else { + $table = new Table(); + $table->id = 'list_agents'; + $table->importFromHash($listAgents['agents']); + $ui->contentAddHtml($table->getHTML()); + + if ($system->getPageSize() < $listAgents['total']) { + $ui->contentAddHtml('
' . + html_print_image('images/spinner.gif', true) . + ' ' . __('Loading...') . + '
'); + + $this->addJavascriptAddBottom(); + } + } + } + + private function addJavascriptAddBottom() { + $ui = Ui::getInstance(); + + $ui->contentAddHtml(""); + } + + private function filterEventsGetString() { + if ($this->default) { + return __("(Default)"); + } + else { + $status = $this->list_status[$this->status]; + $group = groups_get_name($this->group, true); + + + $string = sprintf( + __("(Status: %s - Group: %s - Free Search: %s)"), + $status, $group, $this->free_search); + + return $string; + } + } +} + +?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/agents/group_view.php b/pandora_console/mobile/operation/agents/group_view.php deleted file mode 100644 index 98a9021d6a..0000000000 --- a/pandora_console/mobile/operation/agents/group_view.php +++ /dev/null @@ -1,86 +0,0 @@ -system = $system; - } - - public function show() { - $groups = users_get_groups ($this->system->getConfig('id_user')); - - $table = null; - $table->width = '100%'; - - $table->align = array(); - for($i = 0; $i <= 8; $i++) { - $table->align[$i] = 'center'; - } - - $table->head = array(); - $table->head[0] = ' '; -// $table->head[1] = '' . __('T') . ''; -// $table->head[2] = '' . __('A') . ''; - $table->head[3] = '' . __('Unk') . ''; -// $table->head[4] = '' . __('N') . ''; - $table->head[5] = '' . __('Nor') . ''; -// $table->head[6] = '' . __('W') . ''; -// $table->head[7] = '' . __('C') . ''; - $table->head[8] = '' . __('Aler') . ''; - - $rowPair = false; - $iterator = 0; - foreach ($groups as $idGroup => $group) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - if ($idGroup == 0) continue; //avoid the all group - $groupData = reporting_get_group_stats($idGroup); - - if ($groupData['total_agents'] == 0) continue; //avoid the empty groups - - $data = array(); - - $groupName = groups_get_name($idGroup); - - $data[] = '' . $groupName . ''; -// $data[] = $groupData['total_agents']; -// $data[] = $groupData['agents_unknown']; - $data[] = $groupData['monitor_unknown']; -// $data[] = $groupData['monitor_not_init']; - $data[] = $groupData["monitor_ok"]; -// $data[] = $groupData["monitor_warning"]; -// $data[] = $groupData["monitor_critical"]; - $data[] = $groupData["monitor_alerts_fired"]; - - $table->data[] = $data; - } - - html_print_table($table); - } -} -?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/agents/monitor_status.php b/pandora_console/mobile/operation/agents/monitor_status.php deleted file mode 100644 index a4223c48a3..0000000000 --- a/pandora_console/mobile/operation/agents/monitor_status.php +++ /dev/null @@ -1,249 +0,0 @@ -system = $system; - $this->user = $user; - - $this->offset = $this->system->getRequest("offset", 0); - } - - public function show() { - global $config; - require_once ($config['homedir'].'/include/functions_users.php'); - require_once ($config['homedir'].'/include/functions_modules.php'); - - - $config['text_char_long'] = 12; - - $group = $this->system->getRequest("group", 0); //0 = all - $modulegroup = $this->system->getRequest("modulegroup", 0); //0 = all - $status = $this->system->getRequest("status", -1); //-1 = all - $search = $this->system->getRequest('filter_text', ''); - - $table = null; - $table->width = '100%'; - $table->colspan[1][2] = 2; - - $table->data[0][0] = '' . __('G') . ''; - $table->data[0][1] = html_print_select_groups($this->system->getConfig("id_user"), "IR", true, 'group', $group, '', '', 0, true, false, false, 'w130'); - $table->data[0][2] = '' . __('M') . ''; - $fields = array (); - $fields[-1] = __('All'); - $fields[0] = __('Normal'); - $fields[1] = __('Warning'); - $fields[2] = __('Critical'); - $fields[3] = __('Unknown'); - $fields[4] = __('Not normal'); //default - $fields[5] = __('Not init'); - foreach ($fields as $key => $field) { - $fields[$key] = ui_print_truncate_text($field, GENERIC_SIZE_TEXT, false, true, false); - } - $table->data[0][3] = html_print_select ($fields, "status", $status, '', '', -1, true); - $table->data[1][0] = '' . __('M') . ''; - $table->data[1][1] = html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", - 'module_group', $modulegroup, '',__('All'), 0, true); - $table->data[1][2] = html_print_input_text('search', $search, '', 5, 20, true); - $table->data[1][2] .= ""; - - echo "
"; - html_print_table($table); - echo "
"; - - - - - // Agent group selector - if (($group > 0) && (check_acl($system->getConfig('id_user'), $group, "AR"))) { - $sqlGroup = sprintf (" AND tagente.id_grupo = %d", $ag_group); - } - else { - $user_groups_all = users_get_groups ($this->user->getIdUser(), "AR"); - $user_groups = array_keys ($user_groups_all); - $user_groupsText = implode(',', $user_groups); - - // User has explicit permission on group 1 ? - $sqlGroup = " AND tagente.id_grupo IN (" . $user_groupsText . ")"; - } - - - - // Status selector - $sqlStatus = ''; - if ($status == 0) { //Normal - $sqlStatus = " AND tagente_estado.estado = 0 - AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) "; - } - elseif ($status == 2) { //Critical - $sqlStatus = " AND tagente_estado.estado = 1 AND utimestamp > 0"; - } - elseif ($status == 1) { //Warning - $sqlStatus = " AND tagente_estado.estado = 2 AND utimestamp > 0"; - } - elseif ($status == 4) { //Not normal - $sqlStatus = " AND tagente_estado.estado <> 0"; - } - elseif ($status == 3) { //Unknown - $sqlStatus = " AND tagente_estado.estado = 3"; - } - elseif ($status == 5) { //Not init - $sqlStatus = " AND tagente_estado.utimestamp = 0 - AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)"; - } - - - - // Module group - $sqlModuleGroup = ''; - if ($modulegroup > 0) { - $sqlModuleGroup = sprintf (" AND tagente_modulo.id_module_group = '%d'", $modulegroup); - } - - - // Freestring selector - $sqlFreeSearch = ''; - if ($search != "") { - $sqlFreeSearch = sprintf (" AND (tagente.nombre LIKE '%%%s%%' OR tagente_modulo.nombre LIKE '%%%s%%' OR tagente_modulo.descripcion LIKE '%%%s%%')", $search, $search, $search); - } - - - $selectSQL = 'SELECT tagente_modulo.id_agente_modulo, - tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, - tagente_modulo.nombre AS module_name, - tagente_modulo.id_agente_modulo, tagente_modulo.history_data, - tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, - tagente.id_agente AS id_agent, - tagente_modulo.id_tipo_modulo AS module_type, - tagente_modulo.module_interval, tagente_estado.datos, - tagente_estado.estado, tagente_estado.utimestamp AS utimestamp'; - - $sql = ' FROM tagente, tagente_modulo, tagente_estado - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.disabled = 0 - AND tagente.disabled = 0 - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - ' . $sqlGroup . ' - ' . $sqlStatus . ' - ' . $sqlModuleGroup . ' - ' . $sqlFreeSearch . ' - ORDER BY tagente.id_grupo, tagente.nombre'; - - $total = db_get_value_sql('SELECT COUNT(*) ' . $sql); - - - switch ($config["dbtype"]) { - case "mysql": - $rows = db_get_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->offset . ', ' . $this->system->getPageSize()); - break; - case "postgresql": - $rows = db_get_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset); - break; - case "oracle": - $set = array(); - $set['limit'] = $this->system->getPageSize(); - $set['offset'] = $this->offset; - $rows = oracle_recode_query ($selectSQL . $sql, $set, 'AND', true); - break; - } - - if ($rows === false) $rows = array(); - - if ($config["dbtype"] == 'oracle') { - for ($i=0; $i < count($rows); $i++) { - unset($rows[$i]['rnum']); - } - } - - $table = null; - $table->width = '100%'; - - $table->data = array(); - $rowPair = false; - $iterator = 0; - foreach ($rows as $row) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $data = array(); - - if($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)) { - $statusImg = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); - } - elseif ($row["estado"] == 0) { - $statusImg = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); - } - elseif ($row["estado"] == 1) { - $statusImg = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); - } - elseif ($row["estado"] == 2) { - $statusImg = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); - } - else { - $last_status = modules_get_agentmodule_last_status($row['id_agente_modulo']); - switch($last_status) { - case 0: - $statusImg = ui_print_status_image(STATUS_MODULE_OK, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); - break; - case 1: - $statusImg = ui_print_status_image(STATUS_MODULE_CRITICAL, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); - break; - case 2: - $statusImg = ui_print_status_image(STATUS_MODULE_WARNING, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); - break; - } - } - - $data[] = str_replace('' . - ui_print_truncate_text($row['agent_name'], 'agent_small', true, true) . ''; - $data[] = '' . - ui_print_truncate_text($row['module_name'], 'module_small', true, true) . ''; - if (is_numeric($row["datos"])) - $data[] = format_numeric($row["datos"]); - else - $data[] = "" . - substr(io_safe_output($row["datos"]),0,12).""; - - $data[] = ui_print_timestamp ($row["utimestamp"], true, array('units' => 'tiny')); - - $table->data[] = $data; - } - - html_print_table($table); - - $pagination = pagination ($total, - ui_get_url_refresh (array ()), - 0, 0, true); - - $pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination); - $pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination); - $pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination); - $pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination); - - echo $pagination; - } -} -?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/agents/tactical.php b/pandora_console/mobile/operation/agents/tactical.php deleted file mode 100644 index d88cc8c238..0000000000 --- a/pandora_console/mobile/operation/agents/tactical.php +++ /dev/null @@ -1,119 +0,0 @@ -system = $system; - } - - function show() { - global $config; - - require_once ($config["homedir"] . '/include/functions_graph.php'); - - $data = reporting_get_group_stats(); - - $table = null; - //$table->width = '100%'; - - $table->size[0] = '10px'; - - $table->align[0] = 'center'; - $table->align[3] = 'right'; - - $table->colspan = array(); - $table->colspan[0][0] = 2; - $table->colspan[0][1] = 2; - - $table->data[0][0] = "

" . __('Status') . "

" ; - $table->data[1][0] = '' . __('G') . ' '; - $table->data[1][1] = - str_replace('include', '../include', progress_bar($data["global_health"], 70, 8, '', 0)); - $table->data[2][0] = '' . __('M') . ' '; - $table->data[2][1] = - str_replace('include', '../include', progress_bar($data["monitor_health"], 70, 8, '', 0)); - $table->data[3][0] = '' . __('M') . ' '; - $table->data[3][1] = - str_replace('include', '../include', progress_bar($data["module_sanity"], 70, 8, '', 0)); - $table->data[4][0] = '' . __('A') . ' '; - $table->data[4][1] = - str_replace('include', '../include', progress_bar($data["alert_level"], 70, 8, '', 0)); - $table->data[5][0] = $table->data[5][1] = ''; - $table->data[6][0] = $table->data[6][1] = ''; - $table->data[7][0] = $table->data[7][1] = ''; - $table->data[8][0] = $table->data[8][1] = ''; - - $table->data[0][1] = "

" . __('Monitor checks') . "

"; - $table->data[1][2] = '' . __('Monitor checks') . ''; - $table->data[1][3] = '' . $data["monitor_checks"] . ''; - $table->data[2][2] = '' . __('Monitors critical') . ''; - $table->data[2][3] = '' . $data["monitor_critical"] . ''; - $table->data[3][2] = '' . __('Monitors warning') .''; - $table->data[3][3] = '' . $data["monitor_warning"] . ''; - $table->data[4][2] = '' . __('Monitors normal') . ''; - $table->data[4][3] = '' . $data["monitor_ok"] . ''; - $table->data[5][2] = '' . __('Monitors unknown') . ''; - $table->data[5][3] = '' . $data["monitor_unknown"] . ''; - $table->data[6][2] = '' . __('Monitors not init') . ''; - $table->data[6][3] = '' . $data["monitor_not_init"] . ''; - $table->data[7][2] = '' . __('Alerts defined') . ''; - $table->data[7][3] = '' . $data["monitor_alerts"] . ''; - $table->data[8][2] = '' . __('Alerts fired') . ''; - $table->data[8][3] = '' . $data["monitor_alerts_fired"] . ''; - - html_print_table($table); - - echo "

" . __('Server performance') . "

"; - - $server_performance = servers_get_performance(); - - $table = null; - //$table->width = '100%'; - - $table->align = array(); - $table->align[1] = 'right'; - - $table->data[0][0] = '' . __('Local modules rate') . ''; - $table->data[0][1] = '' . format_numeric($server_performance ["local_modules_rate"]) . ''; - $table->data[1][0] = '' . __('Remote modules rate') . ''; - $table->data[1][1] = '' . format_numeric($server_performance ["remote_modules_rate"]) . ''; - $table->data[2][0] = '' . __('Local modules') . ''; - $table->data[2][1] = '' . format_numeric($server_performance ["total_local_modules"]) . ''; - $table->data[3][0] = '' . __('Remote modules') . ''; - $table->data[3][1] = '' . format_numeric($server_performance ["total_remote_modules"]) . ''; - $table->data[4][0] = '' . __('Total running modules') . ''; - $table->data[4][1] = '' . format_numeric($server_performance ["total_modules"]) . ''; - - html_print_table($table); - - echo "

" . __('Summary') . "

"; - - $table = null; - //$table->width = '100%'; - $table->align[1] = 'right'; - $table->data[0][0] = '' . __('Total agents') . ''; - $table->data[0][1] = '' . $data["total_agents"] . ''; - $table->data[1][0] = '' . __('Uninitialized modules') . ''; - $table->data[1][1] = '' . $data["server_sanity"] . ''; - $table->data[2][0] = '' . __('Agents unknown') . ''; - $table->data[2][1] = '' . $data["agents_unknown"] . ''; - - html_print_table($table); - } -} -?> diff --git a/pandora_console/mobile/operation/agents/view_agents.php b/pandora_console/mobile/operation/agents/view_agents.php deleted file mode 100644 index b11f831531..0000000000 --- a/pandora_console/mobile/operation/agents/view_agents.php +++ /dev/null @@ -1,554 +0,0 @@ -user = $user; - $this->system = $system; - $this->filterText = $this->system->getRequest('filter_text', ''); - $this->filterGroup = $this->system->getRequest('filter_group', 0); - } - - private function showForm() { - echo "
"; - html_print_input_hidden('page', 'agents'); - global $config; - $config['text_char_long'] = 12; - html_print_select_groups($this->user->getIdUser(), "AR", true, 'filter_group', $this->filterGroup); - html_print_input_text('filter_text', $this->filterText, __('Free text search'), 5, 20); - echo ""; - echo ""; - } - - public function show() { - $this->showForm(); - - // Show only selected groups - if ($this->filterGroup > 0) { - $groups = $this->filterGroup; - $agent_names = agents_get_group_agents ($this->filterGroup, array('string' => $this->filterText), "upper"); - // Not selected any specific group - } - else { - $user_group = users_get_groups ($this->user->getIdUser(), "AR"); - $groups = array_keys ($user_group); - $agent_names = agents_get_group_agents (array_keys ($user_group), array('string' => $this->filterText), "upper"); - } - - $total_agents = agents_get_agents (array('id_agente' => array_keys ($agent_names), - 'order' => 'nombre ASC', - 'disabled' => 0, - 'id_grupo' => $groups), - array ('COUNT(*) as total')); - $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; - - $agents = agents_get_agents(array('id_agente' => array_keys ($agent_names), - 'order' => 'nombre ASC', - 'id_grupo' => $groups, - 'offset' => (int) get_parameter ('offset'), - 'limit' => (int) $this->system->getPageSize()), array('id_agente', 'nombre', 'id_grupo')); - - $table = null; - - $table->width = '100%'; - - $table->align = array(); - $table->align[0] = 'center'; - $table->align[2] = 'center'; - $table->align[3] = 'center'; - $table->align[4] = 'center'; - - $table->head = array(); - $table->head[0] = '' . __('G') . ''; - $table->head[1] = __('Name'); - $table->head[2] = '' . __('M') . ''; - $table->head[3] = '' . __('S') . ''; - $table->head[4] = '' . __('A') . ''; - - $table->data = array(); - - if ($agents === false) $agents = array(); - - $iterator = 0; - $rowPair = false; - foreach ($agents as $agent) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $agent_info = reporting_get_agent_module_info ($agent["id_agente"]); //$this->system->debug($agent_info); - - $data = array(); - - $truncName = ui_print_truncate_text($agent['nombre'], 'agent_small', true, true); - - $data[] = ui_print_group_icon_path($agent["id_grupo"], true, "../images/groups_small", '', false); - $data[] = '' . $truncName . ''; - - $moduleInfo = ''; - $moduleInfo .= $agent_info["modules"]; - if ($agent_info["monitor_alertsfired"] > 0) - $moduleInfo .= ' : '.$agent_info["monitor_alertsfired"].''; - if ($agent_info["monitor_critical"] > 0) - $moduleInfo .= ' : '.$agent_info["monitor_critical"].''; - if ($agent_info["monitor_warning"] > 0) - $moduleInfo .= ' : '.$agent_info["monitor_warning"].''; - if ($agent_info["monitor_unknown"] > 0) - $moduleInfo .= ' : '.$agent_info["monitor_unknown"].''; - if ($agent_info["monitor_normal"] > 0) - $moduleInfo .= ' : '.$agent_info["monitor_normal"].''; - $moduleInfo .= ''; - - $data[] = $moduleInfo; - $data[] = ''; - $data[] = ''; - - - $table->data[] = $data; - } - - html_print_table($table); - - $pagination = pagination ($total_agents, - ui_get_url_refresh (array ('filter_group' => $this->filterGroup, 'filter_group' => $this->filterGroup)), - 0, 0, true); - - $pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination); - $pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination); - $pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination); - $pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination); - - echo $pagination; - } -} - -class ViewAgent { - private $idAgent; - private $sytem; - private $agent; - - private $name; - private $os; - private $ips; - private $modules; - - public function __construct() { - global $system; - - $this->system = $system; - - $this->idAgent = $this->system->getRequest('id', 0); - $this->agent = db_get_row_filter('tagente', array('id_agente' => $this->idAgent)); - - $this->ips = agents_get_addresses($this->idAgent); - } - - public function show() { - $idGroup = $this->agent['id_grupo']; - if (! check_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) { - db_pandora_audit("ACL Violation", - "Trying to access (read) to agent ".agents_get_name($this->idAgent)); - include ("../general/noaccess.php"); - return; - } - - $table = null; - - $table->width = '100%'; - - $table->style[0] = 'font-weight: bolder;'; - - $table->data[0][0] = __('Name:'); - $table->data[0][1] = $this->agent['nombre']; - $table->data[1][0] = __('IP:'); - $table->data[1][1] = implode(',', $this->ips); - $table->data[2][0] = __('OS:'); - $table->data[2][1] = str_replace('images/os_icons/', '../images/os_icons/', ui_print_os_icon($this->agent['id_os'], true, true)); - $table->data[3][0] = __('Last contact'); - $table->data[3][1] = $this->agent['ultimo_contacto']; - - html_print_table($table); - - $sql = sprintf (" - SELECT * - FROM tagente_estado, tagente_modulo - LEFT JOIN tmodule_group - ON tmodule_group.id_mg = tagente_modulo.id_module_group - WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.id_agente = %d - AND tagente_modulo.disabled = 0 - AND tagente_modulo.delete_pending = 0 - AND tagente_estado.utimestamp != 0 - ORDER BY tagente_modulo.id_module_group , tagente_modulo.nombre ASC - ", $this->idAgent); - - $modules = db_get_all_rows_sql ($sql); - if (empty ($modules)) { - $modules = array (); - } - - echo "

" . __('Modules') . "

"; - - $table = null; - //$table->width = '100%'; - $table->head = array(); - $table->head[0] = __('Module'); - $table->head[1] = '' . __('S') . ''; - $table->head[2] = __('Data'); - $table->head[3] = '' . __('L') . ''; - - $table->data = array(); - - $iterator = 0; - $rowPair = false; - foreach ($modules as $module) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $data = array(); - - $data[] = '' . - ui_print_truncate_text($module["nombre"], 'module_small', true, true) . ''; - $status = STATUS_MODULE_WARNING; - $title = ""; - - if ($module["estado"] == 1) { - $status = STATUS_MODULE_CRITICAL; - $title = __('CRITICAL'); - } - elseif ($module["estado"] == 2) { - $status = STATUS_MODULE_WARNING; - $title = __('WARNING'); - } - elseif ($module["estado"] == 0) { - $status = STATUS_MODULE_OK; - $title = __('NORMAL'); - } - elseif ($module["estado"] == 3) { - $last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']); - switch($last_status) { - case 0: - $status = STATUS_MODULE_OK; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL'); - break; - case 1: - $status = STATUS_MODULE_CRITICAL; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL'); - break; - case 2: - $status = STATUS_MODULE_WARNING; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING'); - break; - } - } - - if (is_numeric($module["datos"])) { - $title .= ": " . format_for_graph($module["datos"]); - } - else { - $title .= ": " . substr(io_safe_output($module["datos"]),0,42); - } - - $data[] = str_replace(array('images/status_sets', '".substr(io_safe_output($module["datos"]),0,12).""; - } - } - $data[] = $salida; - if ($module['estado'] == 3) { - $lastTime = ''; - } - else { - $lastTime = ''; - } - $lastTime .= ui_print_timestamp ($module["utimestamp"], true, array('units' => 'tiny')); - $lastTime .= ''; - $data[] = $lastTime; - - - $table->data[] = $data; - } - - html_print_table($table); - - $table->head = array(); - $table->head[0] = __('Module'); - $table->head[1] = __('Template'); - $table->head[2] = '' . __('Last') . ''; - $table->head[3] = '' . __('S') . ''; - - - $table->align = array(); - $table->align[3] = 'right'; - $table->align[2] = 'center'; - $table->data = array(); - $table->rowclass = array(); - - echo "

" . __('Alerts') . "

"; - $alertsSimple = agents_get_alerts_simple (array($this->idAgent)); - $rowPair = false; - $iterator = 0; - foreach ($alertsSimple as $alert) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $data = array(); - - $data[] = ui_print_truncate_text(modules_get_agentmodule_name($alert["id_agent_module"]), 'module_small', true, true); - - $template = io_safe_output(alerts_get_alert_template ($alert['id_alert_template'])); - $data[] = ui_print_truncate_text(io_safe_output($template['name']), GENERIC_SIZE_TEXT, true, true); - - $data[] = ui_print_timestamp ($alert["last_fired"], true, array('units' => 'tiny')); - - $status = STATUS_ALERT_NOT_FIRED; - $title = ""; - - if ($alert["times_fired"] > 0) { - $status = STATUS_ALERT_FIRED; - $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); - } - elseif ($alert["disabled"] > 0) { - $status = STATUS_ALERT_DISABLED; - $title = __('Alert disabled'); - } - else { - $status = STATUS_ALERT_NOT_FIRED; - $title = __('Alert not fired'); - } - - $data[] = str_replace(array('images/status_sets', 'data[] = $data; - } - html_print_table($table); - } -} - -class viewGraph { - private $system; - private $idAgentModule; - - function __construct($idAgentModule = 0) { - global $system; - - $this->system = $system; - $this->idAgentModule = $idAgentModule; - $this->agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $this->idAgentModule)); - - $this->period = $this->system->getRequest('period', 86400); - $this->offset = $this->system->getRequest("offset", 0); - - $this->agent = db_get_row_filter('tagente', array('id_agente' => $this->agentModule['id_agente'])); - } - - function show() { - $idGroup = $this->agent['id_grupo']; - if (! check_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) { - db_pandora_audit("ACL Violation", - "Trying to access (read) to agent ".agents_get_name($this->idAgent)); - include ("../general/noaccess.php"); - return; - } - - echo "

" . modules_get_agentmodule_agent_name($this->idAgentModule)." / ".io_safe_output($this->agentModule['nombre']) . "

"; - - echo "

" . __('Graph') . "

"; - - echo grafico_modulo_sparse($this->idAgentModule, $this->period, 0, 240, - 200, io_safe_output($this->agentModule['nombre']), null, false, - false, true, 0, '', true, false, true, true, '../'); - - echo "

" . __('Data') . "

"; - - echo ""; - echo __("Choose period:"); - echo html_print_extended_select_for_time ('period', $this->period, 'this.form.submit();', '', '0', 5); - echo "
"; - - $moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($this->idAgentModule)); - - if ($moduletype_name == "log4x") { - $sql_body = sprintf ("FROM tagente_datos_log4x - WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period)); - - $columns = array( - - //"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ), - "Sev" => array("severity", "format_data", "align" => "center", "width" => "70px"), - "Message" => array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"), - "StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%") - ); - } - else if (preg_match ("/string/", $moduletype_name)) { - $sql_body = sprintf (" FROM tagente_datos_string - WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period)); - - $columns = array( - //"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center"), - "Data" => array("datos", "format_data", "align" => "center"), - "Time" => array("utimestamp", "modules_format_time", "align" => "center") - ); - } - else { - $sql_body = sprintf (" FROM tagente_datos - WHERE id_agente_modulo = %d AND utimestamp > %d - ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period)); - - $columns = array( - "Data" => array("datos", "format_data", "align" => "center"), - "Time" => array("utimestamp", "modules_format_time", "align" => "center") - ); - } - - $sql_count = 'SELECT COUNT(*) ' . $sql_body; - - $count = db_get_value_sql($sql_count); - - switch ($config["dbtype"]) { - case "mysql": - $sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->offset . ',' . $this->system->getPageSize(); - break; - case "postgresql": - $sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset; - break; - case "oracle": - $set = array(); - $set['limit'] = $this->system->getPageSize(); - $set['offset'] = $this->offset; - $sql = oracle_recode_query ('SELECT * ' . $sql_body, $set); - break; - } - - $result = db_get_all_rows_sql ($sql); - - if (($config["dbtype"] == 'oracle') && ($result !== false)) { - // Delete rnum row generated by oracle_recode_query() function - for ($i=0; $i < count($result); $i++) { - unset($result[$i]['rnum']); - } - } - - $table = null; - $table->width = '100%'; - $table->head = array(); - $index = 0; - foreach($columns as $col => $attr) { - $table->head[$index] = $col; - - if (isset($attr["align"])) - $table->align[$index] = $attr["align"]; - - if (isset($attr["width"])) - $table->size[$index] = $attr["width"]; - - $index++; - } - - $table->data = array(); //$this->system->debug($result); - $rowPair = false; - $iterator = 0; - foreach ($result as $row) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $data = array (); - - foreach($columns as $col => $attr) { - $data[] = $attr[1] ($row[$attr[0]]); - } - - array_push ($table->data, $data); - } - - html_print_table($table); - - $pagination = ui_pagination ($count, - ui_get_url_refresh (array ('period' => $this->period)), - 0, 0, true); - - $pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination); - $pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination); - $pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination); - $pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination); - - echo $pagination; - } -} -?> diff --git a/pandora_console/mobile/operation/agents/view_alerts.php b/pandora_console/mobile/operation/agents/view_alerts.php deleted file mode 100644 index d5a4ce5126..0000000000 --- a/pandora_console/mobile/operation/agents/view_alerts.php +++ /dev/null @@ -1,99 +0,0 @@ -system = $system; - } - - public function show() { - $table = null; - //$table->width = '100%'; - $table->head = array(); - $table->head[0] = __('Module'); - $table->head[1] = __('Template'); - $table->head[2] = __('Action'); - $table->head[2] = '' . __('Last') . ''; - $table->head[3] = '' . __('S') . ''; - - - $table->align = array(); - $table->align[3] = 'right'; - $table->align[2] = 'center'; - $table->data = array(); - $table->rowclass = array(); - - $groups = users_get_groups($this->system->getConfig('id_user')); - $idGroups = array_keys($groups); - $agents = agents_get_group_agents($idGroups); - $idAgents = array_keys($agents); - - $alertsSimple = agents_get_alerts_simple($idAgents); - - $rowPair = false; - $iterator = 0; - foreach ($alertsSimple as $alert) { - if ($rowPair) - $table->rowclass[$iterator] = 'rowPair'; - else - $table->rowclass[$iterator] = 'rowOdd'; - $rowPair = !$rowPair; - $iterator++; - - $data = array(); - - $idAgent = modules_get_agentmodule_agent($alert["id_agent_module"]); - - $data[] = '' . - ui_print_truncate_text(modules_get_agentmodule_name($alert["id_agent_module"]), 'module_small', true, true) . ''; - $template = io_safe_output(alerts_get_alert_template ($alert['id_alert_template'])); - $data[] = ui_print_truncate_text(io_safe_output($template['name']), GENERIC_SIZE_TEXT, true, true); - $data[] = ui_print_timestamp ($alert["last_fired"], true, array('units' => 'tiny')); - - $status = STATUS_ALERT_NOT_FIRED; - $title = ""; - - if ($alert["times_fired"] > 0) { - $status = STATUS_ALERT_FIRED; - $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); - } - elseif ($alert["disabled"] > 0) { - $status = STATUS_ALERT_DISABLED; - $title = __('Alert disabled'); - } - else { - $status = STATUS_ALERT_NOT_FIRED; - $title = __('Alert not fired'); - } - - $data[] = str_replace(array('images/status_sets', 'data[] = $data; - } - - html_print_table($table); - } -} -?> diff --git a/pandora_console/mobile/operation/alerts.php b/pandora_console/mobile/operation/alerts.php index bc2624bbf7..7f1cf123e8 100644 --- a/pandora_console/mobile/operation/alerts.php +++ b/pandora_console/mobile/operation/alerts.php @@ -14,6 +14,7 @@ class Alerts { private $correct_acl = false; + private $acl = "LM"; private $default = true; @@ -40,7 +41,7 @@ class Alerts { $system = System::getInstance(); - if ($system->checkACL("LM")) { + if ($system->checkACL($this->acl)) { $this->correct_acl = true; } else { @@ -50,6 +51,7 @@ class Alerts { private function alertsGetFilters() { $system = System::getInstance(); + $user = User::getInstance(); $this->free_search = $system->getRequest('free_search', ''); if ($this->free_search != '') { @@ -65,7 +67,10 @@ class Alerts { } $this->group = $system->getRequest('group', __("Group")); - if ($this->group === __("Group")) { + if (!$user->isInGroup($this->acl, $this->group)) { + $this->group = 0; + } + if (($this->group === __("Group")) || ($this->group == 0)) { $this->group = 0; } else { @@ -195,6 +200,8 @@ class Alerts { $alerts = alerts_get_alerts($this->group, $this->free_search, $this->status, $this->standby, "LM"); + if (empty($alerts)) + $alerts = array(); $table = array(); foreach ($alerts as $alert) { @@ -220,7 +227,7 @@ class Alerts { $row = array(); $row[__('Agent')] = sprintf($disabled_style, - '' . io_safe_output($alert['agent_name'])) . ''; + '' . io_safe_output($alert['agent_name'])) . ''; $row[__('Module')] = sprintf($disabled_style, io_safe_output($alert['module_name'])); $row[__('Template')] = sprintf($disabled_style, diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php index dd42bcc914..a63240f6e1 100644 --- a/pandora_console/mobile/operation/events.php +++ b/pandora_console/mobile/operation/events.php @@ -14,6 +14,7 @@ class Events { private $correct_acl = false; + private $acl = "ER"; private $default = true; private $free_search = ''; @@ -27,7 +28,7 @@ class Events { function __construct() { $system = System::getInstance(); - if ($system->checkACL("ER")) { + if ($system->checkACL($this->acl)) { $this->correct_acl = true; } else { @@ -240,6 +241,7 @@ class Events { private function eventsGetFilters() { $system = System::getInstance(); + $user = User::getInstance(); $this->hours_old = $system->getRequest('hours_old', 8); if ($this->hours_old != 8) { @@ -268,6 +270,9 @@ class Events { } $this->group = $system->getRequest('group', __("Group")); + if (!$user->isInGroup($this->acl, $this->group)) { + $this->group = 0; + } if (($this->group === __("Group")) || ($this->group == 0)) { $this->group = 0; } @@ -390,7 +395,7 @@ class Events { $ui->beginContent(); $ui->contentAddHtml(""); $ui->contentAddHtml(""); - //$test = "javascript: $(\"#test\").click();"; + $filter_title = sprintf(__('Filter Events by %s'), $this->filterEventsGetString()); $ui->contentBeginCollapsible($filter_title); $ui->beginForm("index.php?page=events"); @@ -614,7 +619,8 @@ class Events { $row[$field_status] = ''; } $row[$field_timestamp] = ui_print_timestamp ($event['timestamp_rep'], true); - $row[$field_agent] = ui_print_agent_name ($event["id_agente"], true); + $row[$field_agent] = '' . + (string) agents_get_name($event["id_agente"]) . ''; $events[$event['id_evento']] = $row; @@ -629,7 +635,6 @@ class Events { $table->id = 'list_events'; $table->setRowClass($row_class); $table->importFromHash($events); - $ui->debug($events, true); $ui->contentAddHtml($table->getHTML()); if ($system->getPageSize() < $total_events) { diff --git a/pandora_console/mobile/operation/events/events.php b/pandora_console/mobile/operation/events/events.php deleted file mode 100644 index 4cf5582a42..0000000000 --- a/pandora_console/mobile/operation/events/events.php +++ /dev/null @@ -1,211 +0,0 @@ -system = $system; - } - - function show() { - global $config; - - require_once ($config['homedir'].'/include/functions_agents.php'); - - $config['text_char_long'] = 12; - - $offset = $this->system->getRequest("offset", 0); - $ev_group = $this->system->getRequest("ev_group", 0); //0 = all - $event_type = get_parameter ("event_type", ''); // 0 all - $severity = $this->system->getRequest("severity", -1); // -1 all - $search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode ($this->system->getRequest("search", ''))); - - $event_view_hr = 24; //Last day of events - - $types = get_event_types(); - // Expand standard array to add not_normal (not exist in the array, used only for searches) - $types["not_normal"] = __("Not normal"); - - - $table = null; - $table->width = '100%'; - - $table->colspan[1][2] = 2; - - $table->data[0][0] = '' . __('G') . ''; - $table->data[0][1] = html_print_select_groups($this->system->getConfig("id_user"), "IR", true, 'ev_group', $ev_group, '', '', 0, true, false, false, 'w130'); - $table->data[0][2] = '' . __('E') . ''; - $table->data[0][3] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true); - $table->data[1][0] = '' . __('S') . ''; - $table->data[1][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true); - $table->data[1][2] = html_print_input_text('search', $search, '', 5, 20, true); - $table->data[1][2] .= ""; - - echo "
"; - html_print_table($table); - echo "
"; - - - $groups = users_get_groups ($this->system->getConfig("id_user"), "IR"); - $sqlGroups = ''; - //Group selection - if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) { - //If a group is selected and it's in the groups allowed - $sqlGroups = " AND id_grupo = $ev_group"; - } - else { - if (is_user_admin ($this->system->getConfig("id_user"))) { - //Do nothing if you're admin, you get full access - $sqlGroups = ""; - } - else { - //Otherwise select all groups the user has rights to. - $sqlGroups = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; - } - } - - - $sqlEventType = ''; - if ($event_type != "") { - // If normal, warning, could be several (going_up_warning, going_down_warning... too complex - // for the user so for him is presented only "warning, critical and normal" - if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { - $sqlEventType = " AND event_type LIKE '%$event_type%' "; - } - elseif ($event_type == "not_normal") { - $sqlEventType = " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' "; - } - else { - $sqlEventType = " AND event_type = '".$event_type."'"; - } - - } - - - $sqlSeverity = ''; - if ($severity != -1) - $sqlSeverity = " AND criticity >= ".$severity; - - - $sqlFreeSearch = ''; - if ($search != "") - $sqlFreeSearch .= " AND evento LIKE '%".$search."%'"; - - $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds - $sqlTimestamp = " AND utimestamp > ".$unixtime; - - $sql = 'SELECT * - FROM tevento - WHERE 1=1 ' . $sqlGroups . $sqlEventType . $sqlSeverity . - $sqlFreeSearch . $sqlTimestamp . ' AND estado = 0 ORDER BY utimestamp DESC'; - - $sql_count = str_replace('*', 'COUNT(*)', $sql); - - switch ($config["dbtype"]) { - case "mysql": - $sql = $sql . sprintf(' LIMIT %d,%d', $offset, $this->system->getPageSize()); - break; - case "postgresql": - $sql = $sql . sprintf(' LIMIT %d OFFSET %d', $this->system->getPageSize(), $offset); - break; - case "oracle": - $set = array(); - $set['limit'] = $this->system->getPageSize(); - $set['offset'] = $offset; - $sql = oracle_recode_query ($sql, $set); - break; - } - - $count = db_get_value_sql($sql_count); - - $rows = db_get_all_rows_sql($sql); - if ($rows === false) - $rows = array(); - - - $table = null; - $table->width = '100%'; - $table->head = array(); - $table->head[3] = '' . __('T') . ''; - $table->head[4] = '' . __('Des.') . ''; - $table->head[5] = '' . __('Agent') . ''; - - $table->data = array(); - $iterator = 0; - foreach ($rows as $row) { - $data = array(); - - switch ($row["criticity"]) { - default: - case 0: - $img = "../images/status_sets/default/severity_maintenance_pixel.png"; - break; - case 1: - $img = "../images/status_sets/default/severity_informational_pixel.png"; - break; - case 2: - $img = "../images/status_sets/default/severity_normal_pixel.png"; - break; - case 3: - $img = "../images/status_sets/default/severity_warning_pixel.png"; - break; - case 4: - $img = "../images/status_sets/default/severity_critical_pixel.png"; - break; - } - - $table->rowclass[$iterator] = get_priority_class($row["criticity"]); - $iterator++; - - $data[] = ui_print_timestamp($row["timestamp"], true, array('units' => 'tiny')); - - $data[] = $row["evento"]; - - if ($row["event_type"] == "system") { - $data[] = ui_print_truncate_text(__('System'), GENERIC_SIZE_TEXT, true, true); - } - elseif ($row["id_agente"] > 0) { - // Agent name - $data[] = '' . - ui_print_truncate_text(agents_get_name($row["id_agente"]), 'agent_small', true, true) . ''; - } - else { - $data[] = ui_print_truncate_text(__('Alert SNMP'), GENERIC_SIZE_TEXT, true, true); - } - - $table->data[] = $data; - } - - html_print_table($table); - - $pagination = ui_pagination ($count, - ui_get_url_refresh(array("offset" => $offset, "ev_group" => $ev_group, - "event_type" => $event_type, "severity" => $severity, - "search" => $search)), 0, 0, true); - - $pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination); - $pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination); - $pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination); - $pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination); - - echo $pagination; - } -} -?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/modules.php b/pandora_console/mobile/operation/modules.php new file mode 100644 index 0000000000..e0d4def920 --- /dev/null +++ b/pandora_console/mobile/operation/modules.php @@ -0,0 +1,574 @@ +list_status = array( + -1 => __('All'), + AGENT_MODULE_STATUS_NORMAL => __('Normal'), + AGENT_MODULE_STATUS_WARNING => __('Warning'), + AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'), + AGENT_MODULE_STATUS_UNKNOW => __('Unknown'), + AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), //default + AGENT_MODULE_STATUS_NOT_INIT => __('Not init')); + + if ($system->checkACL($this->acl)) { + $this->correct_acl = true; + } + else { + $this->correct_acl = false; + } + } + + public function ajax($parameter2 = false) { + $system = System::getInstance(); + + if (!$this->correct_acl) { + return; + } + else { + switch ($parameter2) { + case 'get_modules': + $this->getFilters(); + $page = $system->getRequest('page', 0); + $modules = array(); + $end = 1; + + $listModules = $this->getListModules($page, true); + + if (!empty($listModules['modules'])) { + $end = 0; + $modules = $listModules['modules']; + } + + echo json_encode(array('end' => $end, 'modules' => $modules)); + break; + } + } + } + + private function getFilters() { + $system = System::getInstance(); + $user = User::getInstance(); + + $this->free_search = $system->getRequest('free_search', ''); + if ($this->free_search != '') { + $this->default = false; + } + + $this->status = $system->getRequest('status', __("Status")); + if (($this->status === __("Status")) || ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL)) { + $this->status = AGENT_MODULE_STATUS_NOT_NORMAL; + } + else { + $this->default = false; + } + + $this->group = (int)$system->getRequest('group', __("Group")); + if (!$user->isInGroup($this->acl, $this->group)) { + $this->group = 0; + } + if (($this->group === __("Group")) || ($this->group == 0)) { + $this->group = 0; + } + else { + $this->default = false; + } + + $this->module_group = (int)$system->getRequest('module_group', __("Module group")); + if (($this->module_group === __("Module group")) || ($this->module_group == -1) + || ($this->module_group == 0)) { + $this->module_group = -1; + } + else { + $this->default = false; + } + + $this->tag = (int)$system->getRequest('tag', __("Tag")); + if (($this->tag === __("Tag")) || ($this->tag == 0)) { + $this->tag = 0; + } + else { + $this->default = false; + } + } + + public function show() { + if (!$this->correct_acl) { + $this->show_fail_acl(); + } + else { + $this->getFilters(); + $this->show_modules(); + } + } + + private function show_fail_acl() { + $ui = Ui::getInstance(); + + $ui->createPage(); + + $options['type'] = 'onStart'; + $options['title_text'] = __('You don\'t have access to this page'); + $options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.

Please know that all attempts to access this page are recorded in security logs of Pandora System Database'); + $ui->addDialog($options); + + $ui->showPage(); + } + + private function show_modules() { + $ui = Ui::getInstance(); + + $ui->createPage(); + $ui->createDefaultHeader(__("PandoraFMS: Modules")); + $ui->showFooter(false); + $ui->beginContent(); + $filter_title = sprintf(__('Filter Modules by %s'), + $this->filterEventsGetString()); + $ui->contentBeginCollapsible($filter_title); + $ui->beginForm("index.php?page=modules"); + $system = System::getInstance(); + $groups = users_get_groups_for_select( + $system->getConfig('id_user'), "AR", true, true, false, 'id_grupo'); + $options = array( + 'name' => 'group', + 'title' => __('Group'), + 'label' => __('Group'), + 'items' => $groups, + 'selected' => $this->group + ); + $ui->formAddSelectBox($options); + + $options = array( + 'name' => 'status', + 'title' => __('Status'), + 'label' => __('Status'), + 'items' => $this->list_status, + 'selected' => $this->status + ); + $ui->formAddSelectBox($options); + + $module_groups = db_get_all_rows_sql("SELECT * + FROM tmodule_group + ORDER BY name"); + $module_groups = io_safe_output($module_groups); + $options = array( + 'name' => 'module_group', + 'title' => __('Module group'), + 'label' => __('Module group'), + 'item_id' => 'id_mg', + 'item_value' => 'name', + 'items' => $module_groups, + 'selected' => $this->module_group + ); + $ui->formAddSelectBox($options); + + $tags = tags_get_user_tags(); + $options = array( + 'name' => 'tag', + 'title' => __('Tag'), + 'label' => __('Tag'), + 'items' => $tags, + 'selected' => $this->tag + ); + $ui->formAddSelectBox($options); + + $options = array( + 'name' => 'free_search', + 'value' => $this->free_search, + 'placeholder' => __('Free search') + ); + $ui->formAddInputSearch($options); + + $options = array( + 'icon' => 'refresh', + 'icon_pos' => 'right', + 'text' => __('Apply Filter') + ); + $ui->formAddSubmitButton($options); + $html = $ui->getEndForm(); + $ui->contentCollapsibleAddItem($html); + $ui->contentEndCollapsible(); + $this->listModulesHtml(); + $ui->endContent(); + $ui->showPage(); + } + + private function getListModules($page = 0, $ajax = false) { + $system = System::getInstance(); + $user = User::getInstance(); + + $id_type_web_content_string = db_get_value('id_tipo', + 'ttipo_modulo', 'nombre', 'web_content_string'); + + $total = 0; + $modules = array(); + + $sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; + + + // Part SQL for the Group + if ($this->group != 0) { + $sql_conditions_group = " AND tagente.id_grupo = " . $this->group; + } + else { + $user_groups = implode(',', $user->getIdGroups($this->acl)); + $sql_conditions_group = " AND tagente.id_grupo IN (" . $user_groups . ")"; + } + + + // Part SQL for the Tag + $sql_conditions_tags = tags_get_acl_tags($user->getIdUser(), + $this->group, $this->acl, 'module_condition', 'AND', 'tagente_modulo'); + + + $sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0"; + + // Part SQL for the module_group + if ($this->module_group > -1) { + $sql_conditions .= sprintf (" AND tagente_modulo.id_module_group = '%d'", + $this->module_group); + } + + // Part SQL for the free search + if ($this->free_search != "") { + $sql_conditions .= sprintf (" AND (tagente.nombre LIKE '%%%s%%' + OR tagente_modulo.nombre LIKE '%%%s%%' + OR tagente_modulo.descripcion LIKE '%%%s%%')", + $this->free_search, $this->free_search, $this->free_search); + } + + // Part SQL fro Status + if ($this->status == AGENT_MODULE_STATUS_NORMAL) { //Normal + $sql_conditions .= " AND tagente_estado.estado = 0 + AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) "; + } + elseif ($this->status == AGENT_MODULE_STATUS_CRITICAL_BAD) { //Critical + $sql_conditions .= " AND tagente_estado.estado = 1 AND utimestamp > 0"; + } + elseif ($this->status == AGENT_MODULE_STATUS_WARNING) { //Warning + $sql_conditions .= " AND tagente_estado.estado = 2 AND utimestamp > 0"; + } + elseif ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal + $sql_conditions .= " AND tagente_estado.estado <> 0"; + } + elseif ($this->status == AGENT_MODULE_STATUS_UNKNOW) { //Unknown + $sql_conditions .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0"; + } + elseif ($this->status == AGENT_MODULE_STATUS_NOT_INIT) { //Not init + $sql_conditions .= " AND tagente_estado.utimestamp = 0 + AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)"; + } + + if ($this->tag > 0) { + $sql_conditions .= " AND tagente_modulo.id_agente_modulo IN ( + SELECT ttag_module.id_agente_modulo + FROM ttag_module + WHERE ttag_module.id_tag = " . $this->tag . ")"; + } + + $sql_conditions_all = $sql_conditions_base . $sql_conditions . + $sql_conditions_group . $sql_conditions_tags; + + + + $sql_select = "SELECT + (SELECT GROUP_CONCAT(ttag.name SEPARATOR ',') + FROM ttag + WHERE ttag.id_tag IN ( + SELECT ttag_module.id_tag + FROM ttag_module + WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) + AS tags, + tagente_modulo.id_agente_modulo, + tagente.intervalo AS agent_interval, + tagente.nombre AS agent_name, + tagente_modulo.nombre AS module_name, + tagente_modulo.history_data, + tagente_modulo.flag AS flag, + tagente.id_grupo AS id_group, + tagente.id_agente AS id_agent, + tagente_modulo.id_tipo_modulo AS module_type, + tagente_modulo.module_interval, + tagente_estado.datos, + tagente_estado.estado, + tagente_modulo.min_warning, + tagente_modulo.max_warning, + tagente_modulo.str_warning, + tagente_modulo.unit, + tagente_modulo.min_critical, + tagente_modulo.max_critical, + tagente_modulo.str_critical, + tagente_modulo.extended_info, + tagente_modulo.critical_inverse, + tagente_modulo.warning_inverse, + tagente_modulo.critical_instructions, + tagente_modulo.warning_instructions, + tagente_modulo.unknown_instructions, + tagente_estado.utimestamp AS utimestamp"; + + $sql_total = "SELECT count(*)"; + + $sql = " FROM tagente, tagente_modulo, tagente_estado" . + $sql_conditions_all; + + $sql_limit = "ORDER BY tagente.nombre ASC + LIMIT " . (int)($page * $system->getPageSize()) . "," . (int)$system->getPageSize(); + + $total = db_get_value_sql($sql_total. $sql); + $modules_db = db_get_all_rows_sql($sql_select . $sql . $sql_limit); + + if (empty($modules_db)) { + $modules_db = array(); + } + else { + $modules = array(); + foreach ($modules_db as $module) { + $row = array(); + $row[0] = $row[__('Agent name')] = $module['agent_name']; + $row[1] = $row[__('Type')] = html_print_image("images/" . + modules_show_icon_type($module["module_type"]), true); + $row[2] = $row[__('Module name')] = $module['module_name']; + $row[3] = $row[__('Tags')] = $module['tags']; + $row[4] = $row[__('Interval')] = ($module['module_interval'] == 0) ? human_time_description_raw($module['agent_interval']) : human_time_description_raw($module['module_interval']); + if ($module['utimestamp'] == 0 && (($module['module_type'] < 21 || + $module['module_type'] > 23) && $module['module_type'] != 100)) { + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_NO_DATA, + __('NOT INIT'), true); + } + elseif ($module["estado"] == 0) { + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ": " . $module["datos"], true); + } + elseif ($module["estado"] == 1) { + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ": " . $module["datos"], true); + } + elseif ($module["estado"] == 2) { + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ": " . $module["datos"], true); + } + else { + $last_status = modules_get_agentmodule_last_status( + $module['id_agente_modulo']); + switch($last_status) { + case 0: + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') . " " . + __('NORMAL') . ": " . $module["datos"], true); + break; + case 1: + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') ." " . + __('CRITICAL') . ": " . $module["datos"], true); + break; + case 2: + $row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') . " " . + __('WARNING') . ": " . $module["datos"], true); + break; + } + } + $row[6] = $row[__('Timestamp')] = ui_print_timestamp( + $module["utimestamp"], true); + if (is_numeric($module["datos"])) { + $output = format_numeric($module["datos"]); + + // Show units ONLY in numeric data types + if (isset($module["unit"])) { + $output .= " " . + ''. io_safe_output($module["unit"]) . ''; + } + } + else { + $is_web_content_string = + (bool)db_get_value_filter('id_agente_modulo', + 'tagente_modulo', + array('id_agente_modulo' => $module['id_agente_modulo'], + 'id_tipo_modulo' => $id_type_web_content_string)); + + //Fixed the goliat sends the strings from web + //without HTML entities + if ($is_web_content_string) { + $module['datos'] = io_safe_input($module['datos']); + } + + //Fixed the data from Selenium Plugin + if ($module['datos'] != strip_tags($module['datos'])) { + $module['datos'] = io_safe_input($module['datos']); + } + + if ($is_web_content_string) { + $module_value = $module["datos"]; + } + else { + $module_value = io_safe_output($module["datos"]); + } + + $sub_string = substr(io_safe_output($module["datos"]), 0, 12); + if ($module_value == $sub_string) { + $output = $module_value; + } + else { + $output = $sub_string; + } + } + + $row[7] = $row[__('Data')] = $output; + + if (!$ajax) { + unset($row[0]); + unset($row[1]); + unset($row[2]); + unset($row[3]); + unset($row[4]); + unset($row[5]); + unset($row[6]); + unset($row[7]); + } + + $modules[$module['id_agente_modulo']] = $row; + } + } + + return array('modules' => $modules, 'total' => $total); + } + + private function listModulesHtml($page = 0) { + $system = System::getInstance(); + $ui = Ui::getInstance(); + + $listModules = $this->getListModules($page); + $ui->debug($listModules, true); + + if ($listModules['total'] == 0) { + $ui->contentAddHtml('

' . __('No modules') . '

'); + } + else { + $table = new Table(); + $table->id = 'list_Modules'; + $table->importFromHash($listModules['modules']); + $ui->contentAddHtml($table->getHTML()); + + if ($system->getPageSize() < $listModules['total']) { + $ui->contentAddHtml('
' . + html_print_image('images/spinner.gif', true) . + ' ' . __('Loading...') . + '
'); + + $this->addJavascriptAddBottom(); + } + } + } + + private function addJavascriptAddBottom() { + $ui = Ui::getInstance(); + + $ui->contentAddHtml(""); + } + + private function filterEventsGetString() { + if ($this->default) { + return __("(Default)"); + } + else { + $status = $this->list_status[$this->status]; + + $group = groups_get_name($this->group, true); + + $module_group = db_get_value('name', + 'tmodule_group', 'id_mg', $this->module_group); + $module_groups = io_safe_output($module_groups); + $tag = tags_get_name($this->tag); + + $string = sprintf( + __("(Status: %s - Group: %s - Module group: %s - Tag: %s - Free Search: %s)"), + $status, $group, $module_group, $tag, $this->free_search); + + return $string; + } + } +} + +?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/servers/view_servers.php b/pandora_console/mobile/operation/servers/view_servers.php deleted file mode 100644 index 2760410550..0000000000 --- a/pandora_console/mobile/operation/servers/view_servers.php +++ /dev/null @@ -1,70 +0,0 @@ -system = $system; - } - - public function show() { - $servers = servers_get_info (); - - if ($servers === false) $servers = array(); - - $table = null; - $table->width = '100%'; - - $table->align = array(); - $table->align[1] = 'center'; - $table->align[4] = 'center'; - - $table->head = array(); - $table->head[0] = __('Server'); - $table->head[1] = '' . __('T') . ''; - $table->head[2] = '' . __('S') . ''; - $table->head[3] = '' . __('U') . ''; - $table->head[4] = '' . __('S') . ''; - - $table->data = array(); //$this->system->debug($servers); - foreach ($servers as $server) { - $data = array(); - - if ($server['status'] == 0) { - $server_status = ui_print_status_image(STATUS_SERVER_DOWN, '', true); - } - else { - $server_status = ui_print_status_image(STATUS_SERVER_OK, '', true); - } - $data[] = strip_tags($server["name"]); - $data[] = str_replace('images/', '/images/', $server['img']); - $data[] = human_time_comparation ($server["laststart"], 'tiny'); - $data[] = human_time_comparation ($server["keepalive"], 'tiny'); - $data[] = str_replace(array('images/status_sets', 'system->debug($server["name"]); - - $table->data[] = $data; - } - - html_print_table($table); - } -} - -?> diff --git a/pandora_console/mobile/operation/tactical.php b/pandora_console/mobile/operation/tactical.php index 073f16f2bf..bb92a5907c 100755 --- a/pandora_console/mobile/operation/tactical.php +++ b/pandora_console/mobile/operation/tactical.php @@ -60,6 +60,8 @@ class Tactical { $ui->beginContent(); $ui->contentBeginGrid('responsive'); $data = reporting_get_group_stats(); + $data['mobile'] = true; + $formatted_data = reporting_get_stats_indicators($data, 280, 20, false); $overview = '
' .