Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop

This commit is contained in:
m-lopez-f 2015-01-19 13:25:15 +01:00
commit 69ee955e70
31 changed files with 3336 additions and 219 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

View File

@ -67,25 +67,15 @@ if ($search_modules) {
if ($get_module_detail) {
ui_include_time_picker();
ui_require_jquery_file("ui.datepicker-" . get_user_language(),
"include/javascript/i18n/");
ui_require_jquery_file ("ui-timepicker-addon");
// This script is included manually to be included after jquery and avoid error
echo '<script type="text/javascript" src="' .
ui_get_full_url('include/javascript/i18n/jquery-ui-timepicker-' .
get_user_language(), false, false, false) . '"></script>';
ui_require_jquery_file("ui.datepicker-" . get_user_language(),
"include/javascript/i18n/");
ui_include_time_picker();
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
$module_id = get_parameter ('id_module');
$period = get_parameter ("period", 86400);
$module_id = (int) get_parameter('id_module');
$period = (int) get_parameter("period", 86400);
$group = agents_get_agentmodule_group ($module_id);
$agentId = get_parameter("id_agent");
$server_name = get_parameter('server_name');
$agentId = (int) get_parameter("id_agent");
$server_name = (string) get_parameter('server_name');
if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name);

View File

@ -0,0 +1,131 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2012 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 Lesser General Public License
// as published by the Free Software Foundation; 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.
// Only accesible by ajax
if (is_ajax ()) {
global $config;
// Login check
check_login ();
require_once($config['homedir'] . "/include/class/Tree.class.php");
enterprise_include_once("include/class/Tree.class.php");
require_once($config['homedir'] . "/include/functions_reporting.php");
require_once($config['homedir'] . "/include/functions_os.php");
$getChildren = (bool)get_parameter('getChildren', 0);
$getGroupStatus = (bool)get_parameter('getGroupStatus', 0);
$get_detail = (bool) get_parameter('getDetail');
if ($getChildren) {
$type = get_parameter('type', 'group');
$filter = get_parameter('filter', array('searchAgent' => '', 'statusAgent' => AGENT_STATUS_ALL));
$id = (int)get_parameter('id', 0);
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
$countModuleStatusMethod = get_parameter('countModuleStatusMethod', 'on_demand');
$countAgentStatusMethod = get_parameter('countAgentStatusMethod', 'live');
if (class_exists('TreeEnterprise')) {
$tree = new TreeEnterprise($type,
$id,
$childrenMethod,
$countModuleStatusMethod,
$countAgentStatusMethod
);
}
else {
$tree = new Tree($type,
$id,
$childrenMethod,
$countModuleStatusMethod,
$countAgentStatusMethod
);
}
$tree->setFilter(array(
'statusAgent' => $filter['statusAgent'],
'searchAgent' => $filter['searchAgent'])
);
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
return;
}
if ($getGroupStatus) {
$id = (int)get_parameter('id', 0);
$type = get_parameter('type', 'group');
$id = 0;
$status = array();
switch ($type) {
case 'group':
$data = reporting_get_group_stats($id);
$status['unknown'] = $data['agents_unknown'];
$status['critical'] = $data['agent_critical'];
$status['warning'] = $data['agent_warning'];
$status['not_init'] = $data['agent_not_init'];
$status['ok'] = $data['agent_ok'];
$status['total'] = $data['total_agents'];
$status['status'] = $data['status'];
$status['alert_fired'] = $data['alert_fired'];
echo json_encode($status);
break;
}
return;
}
if ($get_detail) {
require_once($config['homedir']."/include/functions_treeview.php");
// Clean the output
ob_clean();
$id = (int) get_parameter('id');
$type = (string) get_parameter('type');
$server = array();
if (defined ('METACONSOLE')) {
$server_name = (string) get_parameter('server');
$server = metaconsole_get_connection($server_name);
metaconsole_connect($server);
}
switch ($type) {
case 'agent':
treeview_printTable($id, $server);
break;
case 'module':
treeview_printModuleTable($id, $server);
break;
case 'alert':
treeview_printAlertsTable($id, $server);
break;
default:
// Nothing
break;
}
if (!empty($server) && defined ('METACONSOLE')) {
metaconsole_restore_db();
}
return;
}
return;
}
?>

File diff suppressed because it is too large Load Diff

147
pandora_console/include/constants.php Normal file → Executable file
View File

@ -19,25 +19,25 @@
*/
/* Enterprise hook constant */
define ('ENTERPRISE_NOT_HOOK', -1);
define ('ENTERPRISE_NOT_HOOK', -1);
/**/
define('DATE_FORMAT', 'Y/m/d');
define('DATE_FORMAT_JS', 'yy/mm/d');
define('TIME_FORMAT', 'H:i:s');
define('TIME_FORMAT_JS', 'HH:mm:ss');
define('DATE_FORMAT', 'Y/m/d');
define('DATE_FORMAT_JS', 'yy/mm/d');
define('TIME_FORMAT', 'H:i:s');
define('TIME_FORMAT_JS', 'HH:mm:ss');
/* Events state constants */
define ('EVENT_NEW', 0);
define ('EVENT_VALIDATE', 1);
define ('EVENT_PROCESS', 2);
define ('EVENT_NEW', 0);
define ('EVENT_VALIDATE', 1);
define ('EVENT_PROCESS', 2);
/* Agents disabled status */
define ('AGENT_ENABLED',0);
define ('AGENT_DISABLED',1);
define ('AGENT_ENABLED', 0);
define ('AGENT_DISABLED', 1);
@ -97,10 +97,10 @@ define('SECONDS_3YEARS', 93312000);
/* Separator constats */
define('SEPARATOR_COLUMN', ';');
define('SEPARATOR_ROW', chr(10)); //chr(10) = '\n'
define('SEPARATOR_COLUMN_CSV', "#");
define('SEPARATOR_ROW_CSV', "@\n");
define('SEPARATOR_COLUMN', ';');
define('SEPARATOR_ROW', chr(10)); //chr(10) = '\n'
define('SEPARATOR_COLUMN_CSV', "#");
define('SEPARATOR_ROW_CSV', "@\n");
@ -108,72 +108,72 @@ define('SEPARATOR_ROW_CSV', "@\n");
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
define ('BACKUP_DIR', 'attachment/backups');
define ('BACKUP_FULLPATH', $config['homedir'] . '/' . BACKUP_DIR);
define ('BACKUP_DIR', 'attachment/backups');
define ('BACKUP_FULLPATH', $config['homedir'] . '/' . BACKUP_DIR);
break;
case "oracle":
define ('BACKUP_DIR', 'DATA_PUMP_DIR');
define ('BACKUP_FULLPATH', 'DATA_PUMP_DIR');
define ('BACKUP_DIR', 'DATA_PUMP_DIR');
define ('BACKUP_FULLPATH', 'DATA_PUMP_DIR');
break;
}
/* Color constants */
define('COL_CRITICAL','#f85858');
define('COL_WARNING','#ffea59');
define('COL_WARNING_DARK','#FFB900');
define('COL_NORMAL','#6EB432');
define('COL_NOTINIT','#3BA0FF');
define('COL_UNKNOWN','#AAAAAA');
define('COL_ALERTFIRED','#FF8800');
define('COL_MINOR','#F099A2');
define('COL_MAJOR','#C97A4A');
define('COL_INFORMATIONAL','#E4E4E4');
define('COL_MAINTENANCE','#3BA0FF');
define('COL_CRITICAL', '#f85858');
define('COL_WARNING', '#ffea59');
define('COL_WARNING_DARK', '#FFB900');
define('COL_NORMAL', '#6EB432');
define('COL_NOTINIT', '#3BA0FF');
define('COL_UNKNOWN', '#AAAAAA');
define('COL_ALERTFIRED', '#FF8800');
define('COL_MINOR', '#F099A2');
define('COL_MAJOR', '#C97A4A');
define('COL_INFORMATIONAL', '#E4E4E4');
define('COL_MAINTENANCE', '#3BA0FF');
define('COL_GRAPH1', '#C397F2');
define('COL_GRAPH2', '#FFE66C');
define('COL_GRAPH3', '#92CCA3');
define('COL_GRAPH4', '#EA6D5B');
define('COL_GRAPH5', '#6BD8DD');
define('COL_GRAPH6', '#F49B31');
define('COL_GRAPH7', '#999999');
define('COL_GRAPH8', '#F2B8C1');
define('COL_GRAPH9', '#C4E8C1');
define('COL_GRAPH10', '#C1DBE5');
define('COL_GRAPH11', '#C9C1e0');
define('COL_GRAPH12', '#F45B95');
define('COL_GRAPH13', '#E83128');
define('COL_GRAPH1', '#C397F2');
define('COL_GRAPH2', '#FFE66C');
define('COL_GRAPH3', '#92CCA3');
define('COL_GRAPH4', '#EA6D5B');
define('COL_GRAPH5', '#6BD8DD');
define('COL_GRAPH6', '#F49B31');
define('COL_GRAPH7', '#999999');
define('COL_GRAPH8', '#F2B8C1');
define('COL_GRAPH9', '#C4E8C1');
define('COL_GRAPH10', '#C1DBE5');
define('COL_GRAPH11', '#C9C1e0');
define('COL_GRAPH12', '#F45B95');
define('COL_GRAPH13', '#E83128');
/* The styles */
/* Size of text in characters for truncate */
define('GENERIC_SIZE_TEXT', 25);
define('GENERIC_SIZE_TEXT', 25);
/* Agent module status */
define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1);
define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100);
define('AGENT_MODULE_STATUS_NO_DATA', 4);
define('AGENT_MODULE_STATUS_NORMAL', 0);
define('AGENT_MODULE_STATUS_NORMAL_ALERT', 300);
define('AGENT_MODULE_STATUS_NOT_NORMAL', 6);
define('AGENT_MODULE_STATUS_WARNING', 2);
define('AGENT_MODULE_STATUS_WARNING_ALERT', 200);
define('AGENT_MODULE_STATUS_UNKNOWN', 3);
define('AGENT_MODULE_STATUS_NOT_INIT', 5);
define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1);
define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100);
define('AGENT_MODULE_STATUS_NO_DATA', 4);
define('AGENT_MODULE_STATUS_NORMAL', 0);
define('AGENT_MODULE_STATUS_NORMAL_ALERT', 300);
define('AGENT_MODULE_STATUS_NOT_NORMAL', 6);
define('AGENT_MODULE_STATUS_WARNING', 2);
define('AGENT_MODULE_STATUS_WARNING_ALERT', 200);
define('AGENT_MODULE_STATUS_UNKNOWN', 3);
define('AGENT_MODULE_STATUS_NOT_INIT', 5);
/* Agent status */
define('AGENT_STATUS_ALL', -1);
define('AGENT_STATUS_CRITICAL', 1);
define('AGENT_STATUS_NORMAL', 0);
define('AGENT_STATUS_NOT_INIT', 5);
define('AGENT_STATUS_NOT_NORMAL', 6);
define('AGENT_STATUS_UNKNOWN', 3);
define('AGENT_STATUS_ALERT_FIRED', 4);
define('AGENT_STATUS_WARNING', 2);
define('AGENT_STATUS_ALL', -1);
define('AGENT_STATUS_CRITICAL', 1);
define('AGENT_STATUS_NORMAL', 0);
define('AGENT_STATUS_NOT_INIT', 5);
define('AGENT_STATUS_NOT_NORMAL', 6);
define('AGENT_STATUS_UNKNOWN', 3);
define('AGENT_STATUS_ALERT_FIRED', 4);
define('AGENT_STATUS_WARNING', 2);
/* Visual maps contants */
@ -260,6 +260,31 @@ define ('STATUS_SERVER_OK', 'server_ok.png');
define ('STATUS_SERVER_DOWN', 'server_down.png');
/* Status images (ball) */
//For modules
define ('STATUS_MODULE_OK_BALL', 'module_ok_ball.png');
define ('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png');
define ('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png');
define ('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png');
define ('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png');
//For agents
define ('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png');
define ('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png');
define ('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png');
define ('STATUS_AGENT_UNKNOWN_BALL', 'agent_unknown_ball.png');
define ('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png');
define ('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png');
define ('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png');
define ('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png');
//For alerts
define ('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png');
define ('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png');
define ('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png');
//For servers
define ('STATUS_SERVER_OK_BALL', 'server_ok_ball.png');
define ('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png');
/* Events criticity */
define ('EVENT_CRIT_MAINTENANCE', 0);

