diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5705f625a8..6304118f18 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,34 @@ +2010-09-15 Miguel de Dios + + * include/functions_reporting.php: in function "get_agent_module_info" added + the return "status" and "alert_value". + + * include/auth/mysql.php: in function "process_user_login" cleaned the + source code style. + + * include/functions_ui.php: in function "print_timestamp" added in the + parameter $option the check of units ('large' and 'tiny' at the moment). + Added the function "print_group_icon2" that it is the same of + "print_group_icon" but it has a new parameter $path for to set the images + path. + + * include/functions.php: in function "human_time_comparation" added the + parameter $units to set the type return text for time unit (at the moment + only "large" and "tiny"). And in the function "human_time_description_raw" + added the paramter $units for to set the type of return text for units, at + the moment only "large" and "tiny". + + * include/functions_db.php, operation/agentes/ver_agente.php: cleaned source + code. + + * mobile/index.php, mobile/operation/agents, + mobile/operation/agents/view_agents.php, mobile/include/db.class.php, + mobile/include/style, mobile/include/style/main.css, + mobile/include/user.class.php, mobile/include/functions_web.php, + mobile/include/system.class.php, mobile/images/bricks.png, + mobile/images/up.png, mobile/images/zoom.png, mobile/images/down.png: added + first version of file for Pandora Mobile version. + 2010-09-15 Ramon Novoa * pandoradb.sql: Fixed a typo. diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index bbe252e38b..422741bab4 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -90,14 +90,16 @@ function process_user_login ($login, $pass) { // to avoid problems with case-sensitive usernames. // Thanks to David Muñiz for Bug discovery :) return $row["id_user"]; - } else { + } + else { $mysql_cache["auth_error"] = "User not found in database or incorrect password"; } return false; // Remote authentication - } else { + } + else { switch ($config["auth"]) { diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 41e4b15641..919522f574 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -276,11 +276,12 @@ function format_integer_round ($number, $rounder = 5) { * TODO: Make sense out of all these time functions and stick with 2 or 3 * * @param int $timestamp Unixtimestamp to compare with current time. + * @param string $units The type of unit, by default 'large'. * * @return string A human readable string of the diference between current * time and a given timestamp. */ -function human_time_comparation ($timestamp) { +function human_time_comparation ($timestamp, $units = 'large') { global $config; if (!is_numeric ($timestamp)) { @@ -289,7 +290,7 @@ function human_time_comparation ($timestamp) { $seconds = get_system_time () - $timestamp; - return human_time_description_raw ($seconds); + return human_time_description_raw($seconds, false, $units); } /** @@ -321,13 +322,33 @@ function get_system_time () { * * @param int $seconds Seconds elapsed time * @param int $exactly If it's true, return the exactly human time + * @param string $units The type of unit, by default 'large'. * * @return string A human readable translation of minutes. */ -function human_time_description_raw ($seconds, $exactly = false) { +function human_time_description_raw ($seconds, $exactly = false, $units = 'large') { + + switch ($units) { + case 'large': + $secondsString = __('seconds'); + $daysString = __('days'); + $monthsString = __('months'); + $minutesString = __('minutes'); + $hoursString = __('hours'); + $nowString = __('Now'); + break; + case 'tiny': + $secondsString = __('s'); + $daysString = __('d'); + $monthsString = __('M'); + $minutesString = __('m'); + $hoursString = __('h'); + $nowString = __('N'); + break; + } if (empty ($seconds)) { - return __('Now'); + return $nowString; // slerena 25/03/09 // Most times $seconds is empty is because last contact is current date // Put here "uknown" or N/A or something similar is not a good idea @@ -341,39 +362,39 @@ function human_time_description_raw ($seconds, $exactly = false) { $months = format_numeric ($seconds / 2592000, 0); if (($mins == 0) && ($hours == 0) && ($days == 0) && ($months == 0)) - return format_numeric ($secs, 0).' '.__('seconds'); + return format_numeric ($secs, 0).' '. $secondsString; else if (($hours == 0) && ($days == 0) && ($months == 0)) return sprintf("%02d",$mins).':'.sprintf("%02d",$secs); else if (($days == 0) && ($months == 0)) return sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); else if (($months == 0)) - return $days.' '.__('days').' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + return $days.' ' . $daysString . ' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); else - return $months.' '.__('months').' '.$days.' '.__('days').' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + return $months.' '. $monthsString .' '.$days.' ' . $daysString . ' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); } if ($seconds < 60) - return format_numeric ($seconds, 0)." ".__('seconds'); + return format_numeric ($seconds, 0)." " . $secondsString; if ($seconds < 3600) { $minutes = floor($seconds / 60); $seconds = $seconds % 60; if ($seconds == 0) - return $minutes.' '.__('minutes'); + return $minutes.' ' . $minutesString; $seconds = sprintf ("%02d", $seconds); - return $minutes.':'.$seconds.' '.__('minutes'); + return $minutes.':'.$seconds.' ' . $minutesString; } if ($seconds < 86400) - return format_numeric ($seconds / 3600, 0)." ".__('hours'); + return format_numeric ($seconds / 3600, 0)." " . $hoursString; if ($seconds < 2592000) - return format_numeric ($seconds / 86400, 0)." ".__('days'); + return format_numeric ($seconds / 86400, 0) . " " . $daysString; if ($seconds < 15552000) - return format_numeric ($seconds / 2592000, 0)." ".__('months'); + return format_numeric ($seconds / 2592000, 0)." ". $monthsString; - return "+6 ".__('months'); + return "+6 " . $monthsString; } /** diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 91d4d3bf14..986b140c1a 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -520,13 +520,6 @@ function get_group_agents ($id_group = 0, $search = false, $case = "lower", $noA $sql = sprintf ("SELECT id_agente, nombre FROM tagente %s ORDER BY nombre", $search_sql); $result = get_db_all_rows_sql ($sql); - ////////////////LOG AJAX/////////////////////// - /////////////////////////////////////////////// - //$log = fopen ( "/tmp/log_sql", "a"); - //fwrite ($log, $sql."\n\n"); - //fclose($log); - /////////////////////////////////////////////// - if ($result === false) return array (); //Return an empty array diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 820f632266..6a53582c14 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1498,9 +1498,11 @@ function get_agent_module_info ($id_agent, $filter = false) { $return["monitor_critical"] = 0; //Number of 'critical' monitors $return["monitor_unknown"] = 0; //Number of 'unknown' monitors $return["monitor_alertsfired"] = 0; //Number of monitors with fired alerts - $return["last_contact"] = 0; //Last agent contact + $return["last_contact"] = 0; //Last agent contact + $return["status"] = STATUS_AGENT_NO_DATA; $return["status_img"] = print_status_image (STATUS_AGENT_NO_DATA, __('Agent without data'), true); $return["alert_status"] = "notfired"; + $return["alert_value"] = STATUS_ALERT_NOT_FIRED; $return["alert_img"] = print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true); $return["agent_group"] = get_agent_group ($id_agent); @@ -1550,15 +1552,19 @@ function get_agent_module_info ($id_agent, $filter = false) { if ($return["modules"] > 0) { if ($return["monitor_critical"] > 0) { + $return["status"] = STATUS_AGENT_CRITICAL; $return["status_img"] = print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true); } else if ($return["monitor_warning"] > 0) { + $return["status"] = STATUS_AGENT_WARNING; $return["status_img"] = print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true); } else if ($return["monitor_unknown"] > 0) { + $return["status"] = STATUS_AGENT_DOWN; $return["status_img"] = print_status_image (STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true); } else { + $return["status"] = STATUS_AGENT_OK; $return["status_img"] = print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true); } } @@ -1567,8 +1573,10 @@ function get_agent_module_info ($id_agent, $filter = false) { if ($return["monitor_alertsfired"] > 0) { $return["alert_status"] = "fired"; $return["alert_img"] = print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true); + $return["alert_value"] = STATUS_ALERT_FIRED; } elseif (give_disabled_group ($return["agent_group"])) { $return["alert_status"] = "disabled"; + $return["alert_value"] = STATUS_ALERT_DISABLED; $return["alert_img"] = print_status_image (STATUS_ALERT_DISABLED, __('Alert disabled'), true); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 88fca30077..2f4c358cc0 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -141,6 +141,7 @@ function print_result_message ($result, $good = '', $bad = '', $attributes = '', * Key html_attr: which html attributes to add (defaults to none) * Key tag: Which html tag to use (defaults to span) * Key prominent: Overrides user preference and display "comparation" or "timestamp" + * key units: The type of units. * * @return string HTML code if return parameter is true. */ @@ -181,12 +182,18 @@ function print_timestamp ($unixtime, $return = false, $option = array ()) { if ($unixtime <= 0) { $title = __('Unknown').'/'.__('Never'); $data = __('Unknown'); - } elseif ($prominent == "timestamp") { + } + elseif ($prominent == "timestamp") { $title = human_time_comparation ($unixtime); $data = date ($config["date_format"], $unixtime); - } else { + } + else { $title = date ($config["date_format"], $unixtime); - $data = human_time_comparation ($unixtime); + $units = 'large'; + if (isset($option['units'])) { + $units = $option['units']; + } + $data = human_time_comparation ($unixtime, $units); } $output = '<'.$tag; @@ -247,7 +254,7 @@ function print_group_icon ($id_group, $return = false, $path = "groups_small", $ $output = ''; if (empty ($icon)) - $output .= ' - '; + $output .= ' - '; else $output .= ''.get_group_name ($id_group, true).''; @@ -260,6 +267,42 @@ function print_group_icon ($id_group, $return = false, $path = "groups_small", $ return $output; } +/** + * Print group icon within a link. Other version. + * + * @param int Group id + * @param bool Whether to return or print + * @param string What path to use (relative to images/). Defaults to groups_small + * + * @return string HTML code if return parameter is true. + */ +function print_group_icon2($id_group, $return = false, $path = "images/groups_small", $style='', $link = true) { + if($id_group > 0) + $icon = (string) get_db_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group); + else + $icon = "world"; + + if($style == '') + $style = 'width: 16px; height: 16px;'; + + $output = ''; + if ($link) + $output = ''; + + if (empty ($icon)) + $output .= ' - '; + else + $output .= ''.get_group_name ($id_group, true).''; + + if ($link) + $output .= ''; + + if (!$return) + echo $output; + + return $output; +} + /** * Get the icon of an operating system. * diff --git a/pandora_console/mobile/images/bricks.png b/pandora_console/mobile/images/bricks.png new file mode 100755 index 0000000000..678cb4d957 Binary files /dev/null and b/pandora_console/mobile/images/bricks.png differ diff --git a/pandora_console/mobile/images/down.png b/pandora_console/mobile/images/down.png new file mode 100644 index 0000000000..6b25088e30 Binary files /dev/null and b/pandora_console/mobile/images/down.png differ diff --git a/pandora_console/mobile/images/up.png b/pandora_console/mobile/images/up.png new file mode 100644 index 0000000000..6cb735b5b7 Binary files /dev/null and b/pandora_console/mobile/images/up.png differ diff --git a/pandora_console/mobile/images/zoom.png b/pandora_console/mobile/images/zoom.png new file mode 100644 index 0000000000..09dbfc2708 Binary files /dev/null and b/pandora_console/mobile/images/zoom.png differ diff --git a/pandora_console/mobile/include/db.class.php b/pandora_console/mobile/include/db.class.php new file mode 100644 index 0000000000..9e5aacf596 --- /dev/null +++ b/pandora_console/mobile/include/db.class.php @@ -0,0 +1,32 @@ +system = &$system; + $this->engine = $engine; + + switch ($engine) { + case 'mysql': + //NONE + break; + } + } +} +?> \ No newline at end of file diff --git a/pandora_console/mobile/include/functions_web.php b/pandora_console/mobile/include/functions_web.php new file mode 100644 index 0000000000..c2226351d3 --- /dev/null +++ b/pandora_console/mobile/include/functions_web.php @@ -0,0 +1,41 @@ + +
+ +
+ + +
+
+
+ + \ No newline at end of file diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css new file mode 100644 index 0000000000..c96de6ef31 --- /dev/null +++ b/pandora_console/mobile/include/style/main.css @@ -0,0 +1,101 @@ +* { + margin: 0; + padding: 0; + border: 0; + + font-size: 12px; +} + +body { +} + +input { + border: 1px solid; +} + +.icon_menu { + width: 50px; + height: 50px; +} + +.orange { + color: #ffa300; +} +.green { + color: #5a8629; +} +.yellow { + color: #F3C500; +} +.greenb { + color: #00aa00; +} +.grey { + color: #808080; + font-weight: bold; +} + +select { + border: #CCCCCC 1px solid; +} + +.button_filter { + background: url("../../images/zoom.png") no-repeat scroll center center; + margin-left: 5px; + width: 20px; + height: 20px; +} + +input { + border: #CCCCCC 1px solid; +} + +.title_h3 { + border-top: 1px solid #CCCCCC; + margin: 5px; + color: #3F4E2F; +} +/*----------------INI-MENU----------------------------------------------------*/ +#top_menu { + background: #3F4E2F; + overflow: hidden; + position: absolute; + z-index: 2; +} + +#margin_bottom_menu { + margin-bottom: 17px; +} + +#menu { + display: none; +} + +#down_button { + height: 15px; + background: #fff; +} + +#down_button img { + background: #3F4E2F; + padding-left: 10px; + padding-right: 10px; +} + +#button_menu_up { + display: none; +} +/*----------------END-MENU----------------------------------------------------*/ + +/*----------------INI-TABLE---------------------------------------------------*/ +th { +background-color:#9EAC8B; +color:#FFFFFF; +text-align:center; +} + +.databox { + border: 1px solid #f2f2f2; + background-color: #fafafa; +} +/*----------------END-TABLE---------------------------------------------------*/ diff --git a/pandora_console/mobile/include/system.class.php b/pandora_console/mobile/include/system.class.php new file mode 100644 index 0000000000..889a47bcf5 --- /dev/null +++ b/pandora_console/mobile/include/system.class.php @@ -0,0 +1,94 @@ +loadConfig(); + $this->db = new DB($this, $this->getConfig('db_engine', 'mysql')); + + session_start(); + $this->session = $_SESSION; + session_write_close(); + } + + private function loadConfig() { + global $config; + + $this->config = &$config; + } + + public function getRequest($name, $default = null) { + $return = $default; + + if (isset($_POST[$name])) { + $return = $_POST[$name]; + } + else { + if (isset($_GET[$name])) { + $return = $_GET[$name]; + } + } + + return $return; + } + + private function getConfig($name, $default = null) { + if (!isset($this->config[$name])) { + return $default; + } + else { + return $this->config[$name]; + } + } + + public function setSession($name, $value) { + $this->session[$name] = $value; + + session_start(); + $_SESSION = $this->session; + session_write_close(); + } + + public function getSession($name, $default = null) { + if (!isset($this->session[$name])) { + return $default; + } + else { + return $this->session[$name]; + } + } + + public function debug($var) { + echo "
";
+		var_dump($var);
+		echo "
"; + } + + public function sessionDestroy() { + session_start(); + session_destroy(); + } + + public function getPageSize() { + return 10; + } +} +?> \ No newline at end of file diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php new file mode 100644 index 0000000000..e9950fe112 --- /dev/null +++ b/pandora_console/mobile/include/user.class.php @@ -0,0 +1,85 @@ +user = $user; + $this->system = &$system; + + //$this->system->debug($this->system); + + if (process_user_login($this->user, $password)) { + $this->logged = true; + } + else { + $this->logged = false; + } + } + + public function hackinjectConfig() { + if ($this->logged) { + //hack to compatibility with pandora + global $config; + $config['id_user'] = $this->user; + } + } + + public function isLogged() { + return $this->logged; + } + + public function checkLogin($user = null, $password = null) { + if (($user == null) && ($password == null)) { + $user = $this->system->getRequest('user', null); + $password = $this->system->getRequest('password', null); + } + + if (process_user_login($user, $password)) { + $this->logged = true; + $this->user = $user; + } + else { + $this->logged = false; + } + + return true; + } + + public function logout() { + $this->user = null; + $this->logged = false; + } + + public function login() { + echo "
"; + print_input_hidden('action', 'login'); + print_input_text('user', $this->user, __('User'), 10, 20); + print_input_password('password', '', __('Password'), 10, 20); + print_submit_button(__('Login'), 'login', false, 'class="sub next"'); + echo "
"; + } + + public function getIdUser() { + return $this->user; + } +} +?> \ No newline at end of file diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php new file mode 100644 index 0000000000..1f7f262848 --- /dev/null +++ b/pandora_console/mobile/index.php @@ -0,0 +1,86 @@ +getSession('user', null); +if ($user == null) { + $user = new User(); +} +$user->hackinjectConfig(); +?> + + + XXX + + + + + + + +
+ getRequest('action'); + switch ($action) { + case 'login': + if (!$user->checkLogin()) { + $user->login(); + } + menu(); + break; + case 'logout': + $user->logout(); + break; + default: + if (!$user->isLogged()) { + $user->login(); + } + else { + menu(); + $page = $system->getRequest('page', 'dashboard'); + switch ($page) { + default: + case 'dashboard': + break; + case 'agents': + $viewAgents = new ViewAgents(); + $viewAgents->show(); + break; + case 'agent': + $viewAgent = new ViewAgent(); + $viewAgent->show(); + break; + case 'servers': + break; + } + } + break; + } + ?> +
+ + +setSession('user', $user); +//$system->sessionDestroy(); +ob_end_flush(); +?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/agents/view_agents.php b/pandora_console/mobile/operation/agents/view_agents.php new file mode 100644 index 0000000000..c6be2ebf2c --- /dev/null +++ b/pandora_console/mobile/operation/agents/view_agents.php @@ -0,0 +1,385 @@ +user = $user; + $this->system = $system; + $this->filterText = $this->system->getRequest('filter_text', ''); + $this->filterGroup = $this->system->getRequest('filter_group', 0);; + } + + private function showForm() { + echo "
"; + print_input_hidden('page', 'agents'); + print_select_groups($this->user->getIdUser(), "AR", true, 'filter_group', $this->filterGroup); + print_input_text('filter_text', $this->filterText, __('Free text search'), 10, 20); + echo ""; + echo ""; + } + + public function show() { + $this->showForm(); + + // Show only selected groups + if ($this->filterGroup > 0) { + $groups = $this->filterGroup; + $agent_names = get_group_agents ($this->filterGroup, array('string' => $this->filterText), "upper"); + // Not selected any specific group + } + else { + $user_group = get_user_groups ($this->user->getIdUser(), "AR"); + $groups = array_keys ($user_group); + $agent_names = get_group_agents (array_keys ($user_group), array('string' => $this->filterText), "upper"); + } + + $total_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 = 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; + + $agent_info = get_agent_module_info ($agent["id_agente"]); //$this->system->debug($agent_info); + + $data = array(); + + $truncName = printTruncateText($agent['nombre'], 10, true, true); + + $data[] = print_group_icon2($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; + } + + print_table($table); + + $pagination = pagination ($total_agents, + 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 = get_db_row_filter('tagente', array('id_agente' => $this->idAgent)); + + $this->ips = get_agent_addresses($this->idAgent); + } + + public function show() { + $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/', print_os_icon($this->agent['id_os'])); + $table->data[3][0] = __('Last contact'); + $table->data[3][1] = $this->agent['ultimo_contacto']; + + 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 = get_db_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; + + $data = array(); + + $data[] = printTruncateText($module["nombre"], 10, 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 = 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(safe_output($module["datos"]),0,42); + } + + $data[] = str_replace('.png', '_ball.png', str_replace('images/status_sets', + '../images/status_sets', print_status_image($status, $title, true))); + + if ($module["id_tipo_modulo"] == 24) { // log4x + switch($module["datos"]) { + case 10: $salida = "TRACE"; $style="font-weight:bold; color:darkgreen;"; break; + case 20: $salida = "DEBUG"; $style="font-weight:bold; color:darkgreen;"; break; + case 30: $salida = "INFO"; $style="font-weight:bold; color:darkgreen;"; break; + case 40: $salida = "WARN"; $style="font-weight:bold; color:darkorange;"; break; + case 50: $salida = "ERROR"; $style="font-weight:bold; color:red;"; break; + case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break; + } + $salida = "$salida"; + } else { + if (is_numeric($module["datos"])){ + $salida = format_numeric($module["datos"]); + } else { + $salida = "".substr(safe_output($module["datos"]),0,12).""; + } + } + $data[] = $salida; + if ($module['estado'] == 3) { + $lastTime = ''; + } else { + $lastTime = ''; + } + $lastTime .= print_timestamp ($module["utimestamp"], true, array('units' => 'tiny')); + $lastTime .= ''; + $data[] = $lastTime; + + + $table->data[] = $data; + } + + print_table($table); + + $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(); + + echo "

" . __('Alerts') . "

"; + $alertsSimple = get_agent_alerts_simple (array($this->idAgent)); + foreach ($alertsSimple as $alert) { + if ($rowPair) + $table->rowclass[$iterator] = 'rowPair'; + else + $table->rowclass[$iterator] = 'rowOdd'; + $rowPair = !$rowPair; + + $data = array(); + + $data[] = printTruncateText(get_agentmodule_name($alert["id_agent_module"]), 10, true, true); + + $template = safe_output(get_alert_template ($alert['id_alert_template'])); + $data[] = printTruncateText(safe_output($template['name']), 10, true, true); + +// $actions = get_alert_agent_module_actions ($alert['id'], false, false); +// if (!empty($actions)){ +// $actionText = '
    '; +// foreach ($actions as $action) { +// $actionText .= '
  • ' . $action['name']; +// if ($action["fires_min"] != $action["fires_max"]){ +// $actionText .= " (".$action["fires_min"] . " / ". $action["fires_max"] . ")"; +// } +// $actionText .= '

  • '; +// } +// $actionText .= '
'; +// } +// else { +// if ($actionDefault != "") +// $actionText = get_db_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " (".__("Default") . ")"; +// } +// +// $data[] = $actionText; + $data[] = 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('.png', '_ball.png', str_replace('images/status_sets', + '../images/status_sets', print_status_image($status, $title, true))); + + $table->data[] = $data; + } + print_table($table); + +// echo "

" . __('Alerts compound') . "

"; +// +// $alertsCombined = get_agent_alerts_compound(array($this->idAgent)); +// +// $table->data = array(); +// foreach ($alertsCombined as $alert) { +// $data = array(); +// +// $table->data[] = $data; +// } + } +} +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 88f4c86bd4..93b95bac97 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -389,7 +389,8 @@ $custom_fields['text']= ''; if ($tab == 'graphs') { $graphs['active'] = true; -} else { +} +else { $graphs['active'] = false; }