diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index cb6467bda4..36627ceb47 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,26 @@ +2010-09-21 Miguel de Dios <miguel.dedios@artica.es> + + * include/functions_html.php: in function "print_select_groups" and function + "print_select_from_sql" added source code to check $config['text_char_long'] + for show small text in this widgets. + + * include/functions.php: in function "get_event_types" and "get_priorities" + added source code to check $config['text_char_long'] for show small text in + this widgets. And in function "get_priority_class" cleaned source code. + + * operation/agentes/status_monitor.php, operation/events/events.php: cleaned + source code style. + + * images/pandora.ico.gif: added image file for to use in the mobile footer. + + * mobile/operation/agents/monitor_status.php, + mobile/operation/agents/view_agents.php, + mobile/operation/agents/tactical.php, + mobile/operation/agents/group_view.php, mobile/operation/events/events.php, + mobile/include/style/main.css, mobile/include/functions_web.php, + mobile/index.php, general/footer.php: continued the develop, yep the + Pandora Console Mobile is complete (only rest the bugs). + 2010-09-21 Sergio Martin <sergio.martin@artica.es> * include/functions_db.php diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index 3c6752dd87..12819d4377 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -26,7 +26,7 @@ if (! file_exists ($config["homedir"] . $license_file)) { } echo '<a class="white_bold" target="_blank" href="' . $config["homeurl"] . $license_file. '">'; -echo 'Pandora FMS '.$pandora_version.' - Build '.$build_version; +echo sprintf(__('Pandora FMS %s - Build %s', $pandora_version, $build_version)); echo '</a><br />'; echo '<a class="white">'. __('Page generated at') . ' '. print_timestamp ($time, true, array ("prominent" => "timestamp")); //Always use timestamp here echo '</a>'; diff --git a/pandora_console/images/pandora.ico.gif b/pandora_console/images/pandora.ico.gif new file mode 100644 index 0000000000..aea148651b Binary files /dev/null and b/pandora_console/images/pandora.ico.gif differ diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 919522f574..08c7977d70 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -779,7 +779,10 @@ function is_module_uncompressed ($module_type) { * @return array module_name Module name to check. */ function get_event_types () { + global $config; + $types = array (); + $types['unknown'] = __('Unknown'); $types['critical'] = __('Monitor Critical'); @@ -794,6 +797,12 @@ function get_event_types () { $types['system'] = __('System'); $types['error'] = __('Error'); + if (isset($config['text_char_long'])) { + foreach ($types as $key => $type) { + $types[$key] = printTruncateText($type, $config['text_char_long'], false, true, false); + } + } + return $types; } @@ -803,6 +812,8 @@ function get_event_types () { * @return array An array with all the priorities. */ function get_priorities () { + global $config; + $priorities = array (); $priorities[0] = __('Maintenance'); $priorities[1] = __('Informational'); @@ -810,6 +821,12 @@ function get_priorities () { $priorities[3] = __('Warning'); $priorities[4] = __('Critical'); + if (isset($config['text_char_long'])) { + foreach ($priorities as $key => $priority) { + $priorities[$key] = printTruncateText($priority, $config['text_char_long'], false, true, false); + } + } + return $priorities; } @@ -844,20 +861,26 @@ function get_priority_name ($priority) { * * @return string CSS priority class. */ -function get_priority_class ($priority) { +function get_priority_class($priority) { switch ($priority) { - case 0: - return "datos_blue"; - case 1: - return "datos_grey"; - case 2: - return "datos_green"; - case 3: - return "datos_yellow"; - case 4: - return "datos_red"; - default: - return "datos_grey"; + case 0: + return "datos_blue"; + break; + case 1: + return "datos_grey"; + break; + case 2: + return "datos_green"; + break; + case 3: + return "datos_yellow"; + break; + case 4: + return "datos_red"; + break; + default: + return "datos_grey"; + break; } } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 7d8a9c2be9..3270090a13 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -164,6 +164,7 @@ function print_select_style ($fields, $name, $selected = '', $style='', $script function print_select_groups($id_user = false, $privilege = "AR", $returnAllGroup = true, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) { + global $config; $user_groups = get_user_groups ($id_user, $privilege, $returnAllGroup, true); @@ -179,7 +180,14 @@ function print_select_groups($id_user = false, $privilege = "AR", $returnAllGrou $fields = array(); foreach ($user_groups_tree as $group) { - $fields[$group['id_grupo']] = str_repeat(" ", $group['deep']) . $group['nombre']; + if (isset($config['text_char_long'])) { + $groupName = printTruncateText($group['nombre'], $config['text_char_long'], false, true, false); + } + else { + $groupName = $group['nombre']; + } + + $fields[$group['id_grupo']] = str_repeat(" ", $group['deep']) . $groupName; } $output = print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, @@ -332,6 +340,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = */ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $return = false, $multiple = false, $sort = true, $disabled = false, $style = false) { + global $config; $fields = array (); $result = get_db_all_rows_sql ($sql); @@ -341,7 +350,12 @@ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $noth foreach ($result as $row) { $id = array_shift($row); $value = array_shift($row); - $fields[$id] = $value; + if (isset($config['text_char_long'])) { + $fields[$id] = printTruncateText($value, $config['text_char_long'], false, true, false); + } + else { + $fields[$id] = $value; + } } return print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, $sort,'',$disabled, $style); diff --git a/pandora_console/mobile/include/functions_web.php b/pandora_console/mobile/include/functions_web.php index 9c9b2dc11f..696d01a637 100644 --- a/pandora_console/mobile/include/functions_web.php +++ b/pandora_console/mobile/include/functions_web.php @@ -13,30 +13,74 @@ // GNU General Public License for more details. function menu() { + $enterpriseHook = enterprise_include('mobile/include/functions_web.php'); + ?> <div id="top_menu"> <div id="menu"> <a href="index.php?page=tactical"><img class="icon_menu" alt="<?php echo __('Dashboard');?>" title="<?php echo __('Dashboard');?>" src="../images/house.png" /></a> <a href="index.php?page=agents"><img class="icon_menu" alt="<?php echo __('Agents');?>" title="<?php echo __('Agents');?>" src="../images/bricks.png" /></a> + <a href="index.php?page=monitor"><img class="icon_menu" alt="<?php echo __('Monitor');?>" title="<?php echo __('Monitor');?>" src="../images/data.png" /></a> <a href="index.php?page=events"><img class="icon_menu" alt="<?php echo __('Events');?>" title="<?php echo __('Events');?>" src="../images/lightning_go.png" /></a> <a href="index.php?page=alerts"><img class="icon_menu" alt="<?php echo __('Alerts');?>" title="<?php echo __('Alerts');?>" src="../images/bell.png" /></a> <a href="index.php?page=groups"><img class="icon_menu" alt="<?php echo __('Groups');?>" title="<?php echo __('Groups');?>" src="../images/world.png" /></a> <a href="index.php?page=servers"><img class="icon_menu" alt="<?php echo __('Servers');?>" title="<?php echo __('Servers');?>" src="../images/god5.png" /></a> - <a href=""><img class="icon_menu" alt="<?php echo __('Reports');?>" title="<?php echo __('Reports');?>" src="../images/reporting.png" /></a> + <?php + if ($enterpriseHook !== ENTERPRISE_NOT_HOOK) { + menuEnterprise(); + } + ?> <a href="index.php?action=logout"><img class="icon_menu" alt="<?php echo __('Logout');?>" title="<?php echo __('Logout');?>" src="../images/log-out.png" /></a> </div> <div id="down_button"> - <a class="button_menu" id="button_menu_down" href="javascript: toggleMenu();"><img src="images/down.png" /></a> - <a class="button_menu" id="button_menu_up" href="javascript: toggleMenu();"><img src="images/up.png" /></a> + <a class="button_menu" id="button_menu_down" href="javascript: toggleMenu();"><img id="img_boton_menu" width="20" height="20" src="images/down.png" /></a> </div> </div> - <div id="margin_bottom_menu"></div> <script type="text/javascript"> - function toggleMenu() { - $("#top_menu #menu").slideToggle("normal"); - $(".button_menu").toggle(); - } + var open = 0; + + function toggleMenu() { + if (document.getElementById) { + var div = document.getElementById('menu'); + var boton_up = document.getElementById('button_menu_up'); + var boton_down = document.getElementById('button_menu_down'); + var boton_img = document.getElementById('img_boton_menu'); + + if (open == 0) { + boton_img.src = 'images/up.png'; + div.style.display = 'block'; +// boton_up.style.display = 'block'; +// boton_down.style.display = 'none'; + open = 1; + } + else { + open = 0; + boton_img.src = 'images/down.png'; + div.style.display = 'none'; +// boton_down.style.display = 'block'; +// boton_up.style.display = 'none'; + } + } + } </script> <?php } + +function footer() { + global $pandora_version, $build_version; + + if (isset($_SERVER['REQUEST_TIME'])) { + $time = $_SERVER['REQUEST_TIME']; + } else { + $time = get_system_time (); + } + ?> + <div id="footer" style="background: url('../images/pandora.ico.gif') no-repeat left #000;"> + <?php + echo sprintf(__('Pandora FMS %s - Build %s', $pandora_version, $build_version)) . '<br />'; + echo __('Generated at') . ' '. print_timestamp ($time, true, array ("prominent" => "timestamp")); + ?> + </div> + <?php +} ?> \ No newline at end of file diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index d3b1b238e3..8169b88495 100644 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -18,9 +18,12 @@ input { border: 1px solid; } -.icon_menu { - width: 50px; - height: 50px; +.tactical_link { + text-decoration: none; +} + +.tactical_link:hover { + text-decoration: underline; } .orange { @@ -79,6 +82,16 @@ tr.rowPair:hover { tr.rowOdd:hover { background-color: #E0E0E0 } + +#footer { + background: #000; + height: 30px; + color: #fff; + text-align: center; + margin-top: 20px; + font-size: 10px; +} + /*----------------INI-MENU----------------------------------------------------*/ #top_menu { background: #3F4E2F; @@ -88,7 +101,7 @@ tr.rowOdd:hover { } #margin_bottom_menu { - margin-bottom: 17px; + /*margin-bottom: 17px;*/ } #menu { @@ -96,7 +109,7 @@ tr.rowOdd:hover { } #down_button { - height: 15px; + height: 20px; background: #fff; } @@ -106,11 +119,30 @@ tr.rowOdd:hover { padding-right: 10px; } -#button_menu_up { - display: none; +.icon_menu { + width: 30px; + height: 30px; } /*----------------END-MENU----------------------------------------------------*/ +/*----------------INI-EVENTS ROW BACKGROUND-----------------------------------*/ +.datos_green, .datos_greenf9 { + background-color: #BBFFA4; +} +.datos_red, .datos_redf9 { + background-color: #FFC0B5; +} +.datos_yellow, .datos_yellowf9 { + background-color: #F4FFBF; +} +.datos_blue, .datos_bluef9 { + background-color: #CDE2EA; +} +.datos_grey, .datos_greyf9 { + background-color: #E4E4E4; +} +/*----------------END-EVENTS ROW BACKGROUND-----------------------------------*/ + /*----------------INI-TABLE---------------------------------------------------*/ th { background-color:#9EAC8B; diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index ac4e3fdccd..aa79841788 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -23,6 +23,8 @@ require_once('operation/agents/tactical.php'); require_once('operation/agents/group_view.php'); require_once('operation/agents/view_alerts.php'); require_once('operation/events/events.php'); +require_once('operation/agents/monitor_status.php'); +$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); $system = new System(); @@ -34,15 +36,15 @@ $user->hackinjectConfig(); ?> <html> <head> - <title>XXX</title> + <title>Pandora FMS - <?php echo __('the Flexible Monitoring System (mobile version)'); ?></title> <link rel="stylesheet" href="include/style/main.css" type="text/css" /> <link rel="stylesheet" href="../include/styles/tip.css" type="text/css" /> <script type="text/javascript" src="../include/javascript/jquery.js"></script> </head> <body> - <!--<div style="width: 100%; height: 100%; border: 2px solid red; overflow: hidden;">--> + <div> <!--<div style="width: 240px; height: 320px; border: 2px solid red; overflow: hidden;">--> - <div style="width: 240px; height: 640px; border: 2px solid red; overflow: hidden;"> + <!--<div style="width: 240px; height: 640px; border: 2px solid red; overflow: hidden;">--> <?php $action = $system->getRequest('action'); switch ($action) { @@ -54,8 +56,8 @@ $user->hackinjectConfig(); $user->hackinjectConfig(); menu(); - if (! give_acl ($system->getConfig('id_user'), 0, "AR")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "AR")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -76,10 +78,15 @@ $user->hackinjectConfig(); menu(); $page = $system->getRequest('page', 'tactical'); switch ($page) { + case 'reports': + if ($enterpriseHook !== ENTERPRISE_NOT_HOOK) { + $enterprise = new Enterprise($page); + } + break; default: case 'tactical': - if (! give_acl ($system->getConfig('id_user'), 0, "AR")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "AR")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -89,8 +96,8 @@ $user->hackinjectConfig(); $tactical->show(); break; case 'agents': - if (! give_acl ($system->getConfig('id_user'), 0, "AR")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "AR")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -115,8 +122,8 @@ $user->hackinjectConfig(); } break; case 'servers': - if (! give_acl ($system->getConfig('id_user'), 0, "PM")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "PM")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -126,8 +133,8 @@ $user->hackinjectConfig(); $viewServers->show(); break; case 'alerts': - if (! give_acl ($system->getConfig('id_user'), 0, "PM")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "PM")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -137,8 +144,8 @@ $user->hackinjectConfig(); $viewAlerts->show(); break; case 'groups': - if (! give_acl ($system->getConfig('id_user'), 0, "PM")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "PM")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; @@ -148,8 +155,8 @@ $user->hackinjectConfig(); $groupView->show(); break; case 'events': - if (! give_acl ($system->getConfig('id_user'), 0, "IR")) { - audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + if (! give_acl($system->getConfig('id_user'), 0, "IR")) { + audit_db($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access event viewer"); require ("general/noaccess.php"); return; @@ -158,12 +165,28 @@ $user->hackinjectConfig(); $eventsView = new EventsView(); $eventsView->show(); break; + case 'monitor': + if (! give_acl($system->getConfig('id_user'), 0, "AR")) { + audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation", + "Trying to access Agent Data view"); + require ("../general/noaccess.php"); + return; + } + + $monitorStatus = new MonitorStatus($user); + $monitorStatus->show(); + break; } } break; } ?> </div> + <?php + if ($user->isLogged()) { + footer(); + } + ?> </body> </html> <?php diff --git a/pandora_console/mobile/operation/agents/group_view.php b/pandora_console/mobile/operation/agents/group_view.php index 26a062e836..817dfaa3b4 100644 --- a/pandora_console/mobile/operation/agents/group_view.php +++ b/pandora_console/mobile/operation/agents/group_view.php @@ -34,14 +34,14 @@ class GroupView { $table->head = array(); $table->head[0] = ' '; - $table->head[1] = '<span title="' . __('Total Agents') . '" alt="' . __('Total Agents') . '">' . __('T') . '</span>'; - $table->head[2] = '<span title="' . __('Agent unknown') . '" alt="' . __('Agent unknown') . '">' . __('A') . '</span>'; - $table->head[3] = '<span title="' . __('Unknown') . '" alt="' . __('Unknown') . '">' . __('U') . '</span>'; - $table->head[4] = '<span title="' . __('Not Init') . '" alt="' . __('Not Init') . '">' . __('N') . '</span>'; - $table->head[5] = '<span title="' . __('Normal') . '" alt="' . __('Normal') . '">' . __('N') . '</span>'; - $table->head[6] = '<span title="' . __('Warning') . '" alt="' . __('Warning') . '">' . __('W') . '</span>'; - $table->head[7] = '<span title="' . __('Critical') . '" alt="' . __('Critical') . '">' . __('C') . '</span>'; - $table->head[8] = '<span title="' . __('Alert fired') . '" alt="' . __('Alert fired') . '">' . __('A') . '</span>'; +// $table->head[1] = '<span title="' . __('Total Agents') . '" alt="' . __('Total Agents') . '">' . __('T') . '</span>'; +// $table->head[2] = '<span title="' . __('Agent unknown') . '" alt="' . __('Agent unknown') . '">' . __('A') . '</span>'; + $table->head[3] = '<span title="' . __('Unknown') . '" alt="' . __('Unknown') . '">' . __('Unk') . '</span>'; +// $table->head[4] = '<span title="' . __('Not Init') . '" alt="' . __('Not Init') . '">' . __('N') . '</span>'; + $table->head[5] = '<span title="' . __('Normal') . '" alt="' . __('Normal') . '">' . __('Nor') . '</span>'; +// $table->head[6] = '<span title="' . __('Warning') . '" alt="' . __('Warning') . '">' . __('W') . '</span>'; +// $table->head[7] = '<span title="' . __('Critical') . '" alt="' . __('Critical') . '">' . __('C') . '</span>'; + $table->head[8] = '<span title="' . __('Alert fired') . '" alt="' . __('Alert fired') . '">' . __('Aler') . '</span>'; $rowPair = false; $iterator = 0; @@ -62,14 +62,14 @@ class GroupView { $groupName = get_group_name($idGroup); - $data[] = '<a href="index.php?page=agents&filter_group=' . $idGroup . '"><img alt="' . $groupName . '" title="' . $groupName . '" src="../images/groups_small/' . get_group_icon($idGroup) . '" /></a>'; - $data[] = $groupData['total_agents']; - $data[] = $groupData['agents_unknown']; + $data[] = '<a href="index.php?page=agents&filter_group=' . $idGroup . '">' . $groupName . '</a>'; +// $data[] = $groupData['total_agents']; +// $data[] = $groupData['agents_unknown']; $data[] = $groupData['monitor_unknown']; - $data[] = $groupData['monitor_not_init']; +// $data[] = $groupData['monitor_not_init']; $data[] = $groupData["monitor_ok"]; - $data[] = $groupData["monitor_warning"]; - $data[] = $groupData["monitor_critical"]; +// $data[] = $groupData["monitor_warning"]; +// $data[] = $groupData["monitor_critical"]; $data[] = $groupData["monitor_alerts_fired"]; $table->data[] = $data; diff --git a/pandora_console/mobile/operation/agents/monitor_status.php b/pandora_console/mobile/operation/agents/monitor_status.php new file mode 100644 index 0000000000..6bc60ef5b5 --- /dev/null +++ b/pandora_console/mobile/operation/agents/monitor_status.php @@ -0,0 +1,224 @@ +<?php +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation for version 2. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +class MonitorStatus { + private $system; + private $user; + private $offset; + + public function __construct($user) { + global $system; + + $this->system = $system; + $this->user = $user; + + $this->offset = $this->system->getRequest("offset", 0); + } + + public function show() { + global $config; + $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] = '<span alt="' . __('Group') . '" title="' . __('Group') . '"><b>' . __('G') . '</b></span>'; + $table->data[0][1] = print_select_groups($this->system->getConfig("id_user"), "IR", true, 'group', $group, '', '', 0, true, false, false, 'w130'); + $table->data[0][2] = '<span alt="' . __('Monitor status') . '" title="' . __('Monitor Status') . '"><b>' . __('M') . '</b></span>'; + $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] = printTruncateText($field, $config['text_char_long'], false, true, false); + } + $table->data[0][3] = print_select ($fields, "status", $status, '', '', -1, true); + $table->data[1][0] = '<span alt="' . __('Module group') . '" title="' . __('Module group') . '"><b>' . __('M') . '</b></span>'; + $table->data[1][1] = print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", + 'module_group', $modulegroup, '',__('All'), 0, true); + $table->data[1][2] = print_input_text('search', $search, '', 5, 20, true); + $table->data[1][2] .= "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />"; + + echo "<form method='post'>"; + print_table($table); + echo "</form>"; + + + + + // Agent group selector + if (($group > 0) && (give_acl($system->getConfig('id_user'), $group, "AR"))) { + $sqlGroup = sprintf (" AND tagente.id_grupo = %d", $ag_group); + } + else { + $user_groups_all = get_user_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 = get_db_value_sql('SELECT COUNT(*) ' . $sql); + + + $rows = get_db_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->offset . ', ' . $this->system->getPageSize()); + + if ($rows === false) $rows = array(); + + + $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 = print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); + } + elseif ($row["estado"] == 0) { + $statusImg = print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); + } + elseif ($row["estado"] == 1) { + $statusImg = print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); + } + elseif ($row["estado"] == 2) { + $statusImg = print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); + } + else { + $last_status = get_agentmodule_last_status($row['id_agente_modulo']); + switch($last_status) { + case 0: + $statusImg = print_status_image(STATUS_MODULE_OK, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); + break; + case 1: + $statusImg = print_status_image(STATUS_MODULE_CRITICAL, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); + break; + case 2: + $statusImg = print_status_image(STATUS_MODULE_WARNING, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); + break; + } + } + + $data[] = str_replace('<img src="' , '<img width="15" height="15" src="../', $statusImg); + + $data[] = '<a href="index.php?page=agent&id=' . $row['id_agent'] . '">' . printTruncateText($row['agent_name'], 25, true, true) . '</a>'; + $data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $row['id_agente_modulo'] . '">' . + printTruncateText($row['module_name'], 25, true, true) . '</a>'; + if (is_numeric($row["datos"])) + $data[] = format_numeric($row["datos"]); + else + $data[] = "<span title='".$row['datos']."' style='white-space: nowrap;'>".substr(safe_output($row["datos"]),0,12)."</span>"; + + $data[] = print_timestamp ($row["utimestamp"], true, array('units' => 'tiny')); + + $table->data[] = $data; + } + + print_table($table); + + $pagination = pagination ($total, + 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 index 83aac2fc00..c638358c8b 100644 --- a/pandora_console/mobile/operation/agents/tactical.php +++ b/pandora_console/mobile/operation/agents/tactical.php @@ -53,22 +53,22 @@ class Tactical { $table->data[8][0] = $table->data[8][1] = ''; $table->data[0][1] = "<h3 class='title_h3_server'>" . __('Monitor checks') . "</h3>"; - $table->data[1][2] = __('Monitor checks'); - $table->data[1][3] = $data["monitor_checks"]; - $table->data[2][2] = '<span style="color: #c00;">' . __('Monitors critical') . '</span>'; - $table->data[2][3] = '<span style="color: #c00;">' . $data["monitor_critical"] . '</span>'; - $table->data[3][2] = '<span style="color: #ffcc00;">' . __('Monitors warning') .'</span>'; - $table->data[3][3] = '<span style="color: #ffcc00;">' . $data["monitor_warning"] . '</span>'; - $table->data[4][2] = '<span style="color: #8ae234;">' . __('Monitors normal') . '</span>'; - $table->data[4][3] = '<span style="color: #8ae234;">' . $data["monitor_ok"] . '</span>'; - $table->data[5][2] = '<span style="color: #aaa;">' . __('Monitors unknown') . '</span>'; - $table->data[5][3] = '<span style="color: #aaa;">' . $data["monitor_unknown"] . '</span>'; - $table->data[6][2] = '<span style="color: #ef2929;">' . __('Monitors not init') . '</span>'; - $table->data[6][3] = '<span style="color: #ef2929;">' . $data["monitor_not_init"] . '</span>'; - $table->data[7][2] = '<span style="color: #000;">' . __('Alerts defined') . '</span>'; - $table->data[7][3] = '<span style="color: #000;">' . $data["monitor_alerts"] . '</span>'; - $table->data[8][2] = '<span style="color: #ff8800;">' . __('Alerts fired') . '</span>'; - $table->data[8][3] = '<span style="color: #ff8800;">' . $data["monitor_alerts_fired"] . '</span>'; + $table->data[1][2] = '<a href="index.php?page=monitor" class="tactical_link" style="color: #000;">' . __('Monitor checks') . '</a>'; + $table->data[1][3] = '<a href="index.php?page=monitor" class="tactical_link" style="color: #000;">' . $data["monitor_checks"] . '</a>'; + $table->data[2][2] = '<a href="index.php?page=monitor&status=2" class="tactical_link" style="color: #c00;">' . __('Monitors critical') . '</a>'; + $table->data[2][3] = '<a href="index.php?page=monitor&status=2" class="tactical_link" style="color: #c00;">' . $data["monitor_critical"] . '</a>'; + $table->data[3][2] = '<a href="index.php?page=monitor&status=1" class="tactical_link" style="color: #ffcc00;">' . __('Monitors warning') .'</a>'; + $table->data[3][3] = '<a href="index.php?page=monitor&status=1" class="tactical_link" style="color: #ffcc00;">' . $data["monitor_warning"] . '</a>'; + $table->data[4][2] = '<a href="index.php?page=monitor&status=0" class="tactical_link" style="color: #8ae234;">' . __('Monitors normal') . '</a>'; + $table->data[4][3] = '<a href="index.php?page=monitor&status=0" class="tactical_link" style="color: #8ae234;">' . $data["monitor_ok"] . '</a>'; + $table->data[5][2] = '<a href="index.php?page=monitor&status=3" class="tactical_link" style="color: #aaa;">' . __('Monitors unknown') . '</a>'; + $table->data[5][3] = '<a href="index.php?page=monitor&status=3" class="tactical_link" style="color: #aaa;">' . $data["monitor_unknown"] . '</a>'; + $table->data[6][2] = '<a href="index.php?page=monitor&status=5" class="tactical_link" style="color: #ef2929;">' . __('Monitors not init') . '</a>'; + $table->data[6][3] = '<a href="index.php?page=monitor&status=5" class="tactical_link" style="color: #ef2929;">' . $data["monitor_not_init"] . '</a>'; + $table->data[7][2] = '<a href="index.php?page=alerts" class="tactical_link" style="color: #000;">' . __('Alerts defined') . '</a>'; + $table->data[7][3] = '<a href="index.php?page=alerts" class="tactical_link" style="color: #000;">' . $data["monitor_alerts"] . '</a>'; + $table->data[8][2] = '<a href="index.php?page=events&event_type=alert_fired" class="tactical_link" style="color: #ff8800;">' . __('Alerts fired') . '</a>'; + $table->data[8][3] = '<a href="index.php?page=events&event_type=alert_fired" class="tactical_link" style="color: #ff8800;">' . $data["monitor_alerts_fired"] . '</a>'; print_table($table); @@ -100,8 +100,8 @@ class Tactical { $table = null; //$table->width = '100%'; $table->align[1] = 'right'; - $table->data[0][0] = '<span style="color: #000;">' . __('Total agents') . '</span>'; - $table->data[0][1] = '<span style="color: #000;">' . $data["total_agents"] . '</span>'; + $table->data[0][0] = '<a href="index.php?page=agents" class="tactical_link" style="color: #000;">' . __('Total agents') . '</span>'; + $table->data[0][1] = '<a href="index.php?page=agents" class="tactical_link" style="color: #000;">' . $data["total_agents"] . '</span>'; $table->data[1][0] = '<span style="color: #ef2929;">' . __('Uninitialized modules') . '</span>'; $table->data[1][1] = '<span style="color: #ef2929;">' . $data["server_sanity"] . '</span>'; $table->data[2][0] = '<span style="color: #aaa;">' . __('Agents unknown') . '</span>'; diff --git a/pandora_console/mobile/operation/agents/view_agents.php b/pandora_console/mobile/operation/agents/view_agents.php index de16164e2b..a2c57a3682 100644 --- a/pandora_console/mobile/operation/agents/view_agents.php +++ b/pandora_console/mobile/operation/agents/view_agents.php @@ -36,8 +36,10 @@ class ViewAgents { private function showForm() { echo "<form>"; print_input_hidden('page', 'agents'); + global $config; + $config['text_char_long'] = 12; print_select_groups($this->user->getIdUser(), "AR", true, 'filter_group', $this->filterGroup); - print_input_text('filter_text', $this->filterText, __('Free text search'), 10, 20); + print_input_text('filter_text', $this->filterText, __('Free text search'), 5, 20); echo "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />"; echo "<form>"; } diff --git a/pandora_console/mobile/operation/events/events.php b/pandora_console/mobile/operation/events/events.php index 99d852da2d..48ac7df5af 100644 --- a/pandora_console/mobile/operation/events/events.php +++ b/pandora_console/mobile/operation/events/events.php @@ -24,6 +24,9 @@ class EventsView { } function show() { + global $config; + $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 @@ -48,7 +51,7 @@ class EventsView { $table->data[0][3] = print_select ($types, 'event_type', $event_type, '', __('All'), '', true); $table->data[1][0] = '<span alt="' . __('Severity') . '" title="' . __('Severity') . '"><b>' . __('S') . '</b></span>'; $table->data[1][1] = print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true); - $table->data[1][2] = print_input_text('search', $search, '', 10, 20, true); + $table->data[1][2] = print_input_text('search', $search, '', 5, 20, true); $table->data[1][2] .= "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />"; echo "<form method='post'>"; @@ -116,9 +119,7 @@ class EventsView { $sql_count = str_replace('*', 'COUNT(*)', $sql); - $sql = $sql . ' LIMIT %d,%d'; - - $sql = sprintf($sql, $offset, $this->system->getPageSize()); + $sql = $sql . sprintf(' LIMIT %d,%d', $offset, $this->system->getPageSize()); $count = get_db_value_sql($sql_count); @@ -130,7 +131,7 @@ class EventsView { $table = null; $table->width = '100%'; $table->head = array(); - $table->head[0] = '<span title="' . __('Severity') . '" alt="' . __('Severity') . '">' . __('S') . '</span>'; +// $table->head[0] = '<span title="' . __('Severity') . '" alt="' . __('Severity') . '">' . __('S') . '</span>'; // $table->head[1] = '<span title="' . __('Group') . '" alt="' . __('Group') . '">' . __('G') . '</span>'; // $table->head[2] = '<span title="' . __('Type') . '" alt="' . __('Type') . '">' . __('T') . '</span>'; $table->head[3] = '<span title="' . __('Timestamp') . '" alt="' . __('Timestamp') . '">' . __('T') . '</span>'; @@ -138,6 +139,7 @@ class EventsView { $table->head[5] = '<span title="' . __('Agent') . '" alt="' . __('Agent') . '">' . __('Agent') . '</span>'; $table->data = array(); + $iterator = 0; foreach ($rows as $row) { $data = array(); @@ -160,14 +162,17 @@ class EventsView { break; } - $data[] = '<a href="index.php?page=events&offset=' . $offset . - '&ev_group=' . $ev_group . '&event_type=' . $event_type . - '&severity=' . $row["criticity"] . '&search=' . $search . '">' . - print_image ($img, true, - array ("class" => "image_status", - "width" => 15, - "height" => 15, - "title" => get_priority_name($row["criticity"]))) . '</a>'; + $table->rowclass[$iterator] = get_priority_class($row["criticity"]); + $iterator++; + +// $data[] = '<a href="index.php?page=events&offset=' . $offset . +// '&ev_group=' . $ev_group . '&event_type=' . $event_type . +// '&severity=' . $row["criticity"] . '&search=' . $search . '">' . +// print_image ($img, true, +// array ("class" => "image_status", +// "width" => 15, +// "height" => 15, +// "title" => get_priority_name($row["criticity"]))) . '</a>'; // $data[] = '<a href="index.php?page=events&ev_group=' . // $row["id_grupo"] . '&event_type=' . $event_type . @@ -183,14 +188,14 @@ class EventsView { $data[] = print_timestamp($row["timestamp"], true, array('units' => 'tiny')); - $data[] = printTruncateText($row["evento"], 40, true, true); + $data[] = $row["evento"]; if ($row["event_type"] == "system") { $data[] = printTruncateText(__('System'), 20, true, true); } elseif ($row["id_agente"] > 0) { // Agent name - $data[] = printTruncateText(get_agent_name($row["id_agente"]), 20, true, true); + $data[] = '<a href="index.php?page=agent&id=' . $row["id_agente"] . '">' . printTruncateText(get_agent_name($row["id_agente"]), 20, true, true) . '</a>'; } else { $data[] = printTruncateText(__('Alert SNMP'), 20, true, true); diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 4406652e66..a89f4a8697 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -97,7 +97,8 @@ $sql = " FROM tagente, tagente_modulo, tagente_estado // Agent group selector if ($ag_group > 0 && give_acl ($config["id_user"], $ag_group, "AR")) { $sql .= sprintf (" AND tagente.id_grupo = %d", $ag_group); -} else { +} +else { // User has explicit permission on group 1 ? $sql .= " AND tagente.id_grupo IN (".$user_groups.")"; } @@ -222,13 +223,17 @@ foreach ($result as $row) { if($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)){ $data[5] = print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); - } elseif ($row["estado"] == 0) { + } + elseif ($row["estado"] == 0) { $data[5] = print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); - } elseif ($row["estado"] == 1) { + } + elseif ($row["estado"] == 1) { $data[5] = print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); - } elseif ($row["estado"] == 2) { + } + elseif ($row["estado"] == 2) { $data[5] = print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); - } else { + } + else { $last_status = get_agentmodule_last_status($row['id_agente_modulo']); switch($last_status) { case 0: diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index a3cad0faf5..b36e0cd4b7 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -218,7 +218,7 @@ else { echo "</h2>"; } -if($section == 'validate' && $ids[0] == -1){ +if (($section == 'validate') && ($ids[0] == -1)) { $section = 'list'; print_error_message (__('No events selected')); }