View File

@ -370,7 +370,8 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$where = db_format_array_where_clause_sql ($filter, 'AND', '');
$where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', '');
$where_nogroup = db_format_array_where_clause_sql(
$filter_nogroup, 'AND', '');
if ($where_nogroup == '') {
$where_nogroup = '1 = 1';
@ -1861,7 +1862,7 @@ function agents_get_agent_group ($id_agent) {
* @return mixed The incidents attached or false
*/
function agents_get_count_incidents ($id_agent) {
if (empty($id_agent)){
if (empty($id_agent)) {
return false;
}
@ -2023,6 +2024,18 @@ function agents_tree_view_alert_img ($alert_fired) {
}
}
//Returns the alert ball image to display tree view
function agents_tree_view_alert_img_ball ($alert_fired) {
if ($alert_fired) {
return ui_print_status_image (STATUS_ALERT_FIRED_BALL, __('Alert fired'), true);
}
else {
return ui_print_status_image (STATUS_ALERT_NOT_FIRED_BALL, __('Alert not fired'), true);
}
}
//Returns the status image to display tree view
function agents_tree_view_status_img ($critical, $warning, $unknown, $total, $notinit) {
@ -2043,7 +2056,33 @@ function agents_tree_view_status_img ($critical, $warning, $unknown, $total, $no
__('At least one module is in UKNOWN status'), true);
}
else {
return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
return ui_print_status_image (STATUS_AGENT_OK,
__('All Monitors OK'), true);
}
}
//Returns the status ball image to display tree view
function agents_tree_view_status_img_ball ($critical, $warning, $unknown, $total, $notinit) {
if ($total == 0 || $total == $notinit) {
return ui_print_status_image (STATUS_AGENT_NO_MONITORS_BALL,
__('No Monitors'), true);
}
if ($critical > 0) {
return ui_print_status_image (STATUS_AGENT_CRITICAL_BALL,
__('At least one module in CRITICAL status'), true);
}
else if ($warning > 0) {
return ui_print_status_image (STATUS_AGENT_WARNING_BALL,
__('At least one module in WARNING status'), true);
}
else if ($unknown > 0) {
return ui_print_status_image (STATUS_AGENT_DOWN_BALL,
__('At least one module is in UKNOWN status'), true);
}
else {
return ui_print_status_image (STATUS_AGENT_OK_BALL,
__('All Monitors OK'), true);
}
}

View File

@ -278,8 +278,12 @@ function groups_get_parents($parent, $onlyPropagate = false, $groups = null) {
continue;
}
if (($group['id_grupo'] == $parent) && ($group['propagate'] || !$onlyPropagate)) {
$return = $return + array($group['id_grupo'] => $group) + groups_get_parents($group['parent'], $onlyPropagate, $groups);
if (($group['id_grupo'] == $parent)
&& ($group['propagate'] || !$onlyPropagate)) {
$return = $return +
array($group['id_grupo'] => $group) +
groups_get_parents($group['parent'], $onlyPropagate, $groups);
}
}
@ -402,7 +406,10 @@ function groups_get_all($groupWithAgents = false) {
global $config;
if ($groupWithAgents)
$sql .= ' WHERE id_grupo IN (SELECT id_grupo FROM tagente GROUP BY id_grupo)';
$sql .= ' WHERE id_grupo IN (
SELECT id_grupo
FROM tagente
GROUP BY id_grupo)';
switch ($config['dbtype']) {
case "mysql":
@ -1828,9 +1835,10 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
if ($id_user == false) {
$id_user = $config['id_user'];
}
$user_groups = array();
$user_tags = array();
$groups_without_tags = array();
foreach ($acltags as $group => $tags) {
if ($user_strict) { //Remove groups with tags
if ($tags == '') {
@ -1852,34 +1860,31 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
} else {
$user_groups_ids = implode(',',array_keys($acltags));
}
if ($user_groups_ids == '') {
$user_groups_ids == -1;
}
switch ($config["dbtype"]) {
case "mysql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
case "postgresql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre ASC");
break;
case "oracle":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
if (!empty($user_groups_ids)) {
switch ($config["dbtype"]) {
case "mysql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
case "postgresql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre ASC");
break;
case "oracle":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
}
}
if ($list_groups == false) {
@ -1924,6 +1929,9 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_name_'] = $item['nombre'];
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
if ($mode == 'tree' && !empty($item['parent']))
$list[$i]['_parent_id_'] = $item['parent'];
$list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"];
$list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
$list[$i]['_total_agents_'] = $group_stat[0]["agents"];
@ -1936,7 +1944,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id);
$list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id);
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = $group_stat[0]["normal"];
$list[$i]['_agents_warning_'] = $group_stat[0]["warning"];
$list[$i]['_agents_critical_'] = $group_stat[0]["critical"];
@ -1945,7 +1953,8 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"];
$list[$i]["_total_checks_"] = $group_stat[0]["modules"];
$list[$i]["_total_alerts_"] = $group_stat[0]["alerts"];
}
if ($mode == 'tactical') {
// Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
@ -2002,7 +2011,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $group_stat[0]["normal"];
$list[0]['_agents_warning_'] += $group_stat[0]["warning"];
$list[0]['_agents_critical_'] += $group_stat[0]["critical"];
@ -2010,7 +2019,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
}
}
if ($mode == 'group') {
if ($mode == 'group' || $mode == 'tree') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
@ -2027,6 +2036,9 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_name_'] = $item['nombre'];
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
if ($mode == 'tree' && !empty($item['parent']))
$list[$i]['_parent_id_'] = $item['parent'];
$list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id);
$list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id);
$list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id);
@ -2037,7 +2049,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id);
$list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id);
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = groups_agent_ok ($id, $user_strict, $id);
$list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id);
$list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id);
@ -2103,7 +2115,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
$list[0]['_agents_warning_'] += $list[$i]['_agents_warning_'];
$list[0]['_agents_critical_'] += $list[$i]['_agents_critical_'];
@ -2111,7 +2123,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
}
}
if ($mode == 'group') {
if ($mode == 'group' || $mode == 'tree') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
@ -2142,7 +2154,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags);
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags);
$list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags);
$list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags);
@ -2160,7 +2172,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_'];
if ($mode == 'tactical') {
if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
$list[0]['_agents_warning_'] += $list[$i]['_agents_warning_'];
$list[0]['_agents_critical_'] += $list[$i]['_agents_critical_'];
@ -2168,7 +2180,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
}
}
if ($mode == 'group') {
if ($mode == 'group' || $mode == 'tree') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
@ -2270,4 +2282,4 @@ function groups_get_group_deep ($id_group) {
return $deep;
}
?>
?>

View File

@ -1766,24 +1766,17 @@ function html_print_image ($src, $return = false, $options = false,
else {
$options['class'] = 'forced_title';
}
if (!isset ($options['id'])) {
$options['id'] = uniqid();
}
$params = array(
'id' => 'forced_title_' . $options['id'],
'class' => 'forced_title_layer',
'content' => $options["title"],
'hidden' => true);
$output = html_print_div($params, true) . $output;
// New way to show the force_title (cleaner and better performance)
$output .= 'title="'.io_safe_input_html($options["title"]).'" ';
$output .= 'data-use_title_for_force_title="1" ';
}
//Valid attributes (invalid attributes get skipped)
$attrs = array ("height", "longdesc", "usemap","width","id",
"class","lang","xml:lang", "onclick", "ondblclick",
$attrs = array ("height", "longdesc", "usemap", "width", "id",
"class", "lang", "xml:lang", "onclick", "ondblclick",
"onmousedown", "onmouseup", "onmouseover", "onmousemove",
"onmouseout", "onkeypress", "onkeydown", "onkeyup","pos_tree");
"onmouseout", "onkeypress", "onkeydown", "onkeyup", "pos_tree");
foreach ($attrs as $attribute) {
if (isset ($options[$attribute])) {

3
pandora_console/include/functions_modules.php Normal file → Executable file
View File

@ -875,7 +875,8 @@ function modules_is_string_type ($id_type) {
* @return string The name of the icon.
*/
function modules_get_type_icon ($id_type) {
return (string) db_get_value ('icon', 'ttipo_modulo', 'id_tipo', (int) $id_type);
return (string) db_get_value ('icon', 'ttipo_modulo', 'id_tipo',
(int) $id_type);
}
/**

View File

@ -66,4 +66,12 @@ function os_get_name($id_os) {
return db_get_value ('name', 'tconfig_os', 'id_os', (int) $id_os);
}
function os_get_os() {
$op_systems = db_get_all_rows_in_table('tconfig_os');
if (empty($op_systems))
$op_systems = array();
return $op_systems;
}
?>

View File

@ -2022,6 +2022,32 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') {
$data["server_sanity"] = format_numeric (100 - $data["module_sanity"], 1);
$data['alert_fired'] = 0;
if ($data["monitor_alerts_fired"] > 0) {
$data['alert_fired'] = 1;
}
if ($data["monitor_critical"] > 0) {
$data['status'] = 'critical';
}
elseif ($data["monitor_warning"] > 0) {
$data['status'] = 'warning';
}
elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) {
$data['status'] = 'unknown';
}
elseif ($data["monitor_ok"] > 0) {
$data['status'] = 'ok';
}
elseif ($data["agent_not_init"] > 0) {
$data['status'] = 'not_init';
}
else {
$data['status'] = 'none';
}
return ($data);
}

View File

@ -274,18 +274,11 @@ function treeview_printTable($id_agente, $server_data = array()) {
$url_hash = metaconsole_get_servers_url_hash($server_data);
}
require_once ("include/functions_agents.php");
require_once ($config["homedir"] . "/include/functions_agents.php");
require_once ($config["homedir"] . '/include/functions_graph.php');
include_graphs_dependencies();
require_once ($config['homedir'] . '/include/functions_groups.php');
require_once ($config['homedir'] . '/include/functions_gis.php');
$agent = db_get_row ("tagente", "id_agente", $id_agente);
if ($agent === false) {
ui_print_error_message(__('There was a problem loading agent'));
return;
}
include_graphs_dependencies();
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
@ -300,11 +293,21 @@ function treeview_printTable($id_agente, $server_data = array()) {
return;
}
echo '<div id="id_div3" width="450px">';
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%; min-width: 300px;">';
//Agent name
echo '<tr><td class="datos"><b>'.__('Agent name').'</b></td>';
$agent = db_get_row ("tagente", "id_agente", $id_agente);
if ($agent === false) {
ui_print_error_message(__('There was a problem loading agent'));
return;
}
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->data = array();
// Agent name
if ($agent['disabled']) {
$cellName = "<em>";
}
@ -317,12 +320,13 @@ function treeview_printTable($id_agente, $server_data = array()) {
if ($agent['disabled']) {
$cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>";
}
echo '<td class="datos"><b>'.$cellName.'</b></td>';
$row = array();
$row['title'] = __('Agent name');
$row['data'] = $cellName;
$table->data['name'] = $row;
//Addresses
echo '<tr><td class="datos2"><b>'.__('IP Address').'</b></td>';
echo '<td class="datos2" colspan="2">';
$ips = array();
$addresses = agents_get_addresses ($id_agente);
$address = agents_get_address($id_agente);
@ -333,95 +337,115 @@ function treeview_printTable($id_agente, $server_data = array()) {
}
}
echo $address;
if (!empty($addresses)) {
ui_print_help_tip(__('Other IP addresses').': <br>'.implode('<br>',$addresses));
$address .= ui_print_help_tip(__('Other IP addresses').': <br>'.implode('<br>',$addresses), true);
}
echo '</td></tr>';
$row = array();
$row['title'] = __('IP Address');
$row['data'] = $address;
$table->data['address'] = $row;
// Agent Interval
echo '<tr><td class="datos"><b>'.__('Interval').'</b></td>';
echo '<td class="datos" colspan="2">'.human_time_description_raw ($agent["intervalo"]).'</td></tr>';
$row = array();
$row['title'] = __('Interval');
$row['data'] = human_time_description_raw ($agent["intervalo"]);
$table->data['interval'] = $row;
// Comments
echo '<tr><td class="datos2"><b>' . __('Description') . '</b></td>';
echo '<td class="datos2" colspan="2">' . $agent["comentarios"] . '</td></tr>';
$row = array();
$row['title'] = __('Description');
$row['data'] = $agent["comentarios"];
$table->data['description'] = $row;
// Last contact
echo '<tr><td class="datos2"><b>' . __('Last contact') . " / " . __('Remote') . '</b></td><td class="datos2 f9" colspan="2">';
ui_print_timestamp ($agent["ultimo_contacto"]);
echo " / ";
$last_contact = ui_print_timestamp($agent["ultimo_contacto"], true);
if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") {
echo __('Never');
$last_remote_contact = __('Never');
}
else {
ui_print_timestamp ($agent["ultimo_contacto_remoto"]);
$last_remote_contact = ui_print_timestamp ($agent["ultimo_contacto_remoto"], true);
}
echo '</td></tr>';
$row = array();
$row['title'] = __('Last contact') . " / " . __('Remote');
$row['data'] = "$last_contact / $last_remote_contact";
$table->data['contact'] = $row;
// Next contact (agent)
$progress = agents_get_next_contact($id_agente);
echo '<tr><td class="datos"><b>'.__('Next agent contact').'</b></td>';
echo '<td class="datos f9" colspan="2">' . progress_bar($progress, 150, 20) . '</td></tr>';
$row = array();
$row['title'] = __('Next agent contact');
$row['data'] = progress_bar($progress, 150, 20);
$table->data['next_contact'] = $row;
//End of table
echo '</table></div>';
$agent_table = html_print_table($table, true);
if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo '<div style="width:90%; text-align: right; min-width: 300px;">';
echo '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"');
echo '</form>';
echo '</div>';
$go_to_agent = '<div style="text-align: right;">';
$go_to_agent .= '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
$go_to_agent .= '</form>';
$go_to_agent .= '</div>';
$agent_table .= $go_to_agent;
}
$agent_table .= "<br>";
// print agent data toggle
ui_toggle($agent_table, __('Agent data'), '', false);
// Advanced data
$advanced = '<div id="id_div3" width="450px">';
$advanced .= '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%;">';
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->data = array();
// Agent version
$advanced .= '<tr><td class="datos2"><b>'.__('Agent Version'). '</b></td>';
$advanced .= '<td class="datos2" colspan="2">'.$agent["agent_version"].'</td></tr>';
$row = array();
$row['title'] = __('Agent Version');
$row['data'] = $agent["agent_version"];
$table->data['agent_version'] = $row;
// Position Information
if ($config['activate_gis']) {
$dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']);
$advanced .= '<tr><td class="datos2"><b>'.__('Position (Long, Lat)'). '</b></td>';
$advanced .= '<td class="datos2" colspan="2">';
if ($dataPositionAgent === false) {
$advanced .= __('There is no GIS data.');
}
else {
$advanced .= '<a href="' . $console_url . 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente='.$id_agente.'">';
if ($dataPositionAgent !== false) {
$position = '<a href="' . $console_url . 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente='.$id_agente.'">';
if ($dataPositionAgent['description'] != "")
$advanced .= $dataPositionAgent['description'];
$position .= $dataPositionAgent['description'];
else
$advanced .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'];
$advanced .= "</a>";
$position .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'];
$position .= "</a>";
$row = array();
$row['title'] = __('Position (Long, Lat)');
$row['data'] = $position;
$table->data['agent_position'] = $row;
}
$advanced .= '</td></tr>';
}
// If the url description is setted
if ($agent['url_address'] != '') {
$advanced .= '<tr><td class="datos"><b>'.__('Url address').'</b></td>';
$advanced .= '<td class="datos2" colspan="2"><a href='.$agent["url_address"].'>' . $agent["url_address"] . '</a></td></tr>';
$row = array();
$row['title'] = __('Url address');
$row['data'] = '<a href='.$agent["url_address"].'>'.$agent["url_address"].'</a>';
$table->data['agent_address'] = $row;
}
// Timezone Offset
if ($agent['timezone_offset'] != 0) {
$advanced .= '<tr><td class="datos2"><b>'.__('Timezone Offset'). '</b></td>';
$advanced .= '<td class="datos2" colspan="2">'.$agent["timezone_offset"].'</td></tr>';
$row = array();
$row['title'] = __('Timezone Offset');
$row['data'] = $agent["timezone_offset"];
$table->data['agent_timezone_offset'] = $row;
}
// Custom fields
@ -431,39 +455,39 @@ function treeview_printTable($id_agente, $server_data = array()) {
}
if ($fields) {
foreach ($fields as $field) {
$advanced .= '<tr><td class="datos"><b>'.$field['name'] . ui_print_help_tip (__('Custom field'), true).'</b></td>';
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if ($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>';
if (!empty($custom_value)) {
$row = array();
$row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true);
$row['data'] = $custom_value;
$table->data['custom_field_'.$field['id_field']] = $row;
}
$advanced .= '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
}
}
//End of table advanced
$advanced .= '</table></div><br>';
$table_advanced = html_print_table($table, true);
$table_advanced .= "<br>";
ui_toggle($advanced, __('Advanced information'));
ui_toggle($table_advanced, __('Advanced information'));
// Blank space below title, DONT remove this, this
// Breaks the layout when Flash charts are enabled :-o
//echo '<div id="id_div" style="height: 10px">&nbsp;</div>';
if ($config["agentaccess"]) {
$access_graph = '<div style="width: 290px; margin-left: 30px;">';
$access_graph = '<div style="margin-left: 10px;">';
$access_graph .= graphic_agentaccess($id_agente, 290, 110, 86400, true);
$access_graph .= '</div><br>';
ui_toggle($access_graph, __('Agent access rate (24h)'));
}
$events_graph = '<div style="width: 290px; height: 15px; margin-left: 30px; position: static;">';
$events_graph = '<div style="margin-left: 10px;">';
$events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, 86400, '', true);
$events_graph .= '</div><br><br>';
$events_graph .= '</div><br>';
ui_toggle($events_graph, __('Events (24h)'));
echo '<br>';
return;
}

View File

@ -588,7 +588,12 @@ function ui_print_group_icon_path ($id_group, $return = false, $path = "images/g
*
* @return string HTML with icon of the OS
*/
function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = true, $networkmap = false, $only_src = false, $relative = false, $options = false) {
function ui_print_os_icon ($id_os, $name = true, $return = false,
$apply_skin = true, $networkmap = false, $only_src = false,
$relative = false, $options = false) {
$subfolter = 'os_icons';
if ($networkmap) {
$subfolter = 'networkmap';
@ -598,7 +603,8 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
$os_name = get_os_name ($id_os);
if (empty ($icon)) {
if ($only_src) {
$output = html_print_image("images/" . $subfolter . "/unknown.png", false, $options, true, $relative);
$output = html_print_image("images/" . $subfolter . "/unknown.png",
true, $options, true, $relative);
}
else {
return "-";

View File

@ -181,7 +181,16 @@ function forced_title_callback() {
// Put title in the layer
///////////////////////////////////////////
var title = $('#forced_title_'+img_id).html();
// If the '.forced_title' element has 'use_title_for_force_title' = 1
// into their 'data' prop, the element title will be used for the
// content.
if ($(this).data("use_title_for_force_title")) {
var title = $(this).prop("title");
}
else {
var title = $('#forced_title_'+img_id).html();
}
$('#forced_title_layer').html(title);
///////////////////////////////////////////

View File

@ -0,0 +1,840 @@
// 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 Lesser General Public License
// as published by the Free Software Foundation; 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.
var TreeController;
var TreeNodeDetailController;
TreeController = {
controllers: [],
getController: function () {
var controller = {
index: -1,
recipient: '',
tree: [],
emptyMessage: "Empty",
errorMessage: "Error",
baseURL: "",
ajaxURL: "ajax.php",
ajaxPage: "include/ajax/tree.ajax",
detailRecipient: '',
filter: {},
counterTitles: {},
reload: function () {
// Bad recipient
if (typeof this.recipient == 'undefined' || this.recipient.length == 0) {
return;
}
// Load branch
function _processGroup (container, elements, rootGroup) {
var $group = $("<ul></ul>");
// First group
if (typeof rootGroup != 'undefinded' && rootGroup == true) {
$group
.addClass("tree-root")
.hide()
.prepend('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')+'images/pandora.ico.gif" />');
}
// Normal group
else {
$group
.addClass("tree-group")
.hide();
}
container.append($group);
elements.forEach(function(element, index) {
element.jqObject = _processNode($group, element);
}, $group);
return $group;
}
// Load leaf counters
function _processNodeCounters (container, counters, type) {
if (typeof counters != 'undefined') {
function _processNodeCounterTitle (container, elementType, counterType) {
var defaultCounterTitles = {
total: {
agents: "Total agents",
modules: "Total modules",
none: "Total"
},
fired: {
agents: "Alert fired",
modules: "Alert fired",
none: "Alert fired"
},
critical: {
agents: "Critical agents",
modules: "Critical modules",
none: "Critical"
},
warning: {
agents: "Warning agents",
modules: "Warning modules",
none: "Warning"
},
unknown: {
agents: "Unknown agents",
modules: "Unknown modules",
none: "Unknown"
},
not_init: {
agents: "Not init agents",
modules: "Not init modules",
none: "Not init"
},
ok: {
agents: "Normal agents",
modules: "Normal modules",
none: "Normal"
}
}
try {
var title = '';
switch (elementType) {
case "group":
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].agents != 'undefined') {
title = controller.counterTitles[counterType].agents;
}
else {
title = defaultCounterTitles[counterType].agents;
}
break;
case "agent":
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].modules != 'undefined') {
title = controller.counterTitles[counterType].modules;
}
else {
title = defaultCounterTitles[counterType].modules;
}
break;
default:
if (typeof controller.counterTitles != 'undefined'
&& typeof controller.counterTitles[counterType] != 'undefined'
&& typeof controller.counterTitles[counterType].none != 'undefined') {
title = controller.counterTitles[counterType].none;
}
else {
title = defaultCounterTitles[counterType].none;
}
break;
}
if (title.length > 0) {
container
.prop("title", title)
.addClass("forced_title")
.data("use_title_for_force_title", 1); // Trick to make easier the 'force title' output
}
}
catch (error) {
// console.log(error);
}
}
var $counters = $("<div></div>");
$counters.addClass('tree-node-counters');
if (typeof counters.total != 'undefined'
&& counters.total > 0) {
var $totalCounter = $("<div></div>");
$totalCounter
.addClass('tree-node-counter')
.addClass('total')
.html(counters.total);
_processNodeCounterTitle($totalCounter, type, "total");
// Open the parentheses
$counters.append(" (");
$counters.append($totalCounter);
if (typeof counters.fired != 'undefined'
&& counters.fired > 0) {
var $firedCounter = $("<div></div>");
$firedCounter
.addClass('tree-node-counter')
.addClass('fired')
.addClass('orange')
.html(counters.fired);
_processNodeCounterTitle($firedCounter, type, "fired");
$counters
.append(" : ")
.append($firedCounter);
}
if (typeof counters.critical != 'undefined'
&& counters.critical > 0) {
var $criticalCounter = $("<div></div>");
$criticalCounter
.addClass('tree-node-counter')
.addClass('critical')
.addClass('red')
.html(counters.critical);
_processNodeCounterTitle($criticalCounter, type, "critical");
$counters
.append(" : ")
.append($criticalCounter);
}
if (typeof counters.warning != 'undefined'
&& counters.warning > 0) {
var $warningCounter = $("<div></div>");
$warningCounter
.addClass('tree-node-counter')
.addClass('warning')
.addClass('yellow')
.html(counters.warning);
_processNodeCounterTitle($warningCounter, type, "warning");
$counters
.append(" : ")
.append($warningCounter);
}
if (typeof counters.unknown != 'undefined'
&& counters.unknown > 0) {
var $unknownCounter = $("<div></div>");
$unknownCounter
.addClass('tree-node-counter')
.addClass('unknown')
.addClass('grey')
.html(counters.unknown);
_processNodeCounterTitle($unknownCounter, type, "unknown");
$counters
.append(" : ")
.append($unknownCounter);
}
if (typeof counters.not_init != 'undefined'
&& counters.not_init > 0) {
var $notInitCounter = $("<div></div>");
$notInitCounter
.addClass('tree-node-counter')
.addClass('not_init')
.addClass('blue')
.html(counters.not_init);
_processNodeCounterTitle($notInitCounter, type, "not_init");
$counters
.append(" : ")
.append($notInitCounter);
}
if (typeof counters.ok != 'undefined'
&& counters.ok > 0) {
var $okCounter = $("<div></div>");
$okCounter
.addClass('tree-node-counter')
.addClass('ok')
.addClass('green')
.html(counters.ok);
_processNodeCounterTitle($okCounter, type, "ok");
$counters
.append(" : ")
.append($okCounter);
}
// Close the parentheses
$counters.append(")");
}
// Add the counters html to the container
container.append($counters);
}
// Load the counters asynchronously
// else if (typeof element.searchCounters != 'undefined' && element.searchCounters) {
// var $counters = $("<div></div>");
// $counters
// .addClass('tree-node-counters')
// .append(' (')
// .append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')+'images/spinner.gif" />')
// .append(')');
// $content.append($counters);
// }
}
// Load leaf
function _processNode (container, element) {
var $node = $("<li></li>");
var $leafIcon = $("<div></div>");
var $content = $("<div></div>");
// Leaf icon
$leafIcon.addClass("leaf-icon");
// Content
$content.addClass("node-content");
switch (element.type) {
case 'group':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/groups_small/'+element.icon+'" /> ');
}
else if (typeof element.iconHTML != 'undefined' && element.iconHTML.length > 0) {
$content.append(element.iconHTML);
}
$content.append(element.name);
break;
case 'agent':
// Status image
if (typeof element.statusImageHTML != 'undefined'
&& element.statusImageHTML.length > 0) {
var $statusImage = $(element.statusImageHTML);
$statusImage.addClass("agent-status");
$content.append($statusImage);
}
// Alerts fired image
if (typeof element.alertImageHTML != 'undefined'
&& element.alertImageHTML.length > 0) {
var $alertImage = $(element.alertImageHTML);
$alertImage.addClass("agent-alerts-fired");
$content.append($alertImage);
}
$content.append(element.name);
break;
case 'module':
// Status image
if (typeof element.statusImageHTML != 'undefined'
&& element.statusImageHTML.length > 0) {
var $statusImage = $(element.statusImageHTML);
$statusImage.addClass("module-status");
$content.append($statusImage);
}
// Server type
if (typeof element.serverTypeHTML != 'undefined'
&& element.serverTypeHTML.length > 0
&& element.serverTypeHTML != '--') {
var $serverTypeImage = $(element.serverTypeHTML);
$serverTypeImage.addClass("module-server-type");
$content.append($serverTypeImage);
}
// Graph pop-up
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/chart_curve.png" /> ');
$graphImage
.addClass('module-graph')
.click(function (e) {
e.preventDefault();
try {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
console.log(error);
}
});
// Data pop-up
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/binary.png" /> ');
$dataImage
.addClass('module-data')
.click(function (e) {
e.preventDefault();
try {
if ($("#module_details_window").length > 0)
show_module_detail_dialog(element.id, '', '', 0, 86400);
}
catch (error) {
console.log(error);
}
});
$content
.append($graphImage)
.append($dataImage)
.append(element.name);
break;
case 'os':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/os_icons/'+element.icon+'" /> ');
}
$content.append(element.name);
break;
case 'tag':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/os_icons/'+element.icon+'" /> ');
}
else {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/tag_red.png" /> ');
}
$content.append(element.name);
break;
default:
$content.append(element.name);
break;
}
// Load the status counters
_processNodeCounters($content, element.counters, element.type);
// If exist the detail container, show the data
if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) {
$content.click(function (e) {
TreeNodeDetailController.getController().init({
recipient: controller.detailRecipient,
type: element.type,
id: element.id,
baseURL: controller.baseURL,
ajaxURL: controller.ajaxURL,
ajaxPage: controller.ajaxPage
});
});
}
$node
.addClass("tree-node")
.append($leafIcon)
.append($content);
container.append($node);
$node.addClass("leaf-empty");
if (typeof element.children != 'undefined' && element.children.length > 0) {
$node
.removeClass("leaf-empty")
.addClass("leaf-closed");
// Add children
var $children = _processGroup($node, element.children);
$node.data('children', $children);
if (typeof element.searchChildren == 'undefined' || !element.searchChildren) {
$leafIcon.click(function (e) {
e.preventDefault();
if ($node.hasClass("leaf-open")) {
$node
.removeClass("leaf-open")
.addClass("leaf-closed")
.data('children')
.slideUp();
}
else {
$node
.removeClass("leaf-closed")
.addClass("leaf-open")
.data('children')
.slideDown();
}
});
}
}
if (typeof element.searchChildren != 'undefined' && element.searchChildren) {
$node
.removeClass("leaf-empty")
.addClass("leaf-closed");
$leafIcon.click(function (e) {
e.preventDefault();
if (!$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) {
$node
.removeClass("leaf-closed")
.removeClass("leaf-error")
.addClass("leaf-loading");
$.ajax({
url: controller.ajaxURL,
type: 'POST',
dataType: 'json',
data: {
page: controller.ajaxPage,
getChildren: 1,
id: element.id,
type: element.type,
filter: controller.filter,
childrenMethod: 'live',
countModuleStatusMethod: 'live',
countAgentStatusMethod: 'live'
},
complete: function(xhr, textStatus) {
$node.removeClass("leaf-loading");
$node.addClass("children-loaded");
},
success: function(data, textStatus, xhr) {
if (data.success) {
if (typeof data.tree != 'undefined' && data.tree.length > 0) {
$node.addClass("leaf-open");
var $group = $node.find("ul.tree-group");
if ($group.length <= 0) {
$group = $("<ul></ul>");
$group
.addClass("tree-group")
.hide();
$node.append($group);
}
data.tree.forEach(function(element, index) {
element.jqObject = _processNode($group, element);
}, $group);
$group.slideDown();
$node.data('children', $group);
// Add again the hover event to the 'force_callback' elements
forced_title_callback();
}
else {
$node.addClass("leaf-empty");
}
}
else {
$node.addClass("leaf-error");
}
},
error: function(xhr, textStatus, errorThrown) {
$node.addClass("leaf-error");
}
});
}
else if (! $node.hasClass("leaf-empty")) {
if ($node.hasClass("leaf-open")) {
$node
.removeClass("leaf-open")
.addClass("leaf-closed")
.data('children')
.slideUp();
}
else {
$node
.removeClass("leaf-closed")
.addClass("leaf-open")
.data('children')
.slideDown();
}
}
});
}
return $node;
}
if (controller.recipient.length == 0) {
return;
}
else if (controller.tree.length == 0) {
controller.recipient.html("<div>" + controller.emptyMessage + "</div>");
return;
}
controller.recipient.empty();
var $children = _processGroup(this.recipient, this.tree, true);
$children.show();
controller.recipient.data('children', $children);
// Add again the hover event to the 'force_callback' elements
forced_title_callback();
},
load: function () {
this.reload();
},
changeTree: function (tree) {
this.tree = tree;
this.reload();
},
init: function (data) {
if (typeof data.recipient != 'undefined' && data.recipient.length > 0) {
this.recipient = data.recipient;
}
if (typeof data.detailRecipient != 'undefined' && data.detailRecipient.length > 0) {
this.detailRecipient = data.detailRecipient;
}
if (typeof data.tree != 'undefined' && data.tree.length > 0) {
this.tree = data.tree;
}
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
this.emptyMessage = data.emptyMessage;
}
if (typeof data.errorMessage != 'undefined' && data.errorMessage.length > 0) {
this.errorMessage = data.errorMessage;
}
if (typeof data.baseURL != 'undefined' && data.baseURL.length > 0) {
this.baseURL = data.baseURL;
}
if (typeof data.ajaxURL != 'undefined' && data.ajaxURL.length > 0) {
this.ajaxURL = data.ajaxURL;
}
if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) {
this.ajaxPage = data.ajaxPage;
}
if (typeof data.filter != 'undefined') {
this.filter = data.filter;
}
this.load();
},
remove: function () {
if (typeof this.recipient != 'undefined' && this.recipient.length > 0) {
this.recipient.empty();
}
if (this.index > -1) {
TreeController.controllers.splice(this.index, 1);
}
}
}
controller.index = TreeController.controllers.push(controller) - 1;
return controller;
}
}
// The controllers will be inside the 'controllers' object,
// ordered by ['type']['id']
TreeNodeDetailController = {
controllers: {},
controllerExist: function (type, id) {
if (typeof this.controllers[type][id] != 'undefined') {
return true;
}
else {
return false;
}
},
removeControllers: function () {
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
element.remove();
});
}
});
}
},
getController: function () {
var controller = {
recipient: '',
type: 'none',
id: -1,
emptyMessage: "Empty",
errorMessage: "Error",
baseURL: "",
ajaxURL: "ajax.php",
ajaxPage: "include/ajax/tree.ajax",
container: '',
reload: function () {
// Label
var $label = $("<div></div>");
$label
.addClass("tree-element-detail-label")
.click(function (e) {
if ($label.hasClass('tree-element-detail-loaded'))
controller.toggle();
});
// Content
var $content = $("<div></div>");
$content.addClass("tree-element-detail-content");
// Container
this.container = $("<div></div>");
this.container
.addClass("tree-element-detail")
.append($label)
.data('label', $label)
.append($content)
.data('content', $content)
.hide();
$label.addClass('tree-element-detail-loading');
$.ajax({
url: this.ajaxURL,
type: 'POST',
dataType: 'json',
data: {
page: this.ajaxPage,
getDetail: 1,
type: this.type,
id: this.id
},
complete: function(xhr, textStatus) {
$label.removeClass('tree-element-detail-loading');
},
success: function(data, textStatus, xhr) {
if (data.success) {
$label.addClass('tree-element-detail-loaded');
$content.html(data.html);
controller.open();
}
else {
$label.addClass('tree-element-detail-error');
$content.html(controller.errorMessage);
}
},
error: function(xhr, textStatus, errorThrown) {
$label.addClass('tree-element-detail-error');
$content.html(controller.errorMessage);
}
});
this.recipient.append(this.container);
this.open();
},
load: function () {
this.reload();
},
toggle: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (this.container.isClosed) {
this.open();
}
else {
this.close();
}
},
open: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (this.container.isClosed) {
this.container.data('content').slideLeft();
this.container.isClosed = false;
}
},
close: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
return false;
}
if (!this.container.isClosed) {
this.container.data('content').slideRight();
this.container.isClosed = true;
}
},
init: function (data) {
// Remove the other controllers
TreeNodeDetailController.removeControllers();
// Required
if (typeof data.recipient != 'undefined' && data.recipient.length > 0) {
this.recipient = data.recipient;
}
else {
return false;
}
// Required
if (typeof data.type != 'undefined' && data.type.length > 0) {
this.type = data.type;
}
else {
return false;
}
// Required
if (typeof data.id != 'undefined' && (data.id.length > 0 || !isNaN(data.id))) {
this.id = data.id;
}
else {
return false;
}
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
this.emptyMessage = data.emptyMessage;
}
if (typeof data.errorMessage != 'undefined' && data.errorMessage.length > 0) {
this.errorMessage = data.errorMessage;
}
if (typeof data.baseURL != 'undefined' && data.baseURL.length > 0) {
this.baseURL = data.baseURL;
}
if (typeof data.ajaxURL != 'undefined' && data.ajaxURL.length > 0) {
this.ajaxURL = data.ajaxURL;
}
if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) {
this.ajaxPage = data.ajaxPage;
}
if (typeof data.counterTitles != 'undefined') {
this.counterTitles = data.counterTitles;
}
if (typeof TreeNodeDetailController.controllers[this.type] == 'undefined')
TreeNodeDetailController.controllers[this.type] = {};
TreeNodeDetailController.controllers[this.type][this.id] = this;
this.load();
},
remove: function () {
if (typeof this.recipient != 'undefined' && this.recipient.length > 0) {
this.recipient.empty();
}
if (this.type != 'none' && this.id > -1) {
try {
delete TreeNodeDetailController.controllers[this.type][this.id];
}
catch (error) {
// console.log('Item not deleted');
}
}
},
closeOther: function () {
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
if (this.type != type && this.id != id)
element.close();
}, this);
}
}, this);
}
},
removeOther: function () {
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
if (this.type != type && this.id != id)
element.remove();
}, this);
}
}, this);
}
}
}
return controller;
}
}

