Merge branch 'feature/NewTreeView' into develop

This commit is contained in:
Alejandro Gallardo Escobar 2015-01-30 20:10:16 +01:00
commit 4cf9accbd7
8 changed files with 704 additions and 1487 deletions

View File

@ -79,14 +79,15 @@ if ($get_module_detail) {
if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name);
$conexion = mysql_connect ($server['dbhost'], $server['dbuser'],
$server['dbpass']);
$select_db = mysql_select_db ($server['dbname'], $conexion);
if (metaconsole_connect($server) != NOERR)
return;
$conexion = false;
}
else {
$conexion = false;
}
html_debug_print($conexion, true);
$selection_mode = get_parameter('selection_mode', 'fromnow');
$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
$time_from = (string) get_parameter ('time_from', date ('h:iA'));
@ -266,6 +267,9 @@ if ($get_module_detail) {
html_print_table($table);
}
if (defined ('METACONSOLE'))
metaconsole_restore_db();
return;
}

View File

@ -27,13 +27,14 @@ if (is_ajax ()) {
$getChildren = (bool) get_parameter('getChildren', 0);
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
$get_detail = (bool) get_parameter('getDetail');
$getDetail = (bool) get_parameter('getDetail');
if ($getChildren) {
$type = get_parameter('type', 'group');
$rootType = get_parameter('rootType', '');
$id = get_parameter('id', -1);
$rootID = get_parameter('rootID', -1);
$serverID = get_parameter('serverID', false);
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
$default_filters = array(
@ -45,10 +46,10 @@ if (is_ajax ()) {
$filter = get_parameter('filter', $default_filters);
if (class_exists('TreeEnterprise')) {
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $childrenMethod);
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $serverID, $childrenMethod);
}
else {
$tree = new Tree($type, $rootType, $id, $rootID, $childrenMethod);
$tree = new Tree($type, $rootType, $id, $rootID, $serverID, $childrenMethod);
}
$tree->setFilter($filter);
@ -56,61 +57,38 @@ if (is_ajax ()) {
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) {
if ($getDetail) {
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);
$server_id = (int) get_parameter('serverID');
$server = metaconsole_get_servers($server_id);
if (metaconsole_connect($server) != NOERR)
return;
}
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;
ob_clean();
if (!empty($id) && !empty($type)) {
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')) {

View File

@ -18,6 +18,7 @@ class Tree {
protected $rootType = null;
protected $id = -1;
protected $rootID = -1;
protected $serverID = false;
protected $tree = array();
protected $filter = array();
protected $childrenMethod = "on_demand";
@ -27,12 +28,13 @@ class Tree {
protected $strictACL = false;
protected $acltags = false;
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $childrenMethod = "on_demand") {
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand") {
$this->type = $type;
$this->rootType = !empty($rootType) ? $rootType : $type;
$this->id = $id;
$this->rootID = !empty($rootID) ? $rootID : $id;
$this->serverID = $serverID;
$this->childrenMethod = $childrenMethod;
$userGroups = users_get_groups();
@ -45,6 +47,9 @@ class Tree {
global $config;
include_once($config['homedir']."/include/functions_servers.php");
if (defined("METACONSOLE"))
enterprise_include_once("meta/include/functions_ui_meta.php");
$this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
if ($this->strictACL) {
@ -150,7 +155,7 @@ class Tree {
// Not init
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
$agents_not_init_count = "($agent_table
$agent_not_init_filter) AS total_not_init_count";
$agent_not_init_filter) AS total_not_init_count";
$columns = "$agents_not_init_count, $agents_fired_count, $agents_total_count";
break;
case AGENT_STATUS_CRITICAL:
@ -213,6 +218,9 @@ class Tree {
// Get the root id
$rootID = $this->rootID;
// Get the server id
$serverID = $this->serverID;
// Agent name filter
$agent_search_filter = "";
if (!empty($this->filter['searchAgent'])) {
@ -377,9 +385,10 @@ class Tree {
ORDER BY $order_fields";
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
ta.normal_count, ta.warning_count, ta.critical_count,
ta.unknown_count, ta.notinit_count, ta.total_count';
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
@ -508,9 +517,10 @@ class Tree {
}
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
ta.normal_count, ta.warning_count, ta.critical_count,
ta.unknown_count, ta.notinit_count, ta.total_count';
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
@ -603,9 +613,10 @@ class Tree {
}
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
ta.normal_count, ta.warning_count, ta.critical_count,
ta.unknown_count, ta.notinit_count, ta.total_count';
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
@ -701,9 +712,10 @@ class Tree {
}
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
ta.normal_count, ta.warning_count, ta.critical_count,
ta.unknown_count, ta.notinit_count, ta.total_count';
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
@ -802,9 +814,10 @@ class Tree {
}
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
ta.normal_count, ta.warning_count, ta.critical_count,
ta.unknown_count, ta.notinit_count, ta.total_count';
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
@ -880,29 +893,26 @@ class Tree {
}
break;
default:
$sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID,
$agent_search_filter, $agent_status_filter,
$agents_join, $module_search_filter,
$module_status_filter, $modules_join,
$sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID,
$agent_search_filter, $agent_status_filter, $agents_join,
$module_search_filter, $module_status_filter, $modules_join,
$module_status_join);
}
html_debug_print($sql, true);
return $sql;
}
// Override this method
protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID,
$agent_search_filter, $agent_status_filter,
$agents_join, $module_search_filter,
$module_status_filter, $modules_join,
protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID,
$agent_search_filter, $agent_status_filter, $agents_join,
$module_search_filter, $module_status_filter, $modules_join,
$module_status_join) {
return false;
}
protected function getItems ($item_for_count = false) {
$sql = $this->getSql($item_for_count);
if (empty($sql))
return array();
@ -928,7 +938,7 @@ class Tree {
return strcmp($a["name"], $b["name"]);
}
protected function getGroupsChildren($groups, $parent_id, $server_id = false) {
protected function getGroupsChildren($groups, $parent_id, $server = false) {
$children = array();
foreach ($groups as $key => $group) {
unset($groups[$key]);
@ -936,7 +946,7 @@ class Tree {
if ((isset($group['parent']) && $group['parent'] == $parent_id)
|| (isset($group['_parent_id_']) && $group['_parent_id_'] == $parent_id)) {
$children_aux = $this->getProcessedItem($group, $server_id, $groups);
$children_aux = $this->getProcessedItem($group, $server, $groups);
if (!empty($children_aux))
$children[] = $children_aux;
}
@ -945,7 +955,7 @@ class Tree {
return $children;
}
protected function getProcessedItem ($item, $server_id = false, $items = array()) {
protected function getProcessedItem ($item, $server = false, $items = array()) {
$processed_item = array();
$processed_item['id'] = $item['id'];
$processed_item['name'] = $item['name'];
@ -972,8 +982,8 @@ class Tree {
$processed_item['icon'] = "without_group.png";
}
if (defined ('METACONSOLE') && $server_id) {
$processed_item['server_id'] = $server_id;
if (defined("METACONSOLE") && !empty($server)) {
$processed_item['serverID'] = $server['id'];
}
$counters = array();
@ -994,7 +1004,7 @@ class Tree {
if ($processed_item['type'] == 'group' && !empty($items)) {
$children = $this->getGroupsChildren($items, $item['id'], $server_id);
$children = $this->getGroupsChildren($items, $item['id'], $server);
if (!empty($children)) {
$processed_item['children'] = $children;
@ -1030,9 +1040,11 @@ class Tree {
// The 'id' parameter will be stored as 'server_id' => 'id'
$resultItem['id'] = array();
$resultItem['id'][$item['server_id']] = $item['id'];
$resultItem['id'][$item['serverID']] = $item['id'];
$resultItem['rootID'] = array();
$resultItem['rootID'][$item['server_id']] = $item['rootID'];
$resultItem['rootID'][$item['serverID']] = $item['rootID'];
$resultItem['serverID'] = array();
$resultItem['serverID'][$item['serverID']] = $item['rootID'];
// Initialize counters if any of it don't exist
if (!isset($resultItem['counters']))
@ -1067,8 +1079,9 @@ class Tree {
// Match with the name and type
if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) {
// Add the matched ids
$resultItem['id'][$item2['server_id']] = $item2['id'];
$resultItem['rootID'][$item2['server_id']] = $item2['rootID'];
$resultItem['id'][$item2['serverID']] = $item2['id'];
$resultItem['rootID'][$item2['serverID']] = $item2['rootID'];
$resultItem['serverID'][$item2['serverID']] = $item2['rootID'];
// Add the matched counters
if (isset($item2['counters']) && !empty($item2['counters'])) {
@ -1109,7 +1122,7 @@ class Tree {
return $mergedItems;
}
protected function processModule (&$module) {
protected function processModule (&$module, $server = false) {
global $config;
$module['type'] = 'module';
@ -1119,7 +1132,11 @@ class Tree {
$module['server_type'] = (int) $module['id_modulo'];
$module['status'] = $module['estado'];
$module['value'] = $module['datos'];
// $module['icon'] = modules_get_type_icon($module['id_tipo_modulo']);
if (defined("METACONSOLE") && !empty($server)) {
$module['serverID'] = $server['id'];
$module['serverName'] = $server['server_name'];
}
if (!isset($module['value']))
$module['value'] = modules_get_last_value($module['id']);
@ -1179,28 +1196,51 @@ class Tree {
// Link to the Module graph
$graphType = return_graphtype($module['id']);
$winHandle = dechex(crc32($module['id'] . $module['name']));
$moduleGraphURL = $config['homeurl'] .
"/operation/agentes/stat_win.php?" .
"type=$graphType&" .
"period=86400&" .
"id=" . $module['id'] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=600";
$module['moduleGraph'] = array(
'url' => $moduleGraphURL,
'handle' => $winHandle
);
}
if (!defined('METACONSOLE')) {
$moduleGraphURL = $config['homeurl'] .
"/operation/agentes/stat_win.php?" .
"type=$graphType&" .
"period=86400&" .
"id=" . $module['id'] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=600";
}
else if (!empty($server)) {
$moduleGraphURL = ui_meta_get_url_console_child(
$server, null, null, null, null,
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=86400&" .
"id=" . $module["id"] . "&" .
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
"refresh=600");
}
protected function processModules (&$modules) {
foreach ($modules as $iterator => $module) {
$this->processModule($modules[$iterator]);
if (!empty($moduleGraphURL)) {
$module['moduleGraph'] = array(
'url' => $moduleGraphURL,
'handle' => $winHandle
);
}
// Alerts fired image
$has_alerts = (bool) db_get_value('COUNT(DISTINCT(id_agent_module))', 'talert_template_modules', 'id_agent_module', $module['id']);
if ($has_alerts) {
$module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts')));
}
}
protected function processAgent (&$agent, $server_id = false) {
protected function processModules (&$modules, $server = false) {
foreach ($modules as $iterator => $module) {
$this->processModule($modules[$iterator], $server);
}
}
protected function processAgent (&$agent, $server = false) {
global $config;
$agent['type'] = 'agent';
$agent['id'] = (int) $agent['id'];
$agent['name'] = $agent['name'];
@ -1208,11 +1248,8 @@ class Tree {
$agent['rootID'] = $this->rootID;
$agent['rootType'] = $this->rootType;
$id = $agent['id'];
if ($server_id) {
$agent['id'] = array();
$agent['id'][$server_id] = $id;
}
if (defined("METACONSOLE") && !empty($server))
$agent['serverID'] = $server['id'];
// Counters
if (empty($agent['counters'])) {
@ -1221,37 +1258,37 @@ class Tree {
if (isset($agent['unknown_count']))
$agent['counters']['unknown'] = $agent['unknown_count'];
else
$agent['counters']['unknown'] = agents_monitor_unknown($id);
$agent['counters']['unknown'] = agents_monitor_unknown($agent['id']);
if (isset($agent['critical_count']))
$agent['counters']['critical'] = $agent['critical_count'];
else
$agent['counters']['critical'] = agents_monitor_critical($id);
$agent['counters']['critical'] = agents_monitor_critical($agent['id']);
if (isset($agent['warning_count']))
$agent['counters']['warning'] = $agent['warning_count'];
else
$agent['counters']['warning'] = agents_monitor_warning($id);
$agent['counters']['warning'] = agents_monitor_warning($agent['id']);
if (isset($agent['notinit_count']))
$agent['counters']['not_init'] = $agent['notinit_count'];
else
$agent['counters']['not_init'] = agents_monitor_notinit($id);
$agent['counters']['not_init'] = agents_monitor_notinit($agent['id']);
if (isset($agent['normal_count']))
$agent['counters']['ok'] = $agent['normal_count'];
else
$agent['counters']['ok'] = agents_monitor_ok($id);
$agent['counters']['ok'] = agents_monitor_ok($agent['id']);
if (isset($agent['total_count']))
$agent['counters']['total'] = $agent['total_count'];
else
$agent['counters']['total'] = agents_monitor_total($id);
$agent['counters']['total'] = agents_monitor_total($agent['id']);
if (isset($agent['fired_count']))
$agent['counters']['alerts'] = $agent['fired_count'];
else
$agent['counters']['alerts'] = agents_get_alerts_fired($id);
$agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']);
}
// Status image
@ -1265,8 +1302,12 @@ class Tree {
// Alerts fired image
$agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']);
// Quiet image
if (isset($agent['quiet']) && $agent['quiet'])
$agent['quietImageHTML'] = html_print_image("/images/dot_green.disabled.png", true, array("title" => __('Quiet')));
// Status
$agent['statusRaw'] = agents_get_status($id);
$agent['statusRaw'] = agents_get_status($agent['id']);
switch ($agent['statusRaw']) {
case AGENT_STATUS_NORMAL:
$agent['status'] = "ok";
@ -1300,7 +1341,7 @@ class Tree {
$agent['searchChildren'] = 0;
// if ($searchChildren)
// $agent['children'] = $this->getModules($id, $modulesFilter);
// $agent['children'] = $this->getModules($agent['id'], $modulesFilter);
break;
}
}
@ -1317,10 +1358,10 @@ class Tree {
}
}
protected function processAgents (&$agents, $server_id = false) {
protected function processAgents (&$agents, $server = false) {
if (!empty($agents)) {
foreach ($agents as $iterator => $agent) {
$this->processAgent($agents[$iterator], $server_id);
$this->processAgent($agents[$iterator], $server);
}
}
}
@ -1383,23 +1424,21 @@ class Tree {
$processed_items = $items;
}
else {
$ids = $this->id;
$items = array();
foreach ($ids as $serverID => $id) {
$server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR)
continue;
db_clean_cache();
$this->id = $id;
$newItems = $this->getItems();
$this->processModules($newItems);
$items = array_merge($items, $newItems);
if ($this->serverID !== false) {
metaconsole_restore_db();
$server = metaconsole_get_servers($this->serverID);
if (metaconsole_connect($server) == NOERR) {
db_clean_cache();
$newItems = $this->getItems();
$this->processModules($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
}
}
$this->id = $ids;
if (!empty($items))
usort($items, array("Tree", "cmpSortNames"));
@ -1519,7 +1558,7 @@ class Tree {
if (isset($item['_monitors_alerts_fired_']))
$item['total_fired_count'] = $item['_monitors_alerts_fired_'];
$processed_items[] = $this->getProcessedItem($item, $server['id'], $items);
$processed_items[] = $this->getProcessedItem($item, $server, $items);
}
}
$unmerged_items += $processed_items;
@ -1549,7 +1588,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
@ -1606,7 +1645,7 @@ class Tree {
if (empty($item['parent'])) {
unset($items[$key]);
$processed_items[] = $this->getProcessedItem($item, $server['id'], $items);
$processed_items[] = $this->getProcessedItem($item, $server, $items);
}
}
@ -1637,7 +1676,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
@ -1696,7 +1735,7 @@ class Tree {
}
}
$processed_item = $this->getProcessedItem($item, $server['id']);
$processed_item = $this->getProcessedItem($item, $server);
$processed_items[] = $processed_item;
}
$item_list = array_merge($item_list, $processed_items);
@ -1726,7 +1765,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
@ -1814,7 +1853,7 @@ class Tree {
'_articapandora_'.ord('!').'_pandoraartica_'),
io_safe_output($item['name']));
$processed_item = $this->getProcessedItem($item, $server['id']);
$processed_item = $this->getProcessedItem($item, $server);
$processed_item['id'] = $name;
$processed_item['rootID'] = $name;
@ -1847,7 +1886,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
@ -1906,7 +1945,7 @@ class Tree {
}
}
$processed_item = $this->getProcessedItem($item, $server['id']);
$processed_item = $this->getProcessedItem($item, $server);
$processed_items[] = $processed_item;
}
$item_list = array_merge($item_list, $processed_items);
@ -1936,7 +1975,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
@ -1996,7 +2035,7 @@ class Tree {
}
}
$processed_item = $this->getProcessedItem($item, $server['id']);
$processed_item = $this->getProcessedItem($item, $server);
$processed_item['icon'] = $item['os_icon'];
$processed_items[] = $processed_item;
}
@ -2027,7 +2066,7 @@ class Tree {
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $serverID);
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();

View File

@ -55,55 +55,75 @@ function treeview_printModuleTable($id_module, $server_data = false) {
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;">';
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->head[] = __('Module');
$table->head_colspan[] = 2;
$table->data = array();
//Module name
echo '<tr><td class="datos"><b>'.__('Module name').'</b></td>';
if ($module["disabled"])
$cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>";
else
$cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;");
echo '<td class="datos"><b>'.$cellName.'</b></td>';
$row = array();
$row['title'] = __('Name');
$row['data'] = "<b>".$cellName."</b>";
$table->data['name'] = $row;
// Interval
echo '<tr><td class="datos"><b>' . __('Interval') . '</b></td>';
echo '<td class="datos" colspan="2">' . human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true) . '</td></tr>';
$row = array();
$row['title'] = __('Interval');
$row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true);
$table->data['interval'] = $row;
// Warning Min/Max
echo '<tr><td class="datos"><b>' . __('Warning status') . '</b></td>';
if (modules_is_string_type($module['id_tipo_modulo'])) {
echo '<td class="datos" colspan="2">' . __('Str.') . ': ' . $module['str_warning'] . '</td></tr>';
$warning_status_str = __('Str.') . ': ' . $module['str_warning'];
}
else {
echo '<td class="datos" colspan="2">' . __('Min.') . ': ' . $module['min_warning'] . '<br>' . __('Max.') . ': ' . $module['max_warning'] . '</td></tr>';
$warning_status_str = __('Min.') . ': ' . $module['min_warning'] . '<br>' . __('Max.') . ': ' . $module['max_warning'];
}
$row = array();
$row['title'] = __('Warning status');
$row['data'] = $warning_status_str;
$table->data['watning_status'] = $row;
// Critical Min/Max
echo '<tr><td class="datos"><b>' . __('Critical status') . '</b></td>';
if (modules_is_string_type($module['id_tipo_modulo'])) {
echo '<td class="datos" colspan="2">' . __('Str.') . ': ' . $module['str_warning'] . '</td></tr>';
$critical_status_str = __('Str.') . ': ' . $module['str_warning'];
}
else {
echo '<td class="datos" colspan="2">' . __('Min.') . ': ' . $module['min_critical'] . '<br>' . __('Max.') . ': ' . $module['max_critical'] . '</td></tr>';
$critical_status_str = __('Min.') . ': ' . $module['min_critical'] . '<br>' . __('Max.') . ': ' . $module['max_critical'];
}
$row = array();
$row['title'] = __('Critical status');
$row['data'] = $critical_status_str;
$table->data['critical_status'] = $row;
// Module group
echo '<tr><td class="datos2"><b>'.__('Module group').'</b></td>';
echo '<td class="datos2" colspan="2">';
$module_group = modules_get_modulegroup_name($module['id_module_group']);
if ($module_group === false)
echo __('Not assigned');
$module_group = __('Not assigned');
else
echo __("$module_group");
echo '</td></tr>';
$module_group = __("$module_group");
$row = array();
$row['title'] = __('Module group');
$row['data'] = $module_group;
$table->data['module_group'] = $row;
// Description
echo '<tr><td class="datos"><b>'.__('Description').'</b></td>';
echo '<td class="datos" colspan="2">'. ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[&hellip;]') .'</td></tr>';
$row = array();
$row['title'] = __('Description');
$row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[&hellip;]');
$table->data['description'] = $row;
// Tags
$tags = tags_get_module_tags($module['id_agente_modulo']);
@ -135,8 +155,10 @@ function treeview_printModuleTable($id_module, $server_data = false) {
$tags = implode(', ' , $tags);
}
echo '<tr><td class="datos"><b>'.__('Tags').'</b></td>';
echo '<td class="datos" colspan="2">' . $tags . '</td></tr>';
$row = array();
$row['title'] = __('Tags');
$row['data'] = $tags;
$table->data['tags'] = $row;
// Data
$last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC')));
@ -145,28 +167,28 @@ function treeview_printModuleTable($id_module, $server_data = false) {
else
$data = "<span title='" . $last_data["datos"] . "' style='white-space: nowrap;'>" . substr(io_safe_output($last_data['datos']),0,12) . "</span>";
echo '<tr><td class="datos"><b>'.__('Last data').'</b></td>';
echo '<td class="datos" colspan="2">';
if (!empty($last_data['utimestamp'])) {
echo $data;
$last_data_str = $data;
if ($module['unit'] != '') {
echo "&nbsp;";
echo '('.$module['unit'].')';
$last_data_str .= "&nbsp;";
$last_data_str .= '('.$module['unit'].')';
}
echo "&nbsp;";
html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px'));
$last_data_str .= "&nbsp;";
$last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
}
else {
echo '<i>' . __('No data') . '</i>';
$last_data_str = '<i>' . __('No data') . '</i>';
}
echo '</td></tr>';
$row = array();
$row['title'] = __('Last data');
$row['data'] = $last_data_str;
$table->data['last_data'] = $row;
//End of table
echo '</table></div>';
html_print_table($table);
$id_group = agents_get_agent_group($module['id_agente']);
$group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
@ -174,10 +196,10 @@ function treeview_printModuleTable($id_module, $server_data = false) {
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) {
// Actions table
echo '<div style="width:90%; text-align: right; min-width: 300px;">';
echo '<form id="module_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">';
echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">';
html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"');
echo '</form>';
echo '</a>';
echo '</div>';
}
@ -218,42 +240,53 @@ function treeview_printAlertsTable($id_module, $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;">';
echo '<tr><th colspan=2 class="datos"><center>' . $module_name . '</center></th></tr>';
echo '<tr><th class="datos" style="background: #B3B3B3;"><b>'.__('Template').'</b></th>';
echo '<th class="datos" style="background: #B3B3B3;"><b>'.__('Actions').'</b></th>';
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['titles'] = 'font-weight: bold; background: #B3B3B3;';
$table->head = array();
$table->head[] = __('Alerts') . ": " . $module_name;
$table->head_colspan[] = 2;
$table->data = array();
$row = array();
$row['template'] = __('Template');
$row['actions'] = __('Actions');
$table->data['titles'] = $row;
foreach($module_alerts as $module_alert) {
//Template name
echo '<tr>';
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);
echo '<td class="datos">'.$template_name.'</td>';
$actions = alerts_get_alert_agent_module_actions($module_alert['id']);
echo '<td class="datos">';
if (empty($actions)) {
echo '<i>'.__('N/A').'</i>';
$actions_list = '<i>'.__('N/A').'</i>';
}
else {
echo '<ul>';
foreach($actions as $act) {
echo '<li>';
echo $act['name'];
echo '</li>';
$actions_list = '<ul>';
foreach($actions_list as $act) {
$actions_list .= '<li>';
$actions_list .= $act['name'];
$actions_list .= '</li>';
}
echo '</ul>';
$actions_list .= '</ul>';
}
echo '</td></tr>';
$row = array();
$row['template'] = $template_name;
$row['actions'] = $actions_list;
$table->data['last_data'] = $row;
}
echo '</table>';
html_print_table($table);
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
// Actions table
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&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
html_print_submit_button (__('Go to alerts edition'), 'upd_button', false, 'class="sub search"');
echo '</form>';
echo '</a>';
echo '</div>';
}
}
@ -386,9 +419,9 @@ function treeview_printTable($id_agente, $server_data = array()) {
if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$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 .= '<a target=_blank href="' . $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 .= '</a>';
$go_to_agent .= '</div>';
$agent_table .= $go_to_agent;

View File

@ -77,10 +77,10 @@ TreeController = {
modules: "Total modules",
none: "Total"
},
fired: {
agents: "Alert fired",
modules: "Alert fired",
none: "Alert fired"
alerts: {
agents: "Alerts fired",
modules: "Alerts fired",
none: "Alerts fired"
},
critical: {
agents: "Critical agents",
@ -173,16 +173,16 @@ TreeController = {
$counters.append($totalCounter);
if (typeof counters.fired != 'undefined'
&& counters.fired > 0) {
if (typeof counters.alerts != 'undefined'
&& counters.alerts > 0) {
var $firedCounter = $("<div></div>");
$firedCounter
.addClass('tree-node-counter')
.addClass('fired')
.addClass('alerts')
.addClass('orange')
.html(counters.fired);
.html(counters.alerts);
_processNodeCounterTitle($firedCounter, type, "fired");
_processNodeCounterTitle($firedCounter, type, "alerts");
$counters
.append(" : ")
@ -311,6 +311,14 @@ TreeController = {
$content.append(element.name);
break;
case 'agent':
// Is quiet
if (typeof element.quietImageHTML != 'undefined'
&& element.quietImageHTML.length > 0) {
var $quietImage = $(element.quietImageHTML);
$quietImage.addClass("agent-quiet");
$content.append($quietImage);
}
// Status image
if (typeof element.statusImageHTML != 'undefined'
&& element.statusImageHTML.length > 0) {
@ -361,14 +369,16 @@ TreeController = {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
console.log(error);
// console.log(error);
}
});
$content.append($graphImage);
}
// Data pop-up
if (typeof element.id != 'undefined'
&& !isNaN(element.id)) {
if (typeof element.id != 'undefined' && !isNaN(element.id)) {
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/binary.png" /> ');
$dataImage
@ -377,19 +387,46 @@ TreeController = {
e.preventDefault();
try {
var serverName = element.serverName.length > 0 ? element.serverName : '';
if ($("#module_details_window").length > 0)
show_module_detail_dialog(element.id, '', '', 0, 86400);
show_module_detail_dialog(element.id, '', serverName, 0, 86400);
}
catch (error) {
console.log(error);
// console.log(error);
}
});
$content.append($dataImage);
}
$content
.append($graphImage)
.append($dataImage)
.append(element.name);
// Alerts
if (typeof element.alertsImageHTML != 'undefined'
&& element.alertsImageHTML.length > 0) {
var $alertsImage = $(element.alertsImageHTML);
$alertsImage
.addClass("module-alerts")
.click(function (e) {
TreeNodeDetailController.getController().init({
recipient: controller.detailRecipient,
type: 'alert',
id: element.id,
serverID: element.serverID,
baseURL: controller.baseURL,
ajaxURL: controller.ajaxURL,
ajaxPage: controller.ajaxPage
});
// Avoid the execution of the module detail event
e.stopPropagation();
})
.css('cursor', 'pointer');
$content.append($alertsImage);
}
$content.append(element.name);
break;
case 'os':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
@ -419,16 +456,20 @@ TreeController = {
// 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
});
});
if (element.type == 'agent' || element.type == 'module') {
$content.click(function (e) {
TreeNodeDetailController.getController().init({
recipient: controller.detailRecipient,
type: element.type,
id: element.id,
serverID: element.serverID,
baseURL: controller.baseURL,
ajaxURL: controller.ajaxURL,
ajaxPage: controller.ajaxPage
});
})
.css('cursor', 'pointer');
}
}
$node
@ -494,6 +535,7 @@ TreeController = {
id: element.id,
type: element.type,
rootID: element.rootID,
serverID: element.serverID,
rootType: element.rootType,
filter: controller.filter
},
@ -648,21 +690,23 @@ TreeNodeDetailController = {
}
},
removeControllers: function () {
if (TreeNodeDetailController.controllers.length > 0) {
TreeNodeDetailController.controllers.forEach(function(elements, type) {
if (elements.length > 0) {
elements.forEach(function(element, id) {
element.remove();
});
}
try {
$.each(TreeNodeDetailController.controllers, function(type, elements) {
$.each(elements, function(id, element) {
element.remove();
});
});
}
catch (error) {
// console.log(error);
}
},
getController: function () {
var controller = {
recipient: '',
type: 'none',
id: -1,
serverID: -1,
emptyMessage: "Empty",
errorMessage: "Error",
baseURL: "",
@ -687,37 +731,33 @@ TreeNodeDetailController = {
this.container = $("<div></div>");
this.container
.addClass("tree-element-detail")
.addClass("tree-element-detail-closed")
.append($label)
.data('label', $label)
.append($content)
.data('content', $content)
.hide();
.data('content', $content);
$label.addClass('tree-element-detail-loading');
$.ajax({
url: this.ajaxURL,
type: 'POST',
dataType: 'json',
dataType: 'html',
async: true,
data: {
page: this.ajaxPage,
getDetail: 1,
type: this.type,
id: this.id
id: this.id,
serverID: this.serverID
},
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);
$label.addClass('tree-element-detail-loaded');
$content.html(data);
controller.open();
}
else {
$label.addClass('tree-element-detail-error');
$content.html(controller.errorMessage);
}
controller.open();
},
error: function(xhr, textStatus, errorThrown) {
$label.addClass('tree-element-detail-error');
@ -726,16 +766,15 @@ TreeNodeDetailController = {
});
this.recipient.append(this.container);
this.open();
},
load: function () {
this.reload();
},
toggle: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
if (typeof this.container == 'undefined' || this.container.length <= 0) {
return false;
}
if (this.container.isClosed) {
if (this.container.hasClass("tree-element-detail-closed")) {
this.open();
}
else {
@ -743,21 +782,23 @@ TreeNodeDetailController = {
}
},
open: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
if (typeof this.container == 'undefined' || this.container.length <= 0) {
return false;
}
if (this.container.isClosed) {
this.container.data('content').slideLeft();
this.container.isClosed = false;
if (this.container.hasClass("tree-element-detail-closed")) {
this.container
.removeClass("tree-element-detail-closed")
.data('content').show();
}
},
close: function () {
if (typeof this.container != 'undefined' && this.container.length > 0) {
if (typeof this.container == 'undefined' || this.container.length <= 0) {
return false;
}
if (!this.container.isClosed) {
this.container.data('content').slideRight();
this.container.isClosed = true;
if (!this.container.hasClass("tree-element-detail-closed")) {
this.container
.addClass("tree-element-detail-closed")
.data('content').hide();
}
},
init: function (data) {
@ -785,6 +826,9 @@ TreeNodeDetailController = {
else {
return false;
}
if (typeof data.serverID != 'undefined' && (data.serverID.length > 0 || !isNaN(data.serverID))) {
this.serverID = data.serverID;
}
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
this.emptyMessage = data.emptyMessage;
}
@ -826,27 +870,29 @@ TreeNodeDetailController = {
}
},
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);
try {
$.each(TreeNodeDetailController.controllers, function(type, elements) {
$.each(elements, function(id, element) {
if (controller.type != type && controller.id != id)
element.close();
});
});
}
catch (error) {
// console.log(error);
}
},
removeOther: function () {
if (TreeNodeDetailController.controllers.length > 0) {
try {
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);
elements.forEach(function(element, id) {
if (controller.type != type && controller.id != id)
element.remove();
});
});
}
catch (error) {
// console.log(error);
}
}
}

View File

@ -5,7 +5,7 @@
.tree-group {
margin-left: 16px;
padding-top: 4px;
padding-top: 1px;
}
.tree-node {
@ -22,11 +22,16 @@
background: 0 0;
}
.node-content {
height: 21px;
height: 16px;
}
.node-content>img {
position: relative;
top: -2px;
}
.node-content:hover {
background-color: #9AB8DF;
background-color: #FFF;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
@ -101,7 +106,9 @@
.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 {
.tree-node>.node-content>img.agent-quiet,
.tree-node>.node-content>img.module-status,
.tree-node>.node-content>img.module-alerts {
padding-right: 3px;
}
@ -122,4 +129,43 @@
font-weight: bold;
font-size: 7pt;
cursor: default;
}
}
div.tree-table {
display: table;
width: 98%;
margin-top: 10px;
}
div.tree-table-row {
display: table-row;
}
div.tree-table-cell {
display: table-cell;
vertical-align: top;
}
div.tree-table-cell.tree-table-cell-tree {
/*width: 70%;*/
max-width: 600px;
overflow-x: auto;
overflow-y: hidden;
}
div.tree-table-cell.tree-table-cell-detail {
padding-left: 10px;
width: 350px;
}
div.tree-element-detail-closed {
display: none;
}
div#tree-controller-recipient {
text-align: left;
}
div#tree-controller-detail-recipient {
/*text-align: right;*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,345 +0,0 @@
<?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_agent = get_parameter('searchAgent', '');
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
$search_module = get_parameter('searchModule', '');
$status_module = get_parameter('statusModule', -1);
// ---------------------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 = array();
$table->rowspan = array();
// Agent filter
$agent_status_arr = array();
$agent_status_arr[AGENT_STATUS_ALL] = __('All'); //default
$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal');
$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning');
$agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical');
$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown');
$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
$row = array();
$row[] = __('Agent status');
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
$row[] = __('Search agent');
$row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true);
// Button
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
$table->rowspan[][count($row)-1] = 2;
$table->data[] = $row;
// Module filter
$module_status_arr = array();
$module_status_arr[-1] = __('All'); //default
$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
$row = array();
$row[] = __('Module status');
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
$row[] = __('Search module');
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
$table->data[] = $row;
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_agent").val();
parameters['filter']['statusAgent'] = $("select#status_agent").val();
parameters['filter']['searchModule'] = $("input#text-search_module").val();
parameters['filter']['statusModule'] = $("select#status_module").val();
$.ajax({
type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
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 ui_get_full_url(false, false, false, false); ?>",
ajaxURL: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
filter: parameters['filter'],
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>