View File

@ -2833,4 +2833,161 @@ table#policy_modules td * {
.left_align {
text-align: left;
}
/* Tree view styles */
.tree-root {
margin-top: 0px;
margin-bottom: 0px;
}
.tree-group {
margin-left: 16px;
padding-top: 4px;
}
.tree-node {
white-space: nowrap;
background-image: url(../../images/tree/branch.png);
background-position: 0px 0px;
background-repeat: repeat-y;
min-height: 26px;
}
.tree-node:last-child {
background: 0 0;
}
.node-content {
height: 21px;
}
.node-content:hover {
background-color: #9AB8DF;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.leaf-icon {
width: 18px;
height: 20px;
}
.node-content, .leaf-icon {
display: inline-block;
}
.node-content>img, .node-content>div {
display: inline;
}
.tree-node.leaf-open>.leaf-icon {
background-image: url(../../images/tree/last_expanded.png);
cursor: pointer;
}
.tree-node.tree-first.leaf-open>.leaf-icon {
background-image: url(../../images/tree/first_expanded.png);
cursor: pointer;
}
.tree-node.leaf-closed>.leaf-icon {
background-image: url(../../images/tree/last_closed.png);
cursor: pointer;
}
.tree-node.tree-first.leaf-closed>.leaf-icon {
background-image: url(../../images/tree/first_closed.png);
cursor: pointer;
}
.tree-node.leaf-loading>.leaf-icon {
background-image: url(../../images/tree/last_expanded.png);
}
.tree-node.leaf-empty>.leaf-icon {
background-image: url(../../images/tree/last_leaf.png);
}
.tree-node.tree-first.leaf-empty>.leaf-icon {
background-image: url(../../images/tree/first_leaf.png);
}
.tree-node.leaf-error>.leaf-icon {
background-image: url(../../images/tree/last_leaf.png);
}
.tree-node>.leaf-icon {
background-position: 0px 0px;
background-repeat: no-repeat;
}
.tree-node>.node-content>img {
max-height: 20px;
/*max-width: 20px;*/
}
.tree-node>.node-content>img.module-data,
.tree-node>.node-content>img.module-graph {
cursor: pointer;
padding-right: 3px;
}
.tree-node>.node-content>img.module-server-type,
.tree-node>.node-content>img.agent-status,
.tree-node>.node-content>img.agent-alerts-fired,
.tree-node>.node-content>img.module-status {
padding-right: 3px;
}
.tree-node>.node-content>.tree-node-counters,
.tree-node>.node-content>.tree-node-counters>.tree-node-counter {
display: inline;
}
.tree-node>.node-content>.tree-node-counters {
}
.tree-node>.node-content>img {
vertical-align: middle;
}
.tree-node>.node-content>.tree-node-counters>.tree-node-counter {
font-weight: bold;
font-size: 7pt;
cursor: default;
}
/* The items with the class 'spinner' will rotate */
/* Not supported on IE9 and below */
.spinner {
-webkit-animation: spinner 2s infinite linear;
animation: spinner 2s infinite linear;
}
@-webkit-keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}

View File

@ -14,6 +14,13 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once("tree2.php");
return;
////////////////////////////////////////////////////////////////////////
define('ALL', -1);
define('NORMAL', 0);
define('WARNING', 2);
@ -96,7 +103,6 @@ if (is_ajax ()) {
metaconsole_connect($server);
}
treeview_printTable($id_agent, $server);
treeview_printModuleTable($id_module, $server);

View File

@ -0,0 +1,328 @@
<?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 Lesser General Public License
// as published by the Free Software Foundation; 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.
global $config;
$tab = get_parameter('tab', 'group');
$search = get_parameter('search', '');
$status = get_parameter('status', AGENT_STATUS_ALL);
// ---------------------Tabs -------------------------------------------
$enterpriseEnable = false;
if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) {
$enterpriseEnable = true;
}
$url = 'index.php?' .
'sec=estado&' .
'sec2=operation/tree&' .
'refr=0&' .
'pure=' . (int)get_parameter('pure', 0) . '&' .
'tab=%s';
$tabs = array();
$tabs['os'] = array(
'text' => "<a href='" . sprintf($url, "os") . "'>" .
html_print_image("images/operating_system.png", true,
array("title" => __('OS'))) . "</a>",
'active' => ($tab == "os"));
$tabs['group'] = array(
'text' => "<a href='" . sprintf($url, "group") . "'>" .
html_print_image("images/group.png", true,
array("title" => __('Groups'))) . "</a>",
'active' => ($tab == "group"));
$tabs['module_group'] = array(
'text' => "<a href='" . sprintf($url, "module_group") . "'>" .
html_print_image("images/module_group.png", true,
array("title" => __('Module groups'))) . "</a>",
'active' => ($tab == "module_group"));
$tabs['module'] = array(
'text' => "<a href='" . sprintf($url, "module") . "'>" .
html_print_image("images/brick.png", true,
array("title" => __('Modules'))) . "</a>",
'active' => ($tab == "module"));
$tabs['tag'] = array(
'text' => "<a href='" . sprintf($url, "tag") . "'>" .
html_print_image("images/tag.png", true,
array("title" => __('Tags'))) . "</a>",
'active' => ($tab == "tag"));
if ($enterpriseEnable) {
$tabs['policies'] = array(
'text' => "<a href='" . sprintf($url, "policies") . "'>" .
html_print_image("images/policies_mc.png", true,
array("title" => __('Policies'))) . "</a>",
'active' => ($tab == "policies"));
}
$header_title = "";
switch ($tab) {
case 'os':
$header_title =
__('Tree view - Sort the agents by OS');
break;
case 'group':
$header_title =
__('Tree view - Sort the agents by groups');
break;
case 'module_group':
$header_title =
__('Tree view - Sort the agents by module groups');
break;
case 'module':
$header_title =
__('Tree view - Sort the agents by modules');
break;
case 'tag':
$header_title =
__('Tree view - Sort the agents by tags');
break;
}
ui_print_page_header(
$header_title, "images/extensions.png", false, "", false, $tabs);
// ---------------------Tabs -------------------------------------------
// --------------------- form filter -----------------------------------
$table = null;
$table->width = "100%";
$table->data[0][0] = __('Agent status');
$fields = array ();
$fields[AGENT_STATUS_ALL] = __('All'); //default
$fields[AGENT_STATUS_NORMAL] = __('Normal');
$fields[AGENT_STATUS_WARNING] = __('Warning');
$fields[AGENT_STATUS_CRITICAL] = __('Critical');
$fields[AGENT_STATUS_UNKNOWN] = __('Unknown');
$fields[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[0][1] = html_print_select($fields,
"status",
$status,
'',
'',
0,
true);
$table->data[0][2] = __('Search agent');
$table->data[0][3] = html_print_input_text(
"search", $search, '', 40, 30, true);
$table->data[0][4] = html_print_submit_button(
__('Filter'), "uptbutton", false, 'class="sub search"', true);
echo '<form id="tree_search" method="post" action="index.php?sec=monitoring&sec2=operation/tree&refr=0&tab='.$tab.'&pure='.$config['pure'].'">';
html_print_table($table);
echo '</form>';
// --------------------- form filter -----------------------------------
ui_include_time_picker();
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
ui_require_javascript_file("TreeController", "include/javascript/tree/");
html_print_image('images/spinner.gif', false,
array('class' => "loading_tree",
'style' => 'display: none;'));
echo "<div id='tree-controller-recipient' style='float: left;'>";
echo "</div>";
echo "<div id='tree-controller-detail-recipient' style='float: right;'>";
echo "</div>";
?>
<script type="text/javascript">
var treeController = TreeController.getController();
processTreeSearch();
$("form#tree_search").submit(function(e) {
e.preventDefault();
processTreeSearch();
});
function processTreeSearch () {
// Clear the tree
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)
treeController.recipient.empty();
$(".loading_tree").show();
var parameters = {};
parameters['page'] = "include/ajax/tree.ajax";
parameters['getChildren'] = 1;
parameters['filter'] = {};
parameters['type'] = "<?php echo $tab; ?>";
parameters['filter']['searchAgent'] = $("input#text-search").val();
parameters['filter']['status'] = $("select#status").val();
parameters['childrenMethod'] = 'live';
parameters['countModuleStatusMethod'] = 'live';
parameters['countAgentStatusMethod'] = 'live';
$.ajax({
type: "POST",
url: "<?php echo $config['homeurl']; ?>ajax.php",
data: parameters,
success: function(data) {
if (data.success) {
$(".loading_tree").hide();
treeController.init({
recipient: $("div#tree-controller-recipient"),
detailRecipient: $("div#tree-controller-detail-recipient"),
page: page,
tree: data.tree,
baseURL: "<?php echo $config['homeurl'].'/'; ?>",
ajaxURL: "<?php echo $config['homeurl'].'/'; ?>ajax.php",
filter: {
search: parameters['filter']['search'],
status: parameters['filter']['status']
},
counterTitles: {
total: {
agents: "<?php echo __('Total agents'); ?>",
modules: "<?php echo __('Total modules'); ?>",
none: "<?php echo __('Total'); ?>"
},
fired: {
agents: "<?php echo __('Fired alerts'); ?>",
modules: "<?php echo __('Fired alerts'); ?>",
none: "<?php echo __('Fired alerts'); ?>"
},
critical: {
agents: "<?php echo __('Critical agents'); ?>",
modules: "<?php echo __('Critical modules'); ?>",
none: "<?php echo __('Critical'); ?>"
},
warning: {
agents: "<?php echo __('Warning agents'); ?>",
modules: "<?php echo __('Warning modules'); ?>",
none: "<?php echo __('Warning'); ?>"
},
unknown: {
agents: "<?php echo __('Unknown agents'); ?>",
modules: "<?php echo __('Unknown modules'); ?>",
none: "<?php echo __('Unknown'); ?>"
},
not_init: {
agents: "<?php echo __('Not init agents'); ?>",
modules: "<?php echo __('Not init modules'); ?>",
none: "<?php echo __('Not init'); ?>"
},
ok: {
agents: "<?php echo __('Normal agents'); ?>",
modules: "<?php echo __('Normal modules'); ?>",
none: "<?php echo __('Normal'); ?>"
}
}
});
}
},
dataType: "json"
});
}
// Show the modal window of an module
var moduleDetailsWindow = $("<div></div>");
moduleDetailsWindow
.hide()
.prop("id", "module_details_window")
.appendTo('body');
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) {
var params = {};
if (period == -1) {
period = $('#period').val();
params.selection_mode = $('input[name=selection_mode]:checked').val();
params.date_from = $('#text-date_from').val();
params.time_from = $('#text-time_from').val();
params.date_to = $('#text-date_to').val();
params.time_to = $('#text-time_to').val();
}
params.page = "include/ajax/module";
params.get_module_detail = 1;
params.server_name = server_name;
params.id_agent = id_agent;
params.id_module = module_id;
params.offset = offset;
params.period = period;
$.ajax({
type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: params,
dataType: "html",
success: function(data) {
$("#module_details_window").hide ()
.empty ()
.append (data)
.dialog ({
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
width: 650,
height: 500
})
.show ();
refresh_pagination_callback(module_id, id_agent, server_name);
datetime_picker_callback();
forced_title_callback();
}
});
}
function datetime_picker_callback() {
$("#text-time_from, #text-time_to").timepicker({
showSecond: true,
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
timeOnlyTitle: '<?php echo __('Choose time');?>',
timeText: '<?php echo __('Time');?>',
hourText: '<?php echo __('Hour');?>',
minuteText: '<?php echo __('Minute');?>',
secondText: '<?php echo __('Second');?>',
currentText: '<?php echo __('Now');?>',
closeText: '<?php echo __('Close');?>'});
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
}
function refresh_pagination_callback (module_id, id_agent, server_name) {
$(".binary_dialog").click( function() {
var classes = $(this).attr('class');
classes = classes.split(' ');
var offset_class = classes[2];
offset_class = offset_class.split('_');
var offset = offset_class[1];
var period = $('#period').val();
show_module_detail_dialog(module_id, id_agent, server_name, offset, period);
return false;
});
}
</script>