Merge branch 'feature/NewTreeView' into develop
This commit is contained in:
commit
4cf9accbd7
|
@ -79,14 +79,15 @@ if ($get_module_detail) {
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
$server = metaconsole_get_connection ($server_name);
|
$server = metaconsole_get_connection ($server_name);
|
||||||
$conexion = mysql_connect ($server['dbhost'], $server['dbuser'],
|
|
||||||
$server['dbpass']);
|
if (metaconsole_connect($server) != NOERR)
|
||||||
$select_db = mysql_select_db ($server['dbname'], $conexion);
|
return;
|
||||||
|
$conexion = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$conexion = false;
|
$conexion = false;
|
||||||
}
|
}
|
||||||
|
html_debug_print($conexion, true);
|
||||||
$selection_mode = get_parameter('selection_mode', 'fromnow');
|
$selection_mode = get_parameter('selection_mode', 'fromnow');
|
||||||
$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
|
$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
|
||||||
$time_from = (string) get_parameter ('time_from', date ('h:iA'));
|
$time_from = (string) get_parameter ('time_from', date ('h:iA'));
|
||||||
|
@ -266,6 +267,9 @@ if ($get_module_detail) {
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined ('METACONSOLE'))
|
||||||
|
metaconsole_restore_db();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,14 @@ if (is_ajax ()) {
|
||||||
|
|
||||||
$getChildren = (bool) get_parameter('getChildren', 0);
|
$getChildren = (bool) get_parameter('getChildren', 0);
|
||||||
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
||||||
$get_detail = (bool) get_parameter('getDetail');
|
$getDetail = (bool) get_parameter('getDetail');
|
||||||
|
|
||||||
if ($getChildren) {
|
if ($getChildren) {
|
||||||
$type = get_parameter('type', 'group');
|
$type = get_parameter('type', 'group');
|
||||||
$rootType = get_parameter('rootType', '');
|
$rootType = get_parameter('rootType', '');
|
||||||
$id = get_parameter('id', -1);
|
$id = get_parameter('id', -1);
|
||||||
$rootID = get_parameter('rootID', -1);
|
$rootID = get_parameter('rootID', -1);
|
||||||
|
$serverID = get_parameter('serverID', false);
|
||||||
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
||||||
|
|
||||||
$default_filters = array(
|
$default_filters = array(
|
||||||
|
@ -45,10 +46,10 @@ if (is_ajax ()) {
|
||||||
$filter = get_parameter('filter', $default_filters);
|
$filter = get_parameter('filter', $default_filters);
|
||||||
|
|
||||||
if (class_exists('TreeEnterprise')) {
|
if (class_exists('TreeEnterprise')) {
|
||||||
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $childrenMethod);
|
$tree = new TreeEnterprise($type, $rootType, $id, $rootID, $serverID, $childrenMethod);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tree = new Tree($type, $rootType, $id, $rootID, $childrenMethod);
|
$tree = new Tree($type, $rootType, $id, $rootID, $serverID, $childrenMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tree->setFilter($filter);
|
$tree->setFilter($filter);
|
||||||
|
@ -56,61 +57,38 @@ if (is_ajax ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($getGroupStatus) {
|
if ($getDetail) {
|
||||||
$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");
|
require_once($config['homedir']."/include/functions_treeview.php");
|
||||||
|
|
||||||
// Clean the output
|
|
||||||
ob_clean();
|
|
||||||
|
|
||||||
$id = (int) get_parameter('id');
|
$id = (int) get_parameter('id');
|
||||||
$type = (string) get_parameter('type');
|
$type = (string) get_parameter('type');
|
||||||
|
|
||||||
$server = array();
|
$server = array();
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
$server_name = (string) get_parameter('server');
|
$server_id = (int) get_parameter('serverID');
|
||||||
$server = metaconsole_get_connection($server_name);
|
$server = metaconsole_get_servers($server_id);
|
||||||
metaconsole_connect($server);
|
|
||||||
|
if (metaconsole_connect($server) != NOERR)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
ob_clean();
|
||||||
case 'agent':
|
|
||||||
treeview_printTable($id, $server);
|
if (!empty($id) && !empty($type)) {
|
||||||
break;
|
switch ($type) {
|
||||||
case 'module':
|
case 'agent':
|
||||||
treeview_printModuleTable($id, $server);
|
treeview_printTable($id, $server);
|
||||||
break;
|
break;
|
||||||
case 'alert':
|
case 'module':
|
||||||
treeview_printAlertsTable($id, $server);
|
treeview_printModuleTable($id, $server);
|
||||||
break;
|
break;
|
||||||
default:
|
case 'alert':
|
||||||
// Nothing
|
treeview_printAlertsTable($id, $server);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
// Nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($server) && defined ('METACONSOLE')) {
|
if (!empty($server) && defined ('METACONSOLE')) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Tree {
|
||||||
protected $rootType = null;
|
protected $rootType = null;
|
||||||
protected $id = -1;
|
protected $id = -1;
|
||||||
protected $rootID = -1;
|
protected $rootID = -1;
|
||||||
|
protected $serverID = false;
|
||||||
protected $tree = array();
|
protected $tree = array();
|
||||||
protected $filter = array();
|
protected $filter = array();
|
||||||
protected $childrenMethod = "on_demand";
|
protected $childrenMethod = "on_demand";
|
||||||
|
@ -27,12 +28,13 @@ class Tree {
|
||||||
protected $strictACL = false;
|
protected $strictACL = false;
|
||||||
protected $acltags = 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->type = $type;
|
||||||
$this->rootType = !empty($rootType) ? $rootType : $type;
|
$this->rootType = !empty($rootType) ? $rootType : $type;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->rootID = !empty($rootID) ? $rootID : $id;
|
$this->rootID = !empty($rootID) ? $rootID : $id;
|
||||||
|
$this->serverID = $serverID;
|
||||||
$this->childrenMethod = $childrenMethod;
|
$this->childrenMethod = $childrenMethod;
|
||||||
|
|
||||||
$userGroups = users_get_groups();
|
$userGroups = users_get_groups();
|
||||||
|
@ -45,6 +47,9 @@ class Tree {
|
||||||
global $config;
|
global $config;
|
||||||
include_once($config['homedir']."/include/functions_servers.php");
|
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']);
|
$this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
||||||
|
|
||||||
if ($this->strictACL) {
|
if ($this->strictACL) {
|
||||||
|
@ -150,7 +155,7 @@ class Tree {
|
||||||
// Not init
|
// Not init
|
||||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
||||||
$agents_not_init_count = "($agent_table
|
$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";
|
$columns = "$agents_not_init_count, $agents_fired_count, $agents_total_count";
|
||||||
break;
|
break;
|
||||||
case AGENT_STATUS_CRITICAL:
|
case AGENT_STATUS_CRITICAL:
|
||||||
|
@ -213,6 +218,9 @@ class Tree {
|
||||||
// Get the root id
|
// Get the root id
|
||||||
$rootID = $this->rootID;
|
$rootID = $this->rootID;
|
||||||
|
|
||||||
|
// Get the server id
|
||||||
|
$serverID = $this->serverID;
|
||||||
|
|
||||||
// Agent name filter
|
// Agent name filter
|
||||||
$agent_search_filter = "";
|
$agent_search_filter = "";
|
||||||
if (!empty($this->filter['searchAgent'])) {
|
if (!empty($this->filter['searchAgent'])) {
|
||||||
|
@ -377,9 +385,10 @@ class Tree {
|
||||||
ORDER BY $order_fields";
|
ORDER BY $order_fields";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
|
$columns = 'ta.id_agente AS id, ta.nombre AS name,
|
||||||
ta.normal_count, ta.warning_count, ta.critical_count,
|
ta.fired_count, ta.normal_count, ta.warning_count,
|
||||||
ta.unknown_count, ta.notinit_count, ta.total_count';
|
ta.critical_count, ta.unknown_count, ta.notinit_count,
|
||||||
|
ta.total_count, ta.quiet';
|
||||||
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
||||||
|
|
||||||
$sql = "SELECT $columns
|
$sql = "SELECT $columns
|
||||||
|
@ -508,9 +517,10 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
|
$columns = 'ta.id_agente AS id, ta.nombre AS name,
|
||||||
ta.normal_count, ta.warning_count, ta.critical_count,
|
ta.fired_count, ta.normal_count, ta.warning_count,
|
||||||
ta.unknown_count, ta.notinit_count, ta.total_count';
|
ta.critical_count, ta.unknown_count, ta.notinit_count,
|
||||||
|
ta.total_count, ta.quiet';
|
||||||
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
||||||
|
|
||||||
$sql = "SELECT $columns
|
$sql = "SELECT $columns
|
||||||
|
@ -603,9 +613,10 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
|
$columns = 'ta.id_agente AS id, ta.nombre AS name,
|
||||||
ta.normal_count, ta.warning_count, ta.critical_count,
|
ta.fired_count, ta.normal_count, ta.warning_count,
|
||||||
ta.unknown_count, ta.notinit_count, ta.total_count';
|
ta.critical_count, ta.unknown_count, ta.notinit_count,
|
||||||
|
ta.total_count, ta.quiet';
|
||||||
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
||||||
|
|
||||||
$sql = "SELECT $columns
|
$sql = "SELECT $columns
|
||||||
|
@ -701,9 +712,10 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
|
$columns = 'ta.id_agente AS id, ta.nombre AS name,
|
||||||
ta.normal_count, ta.warning_count, ta.critical_count,
|
ta.fired_count, ta.normal_count, ta.warning_count,
|
||||||
ta.unknown_count, ta.notinit_count, ta.total_count';
|
ta.critical_count, ta.unknown_count, ta.notinit_count,
|
||||||
|
ta.total_count, ta.quiet';
|
||||||
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
||||||
|
|
||||||
$sql = "SELECT $columns
|
$sql = "SELECT $columns
|
||||||
|
@ -802,9 +814,10 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count,
|
$columns = 'ta.id_agente AS id, ta.nombre AS name,
|
||||||
ta.normal_count, ta.warning_count, ta.critical_count,
|
ta.fired_count, ta.normal_count, ta.warning_count,
|
||||||
ta.unknown_count, ta.notinit_count, ta.total_count';
|
ta.critical_count, ta.unknown_count, ta.notinit_count,
|
||||||
|
ta.total_count, ta.quiet';
|
||||||
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
|
||||||
|
|
||||||
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
|
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
|
||||||
|
@ -881,21 +894,18 @@ class Tree {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID,
|
$sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID,
|
||||||
$agent_search_filter, $agent_status_filter,
|
$agent_search_filter, $agent_status_filter, $agents_join,
|
||||||
$agents_join, $module_search_filter,
|
$module_search_filter, $module_status_filter, $modules_join,
|
||||||
$module_status_filter, $modules_join,
|
|
||||||
$module_status_join);
|
$module_status_join);
|
||||||
}
|
}
|
||||||
|
|
||||||
html_debug_print($sql, true);
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override this method
|
// Override this method
|
||||||
protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID,
|
protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID,
|
||||||
$agent_search_filter, $agent_status_filter,
|
$agent_search_filter, $agent_status_filter, $agents_join,
|
||||||
$agents_join, $module_search_filter,
|
$module_search_filter, $module_status_filter, $modules_join,
|
||||||
$module_status_filter, $modules_join,
|
|
||||||
$module_status_join) {
|
$module_status_join) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -928,7 +938,7 @@ class Tree {
|
||||||
return strcmp($a["name"], $b["name"]);
|
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();
|
$children = array();
|
||||||
foreach ($groups as $key => $group) {
|
foreach ($groups as $key => $group) {
|
||||||
unset($groups[$key]);
|
unset($groups[$key]);
|
||||||
|
@ -936,7 +946,7 @@ class Tree {
|
||||||
if ((isset($group['parent']) && $group['parent'] == $parent_id)
|
if ((isset($group['parent']) && $group['parent'] == $parent_id)
|
||||||
|| (isset($group['_parent_id_']) && $group['_parent_id_'] == $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))
|
if (!empty($children_aux))
|
||||||
$children[] = $children_aux;
|
$children[] = $children_aux;
|
||||||
}
|
}
|
||||||
|
@ -945,7 +955,7 @@ class Tree {
|
||||||
return $children;
|
return $children;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getProcessedItem ($item, $server_id = false, $items = array()) {
|
protected function getProcessedItem ($item, $server = false, $items = array()) {
|
||||||
$processed_item = array();
|
$processed_item = array();
|
||||||
$processed_item['id'] = $item['id'];
|
$processed_item['id'] = $item['id'];
|
||||||
$processed_item['name'] = $item['name'];
|
$processed_item['name'] = $item['name'];
|
||||||
|
@ -972,8 +982,8 @@ class Tree {
|
||||||
$processed_item['icon'] = "without_group.png";
|
$processed_item['icon'] = "without_group.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined ('METACONSOLE') && $server_id) {
|
if (defined("METACONSOLE") && !empty($server)) {
|
||||||
$processed_item['server_id'] = $server_id;
|
$processed_item['serverID'] = $server['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$counters = array();
|
$counters = array();
|
||||||
|
@ -994,7 +1004,7 @@ class Tree {
|
||||||
|
|
||||||
if ($processed_item['type'] == 'group' && !empty($items)) {
|
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)) {
|
if (!empty($children)) {
|
||||||
$processed_item['children'] = $children;
|
$processed_item['children'] = $children;
|
||||||
|
|
||||||
|
@ -1030,9 +1040,11 @@ class Tree {
|
||||||
|
|
||||||
// The 'id' parameter will be stored as 'server_id' => 'id'
|
// The 'id' parameter will be stored as 'server_id' => 'id'
|
||||||
$resultItem['id'] = array();
|
$resultItem['id'] = array();
|
||||||
$resultItem['id'][$item['server_id']] = $item['id'];
|
$resultItem['id'][$item['serverID']] = $item['id'];
|
||||||
$resultItem['rootID'] = array();
|
$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
|
// Initialize counters if any of it don't exist
|
||||||
if (!isset($resultItem['counters']))
|
if (!isset($resultItem['counters']))
|
||||||
|
@ -1067,8 +1079,9 @@ class Tree {
|
||||||
// Match with the name and type
|
// Match with the name and type
|
||||||
if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) {
|
if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) {
|
||||||
// Add the matched ids
|
// Add the matched ids
|
||||||
$resultItem['id'][$item2['server_id']] = $item2['id'];
|
$resultItem['id'][$item2['serverID']] = $item2['id'];
|
||||||
$resultItem['rootID'][$item2['server_id']] = $item2['rootID'];
|
$resultItem['rootID'][$item2['serverID']] = $item2['rootID'];
|
||||||
|
$resultItem['serverID'][$item2['serverID']] = $item2['rootID'];
|
||||||
|
|
||||||
// Add the matched counters
|
// Add the matched counters
|
||||||
if (isset($item2['counters']) && !empty($item2['counters'])) {
|
if (isset($item2['counters']) && !empty($item2['counters'])) {
|
||||||
|
@ -1109,7 +1122,7 @@ class Tree {
|
||||||
return $mergedItems;
|
return $mergedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processModule (&$module) {
|
protected function processModule (&$module, $server = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$module['type'] = 'module';
|
$module['type'] = 'module';
|
||||||
|
@ -1119,7 +1132,11 @@ class Tree {
|
||||||
$module['server_type'] = (int) $module['id_modulo'];
|
$module['server_type'] = (int) $module['id_modulo'];
|
||||||
$module['status'] = $module['estado'];
|
$module['status'] = $module['estado'];
|
||||||
$module['value'] = $module['datos'];
|
$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']))
|
if (!isset($module['value']))
|
||||||
$module['value'] = modules_get_last_value($module['id']);
|
$module['value'] = modules_get_last_value($module['id']);
|
||||||
|
@ -1180,27 +1197,50 @@ class Tree {
|
||||||
$graphType = return_graphtype($module['id']);
|
$graphType = return_graphtype($module['id']);
|
||||||
$winHandle = dechex(crc32($module['id'] . $module['name']));
|
$winHandle = dechex(crc32($module['id'] . $module['name']));
|
||||||
|
|
||||||
$moduleGraphURL = $config['homeurl'] .
|
if (!defined('METACONSOLE')) {
|
||||||
"/operation/agentes/stat_win.php?" .
|
$moduleGraphURL = $config['homeurl'] .
|
||||||
"type=$graphType&" .
|
"/operation/agentes/stat_win.php?" .
|
||||||
"period=86400&" .
|
"type=$graphType&" .
|
||||||
"id=" . $module['id'] . "&" .
|
"period=86400&" .
|
||||||
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
|
"id=" . $module['id'] . "&" .
|
||||||
"refresh=600";
|
"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");
|
||||||
|
}
|
||||||
|
|
||||||
$module['moduleGraph'] = array(
|
if (!empty($moduleGraphURL)) {
|
||||||
'url' => $moduleGraphURL,
|
$module['moduleGraph'] = array(
|
||||||
'handle' => $winHandle
|
'url' => $moduleGraphURL,
|
||||||
);
|
'handle' => $winHandle
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function processModules (&$modules) {
|
// Alerts fired image
|
||||||
foreach ($modules as $iterator => $module) {
|
$has_alerts = (bool) db_get_value('COUNT(DISTINCT(id_agent_module))', 'talert_template_modules', 'id_agent_module', $module['id']);
|
||||||
$this->processModule($modules[$iterator]);
|
|
||||||
|
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['type'] = 'agent';
|
||||||
$agent['id'] = (int) $agent['id'];
|
$agent['id'] = (int) $agent['id'];
|
||||||
$agent['name'] = $agent['name'];
|
$agent['name'] = $agent['name'];
|
||||||
|
@ -1208,11 +1248,8 @@ class Tree {
|
||||||
$agent['rootID'] = $this->rootID;
|
$agent['rootID'] = $this->rootID;
|
||||||
$agent['rootType'] = $this->rootType;
|
$agent['rootType'] = $this->rootType;
|
||||||
|
|
||||||
$id = $agent['id'];
|
if (defined("METACONSOLE") && !empty($server))
|
||||||
if ($server_id) {
|
$agent['serverID'] = $server['id'];
|
||||||
$agent['id'] = array();
|
|
||||||
$agent['id'][$server_id] = $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Counters
|
// Counters
|
||||||
if (empty($agent['counters'])) {
|
if (empty($agent['counters'])) {
|
||||||
|
@ -1221,37 +1258,37 @@ class Tree {
|
||||||
if (isset($agent['unknown_count']))
|
if (isset($agent['unknown_count']))
|
||||||
$agent['counters']['unknown'] = $agent['unknown_count'];
|
$agent['counters']['unknown'] = $agent['unknown_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['unknown'] = agents_monitor_unknown($id);
|
$agent['counters']['unknown'] = agents_monitor_unknown($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['critical_count']))
|
if (isset($agent['critical_count']))
|
||||||
$agent['counters']['critical'] = $agent['critical_count'];
|
$agent['counters']['critical'] = $agent['critical_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['critical'] = agents_monitor_critical($id);
|
$agent['counters']['critical'] = agents_monitor_critical($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['warning_count']))
|
if (isset($agent['warning_count']))
|
||||||
$agent['counters']['warning'] = $agent['warning_count'];
|
$agent['counters']['warning'] = $agent['warning_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['warning'] = agents_monitor_warning($id);
|
$agent['counters']['warning'] = agents_monitor_warning($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['notinit_count']))
|
if (isset($agent['notinit_count']))
|
||||||
$agent['counters']['not_init'] = $agent['notinit_count'];
|
$agent['counters']['not_init'] = $agent['notinit_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['not_init'] = agents_monitor_notinit($id);
|
$agent['counters']['not_init'] = agents_monitor_notinit($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['normal_count']))
|
if (isset($agent['normal_count']))
|
||||||
$agent['counters']['ok'] = $agent['normal_count'];
|
$agent['counters']['ok'] = $agent['normal_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['ok'] = agents_monitor_ok($id);
|
$agent['counters']['ok'] = agents_monitor_ok($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['total_count']))
|
if (isset($agent['total_count']))
|
||||||
$agent['counters']['total'] = $agent['total_count'];
|
$agent['counters']['total'] = $agent['total_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['total'] = agents_monitor_total($id);
|
$agent['counters']['total'] = agents_monitor_total($agent['id']);
|
||||||
|
|
||||||
if (isset($agent['fired_count']))
|
if (isset($agent['fired_count']))
|
||||||
$agent['counters']['alerts'] = $agent['fired_count'];
|
$agent['counters']['alerts'] = $agent['fired_count'];
|
||||||
else
|
else
|
||||||
$agent['counters']['alerts'] = agents_get_alerts_fired($id);
|
$agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status image
|
// Status image
|
||||||
|
@ -1265,8 +1302,12 @@ class Tree {
|
||||||
// Alerts fired image
|
// Alerts fired image
|
||||||
$agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']);
|
$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
|
// Status
|
||||||
$agent['statusRaw'] = agents_get_status($id);
|
$agent['statusRaw'] = agents_get_status($agent['id']);
|
||||||
switch ($agent['statusRaw']) {
|
switch ($agent['statusRaw']) {
|
||||||
case AGENT_STATUS_NORMAL:
|
case AGENT_STATUS_NORMAL:
|
||||||
$agent['status'] = "ok";
|
$agent['status'] = "ok";
|
||||||
|
@ -1300,7 +1341,7 @@ class Tree {
|
||||||
$agent['searchChildren'] = 0;
|
$agent['searchChildren'] = 0;
|
||||||
|
|
||||||
// if ($searchChildren)
|
// if ($searchChildren)
|
||||||
// $agent['children'] = $this->getModules($id, $modulesFilter);
|
// $agent['children'] = $this->getModules($agent['id'], $modulesFilter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1317,10 +1358,10 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processAgents (&$agents, $server_id = false) {
|
protected function processAgents (&$agents, $server = false) {
|
||||||
if (!empty($agents)) {
|
if (!empty($agents)) {
|
||||||
foreach ($agents as $iterator => $agent) {
|
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;
|
$processed_items = $items;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ids = $this->id;
|
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($ids as $serverID => $id) {
|
|
||||||
$server = metaconsole_get_servers($serverID);
|
|
||||||
if (metaconsole_connect($server) != NOERR)
|
|
||||||
continue;
|
|
||||||
db_clean_cache();
|
|
||||||
|
|
||||||
$this->id = $id;
|
if ($this->serverID !== false) {
|
||||||
$newItems = $this->getItems();
|
|
||||||
$this->processModules($newItems);
|
|
||||||
$items = array_merge($items, $newItems);
|
|
||||||
|
|
||||||
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))
|
if (!empty($items))
|
||||||
usort($items, array("Tree", "cmpSortNames"));
|
usort($items, array("Tree", "cmpSortNames"));
|
||||||
|
@ -1519,7 +1558,7 @@ class Tree {
|
||||||
if (isset($item['_monitors_alerts_fired_']))
|
if (isset($item['_monitors_alerts_fired_']))
|
||||||
$item['total_fired_count'] = $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;
|
$unmerged_items += $processed_items;
|
||||||
|
@ -1549,7 +1588,7 @@ class Tree {
|
||||||
|
|
||||||
$this->rootID = $rootID;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
|
@ -1606,7 +1645,7 @@ class Tree {
|
||||||
if (empty($item['parent'])) {
|
if (empty($item['parent'])) {
|
||||||
|
|
||||||
unset($items[$key]);
|
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;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
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;
|
$processed_items[] = $processed_item;
|
||||||
}
|
}
|
||||||
$item_list = array_merge($item_list, $processed_items);
|
$item_list = array_merge($item_list, $processed_items);
|
||||||
|
@ -1726,7 +1765,7 @@ class Tree {
|
||||||
|
|
||||||
$this->rootID = $rootID;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
|
@ -1814,7 +1853,7 @@ class Tree {
|
||||||
'_articapandora_'.ord('!').'_pandoraartica_'),
|
'_articapandora_'.ord('!').'_pandoraartica_'),
|
||||||
io_safe_output($item['name']));
|
io_safe_output($item['name']));
|
||||||
|
|
||||||
$processed_item = $this->getProcessedItem($item, $server['id']);
|
$processed_item = $this->getProcessedItem($item, $server);
|
||||||
$processed_item['id'] = $name;
|
$processed_item['id'] = $name;
|
||||||
$processed_item['rootID'] = $name;
|
$processed_item['rootID'] = $name;
|
||||||
|
|
||||||
|
@ -1847,7 +1886,7 @@ class Tree {
|
||||||
|
|
||||||
$this->rootID = $rootID;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
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;
|
$processed_items[] = $processed_item;
|
||||||
}
|
}
|
||||||
$item_list = array_merge($item_list, $processed_items);
|
$item_list = array_merge($item_list, $processed_items);
|
||||||
|
@ -1936,7 +1975,7 @@ class Tree {
|
||||||
|
|
||||||
$this->rootID = $rootID;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
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_item['icon'] = $item['os_icon'];
|
||||||
$processed_items[] = $processed_item;
|
$processed_items[] = $processed_item;
|
||||||
}
|
}
|
||||||
|
@ -2027,7 +2066,7 @@ class Tree {
|
||||||
|
|
||||||
$this->rootID = $rootID;
|
$this->rootID = $rootID;
|
||||||
$newItems = $this->getItems();
|
$newItems = $this->getItems();
|
||||||
$this->processAgents($newItems, $serverID);
|
$this->processAgents($newItems, $server);
|
||||||
$items = array_merge($items, $newItems);
|
$items = array_merge($items, $newItems);
|
||||||
|
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
|
|
|
@ -55,55 +55,75 @@ function treeview_printModuleTable($id_module, $server_data = false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div id="id_div3" width="450px">';
|
$table = new StdClass();
|
||||||
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%; min-width: 300px;">';
|
$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
|
//Module name
|
||||||
echo '<tr><td class="datos"><b>'.__('Module name').'</b></td>';
|
|
||||||
|
|
||||||
if ($module["disabled"])
|
if ($module["disabled"])
|
||||||
$cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>";
|
$cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>";
|
||||||
else
|
else
|
||||||
$cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;");
|
$cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"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
|
// Interval
|
||||||
echo '<tr><td class="datos"><b>' . __('Interval') . '</b></td>';
|
$row = array();
|
||||||
echo '<td class="datos" colspan="2">' . human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true) . '</td></tr>';
|
$row['title'] = __('Interval');
|
||||||
|
$row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true);
|
||||||
|
$table->data['interval'] = $row;
|
||||||
|
|
||||||
// Warning Min/Max
|
// Warning Min/Max
|
||||||
echo '<tr><td class="datos"><b>' . __('Warning status') . '</b></td>';
|
|
||||||
if (modules_is_string_type($module['id_tipo_modulo'])) {
|
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 {
|
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
|
// Critical Min/Max
|
||||||
echo '<tr><td class="datos"><b>' . __('Critical status') . '</b></td>';
|
|
||||||
if (modules_is_string_type($module['id_tipo_modulo'])) {
|
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 {
|
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
|
// 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']);
|
$module_group = modules_get_modulegroup_name($module['id_module_group']);
|
||||||
|
|
||||||
if ($module_group === false)
|
if ($module_group === false)
|
||||||
echo __('Not assigned');
|
$module_group = __('Not assigned');
|
||||||
else
|
else
|
||||||
echo __("$module_group");
|
$module_group = __("$module_group");
|
||||||
echo '</td></tr>';
|
|
||||||
|
$row = array();
|
||||||
|
$row['title'] = __('Module group');
|
||||||
|
$row['data'] = $module_group;
|
||||||
|
$table->data['module_group'] = $row;
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
echo '<tr><td class="datos"><b>'.__('Description').'</b></td>';
|
$row = array();
|
||||||
echo '<td class="datos" colspan="2">'. ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]') .'</td></tr>';
|
$row['title'] = __('Description');
|
||||||
|
$row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]');
|
||||||
|
$table->data['description'] = $row;
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
$tags = tags_get_module_tags($module['id_agente_modulo']);
|
$tags = tags_get_module_tags($module['id_agente_modulo']);
|
||||||
|
@ -135,8 +155,10 @@ function treeview_printModuleTable($id_module, $server_data = false) {
|
||||||
$tags = implode(', ' , $tags);
|
$tags = implode(', ' , $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<tr><td class="datos"><b>'.__('Tags').'</b></td>';
|
$row = array();
|
||||||
echo '<td class="datos" colspan="2">' . $tags . '</td></tr>';
|
$row['title'] = __('Tags');
|
||||||
|
$row['data'] = $tags;
|
||||||
|
$table->data['tags'] = $row;
|
||||||
|
|
||||||
// Data
|
// 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')));
|
$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
|
else
|
||||||
$data = "<span title='" . $last_data["datos"] . "' style='white-space: nowrap;'>" . substr(io_safe_output($last_data['datos']),0,12) . "</span>";
|
$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'])) {
|
if (!empty($last_data['utimestamp'])) {
|
||||||
echo $data;
|
$last_data_str = $data;
|
||||||
|
|
||||||
if ($module['unit'] != '') {
|
if ($module['unit'] != '') {
|
||||||
echo " ";
|
$last_data_str .= " ";
|
||||||
echo '('.$module['unit'].')';
|
$last_data_str .= '('.$module['unit'].')';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo " ";
|
$last_data_str .= " ";
|
||||||
html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px'));
|
$last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
|
||||||
}
|
}
|
||||||
else {
|
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
|
//End of table
|
||||||
echo '</table></div>';
|
html_print_table($table);
|
||||||
|
|
||||||
$id_group = agents_get_agent_group($module['id_agente']);
|
$id_group = agents_get_agent_group($module['id_agente']);
|
||||||
$group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
|
$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')) {
|
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) {
|
||||||
// Actions table
|
// Actions table
|
||||||
echo '<div style="width:90%; text-align: right; min-width: 300px;">';
|
echo '<div style="width:100%; 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 '<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"');
|
html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"');
|
||||||
echo '</form>';
|
echo '</a>';
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
@ -218,42 +240,53 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div id="id_div3" width="450px">';
|
$table = new StdClass();
|
||||||
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%; min-width: 300px;">';
|
$table->width = "100%";
|
||||||
echo '<tr><th colspan=2 class="datos"><center>' . $module_name . '</center></th></tr>';
|
$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();
|
||||||
|
|
||||||
echo '<tr><th class="datos" style="background: #B3B3B3;"><b>'.__('Template').'</b></th>';
|
$row = array();
|
||||||
echo '<th class="datos" style="background: #B3B3B3;"><b>'.__('Actions').'</b></th>';
|
$row['template'] = __('Template');
|
||||||
|
$row['actions'] = __('Actions');
|
||||||
|
$table->data['titles'] = $row;
|
||||||
|
|
||||||
foreach($module_alerts as $module_alert) {
|
foreach($module_alerts as $module_alert) {
|
||||||
//Template name
|
//Template name
|
||||||
echo '<tr>';
|
|
||||||
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);
|
$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']);
|
$actions = alerts_get_alert_agent_module_actions($module_alert['id']);
|
||||||
echo '<td class="datos">';
|
|
||||||
if (empty($actions)) {
|
if (empty($actions)) {
|
||||||
echo '<i>'.__('N/A').'</i>';
|
$actions_list = '<i>'.__('N/A').'</i>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<ul>';
|
$actions_list = '<ul>';
|
||||||
foreach($actions as $act) {
|
foreach($actions_list as $act) {
|
||||||
echo '<li>';
|
$actions_list .= '<li>';
|
||||||
echo $act['name'];
|
$actions_list .= $act['name'];
|
||||||
echo '</li>';
|
$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')) {
|
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
|
||||||
// Actions table
|
// Actions table
|
||||||
echo '<div style="width:90%; text-align: right; min-width: 300px;">';
|
echo '<div style="width:100%; 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 '<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"');
|
html_print_submit_button (__('Go to alerts edition'), 'upd_button', false, 'class="sub search"');
|
||||||
echo '</form>';
|
echo '</a>';
|
||||||
echo '</div>';
|
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")) {
|
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 = '<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 .= 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>';
|
$go_to_agent .= '</div>';
|
||||||
|
|
||||||
$agent_table .= $go_to_agent;
|
$agent_table .= $go_to_agent;
|
||||||
|
|
|
@ -77,10 +77,10 @@ TreeController = {
|
||||||
modules: "Total modules",
|
modules: "Total modules",
|
||||||
none: "Total"
|
none: "Total"
|
||||||
},
|
},
|
||||||
fired: {
|
alerts: {
|
||||||
agents: "Alert fired",
|
agents: "Alerts fired",
|
||||||
modules: "Alert fired",
|
modules: "Alerts fired",
|
||||||
none: "Alert fired"
|
none: "Alerts fired"
|
||||||
},
|
},
|
||||||
critical: {
|
critical: {
|
||||||
agents: "Critical agents",
|
agents: "Critical agents",
|
||||||
|
@ -173,16 +173,16 @@ TreeController = {
|
||||||
|
|
||||||
$counters.append($totalCounter);
|
$counters.append($totalCounter);
|
||||||
|
|
||||||
if (typeof counters.fired != 'undefined'
|
if (typeof counters.alerts != 'undefined'
|
||||||
&& counters.fired > 0) {
|
&& counters.alerts > 0) {
|
||||||
var $firedCounter = $("<div></div>");
|
var $firedCounter = $("<div></div>");
|
||||||
$firedCounter
|
$firedCounter
|
||||||
.addClass('tree-node-counter')
|
.addClass('tree-node-counter')
|
||||||
.addClass('fired')
|
.addClass('alerts')
|
||||||
.addClass('orange')
|
.addClass('orange')
|
||||||
.html(counters.fired);
|
.html(counters.alerts);
|
||||||
|
|
||||||
_processNodeCounterTitle($firedCounter, type, "fired");
|
_processNodeCounterTitle($firedCounter, type, "alerts");
|
||||||
|
|
||||||
$counters
|
$counters
|
||||||
.append(" : ")
|
.append(" : ")
|
||||||
|
@ -311,6 +311,14 @@ TreeController = {
|
||||||
$content.append(element.name);
|
$content.append(element.name);
|
||||||
break;
|
break;
|
||||||
case 'agent':
|
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
|
// Status image
|
||||||
if (typeof element.statusImageHTML != 'undefined'
|
if (typeof element.statusImageHTML != 'undefined'
|
||||||
&& element.statusImageHTML.length > 0) {
|
&& element.statusImageHTML.length > 0) {
|
||||||
|
@ -361,14 +369,16 @@ TreeController = {
|
||||||
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
|
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$content.append($graphImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data pop-up
|
// Data pop-up
|
||||||
if (typeof element.id != 'undefined'
|
if (typeof element.id != 'undefined' && !isNaN(element.id)) {
|
||||||
&& !isNaN(element.id)) {
|
|
||||||
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
||||||
+'images/binary.png" /> ');
|
+'images/binary.png" /> ');
|
||||||
$dataImage
|
$dataImage
|
||||||
|
@ -377,19 +387,46 @@ TreeController = {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var serverName = element.serverName.length > 0 ? element.serverName : '';
|
||||||
if ($("#module_details_window").length > 0)
|
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) {
|
catch (error) {
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$content.append($dataImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content
|
// Alerts
|
||||||
.append($graphImage)
|
if (typeof element.alertsImageHTML != 'undefined'
|
||||||
.append($dataImage)
|
&& element.alertsImageHTML.length > 0) {
|
||||||
.append(element.name);
|
|
||||||
|
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;
|
break;
|
||||||
case 'os':
|
case 'os':
|
||||||
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
|
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
|
||||||
|
@ -419,16 +456,20 @@ TreeController = {
|
||||||
|
|
||||||
// If exist the detail container, show the data
|
// If exist the detail container, show the data
|
||||||
if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) {
|
if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) {
|
||||||
$content.click(function (e) {
|
if (element.type == 'agent' || element.type == 'module') {
|
||||||
TreeNodeDetailController.getController().init({
|
$content.click(function (e) {
|
||||||
recipient: controller.detailRecipient,
|
TreeNodeDetailController.getController().init({
|
||||||
type: element.type,
|
recipient: controller.detailRecipient,
|
||||||
id: element.id,
|
type: element.type,
|
||||||
baseURL: controller.baseURL,
|
id: element.id,
|
||||||
ajaxURL: controller.ajaxURL,
|
serverID: element.serverID,
|
||||||
ajaxPage: controller.ajaxPage
|
baseURL: controller.baseURL,
|
||||||
});
|
ajaxURL: controller.ajaxURL,
|
||||||
});
|
ajaxPage: controller.ajaxPage
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.css('cursor', 'pointer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$node
|
$node
|
||||||
|
@ -494,6 +535,7 @@ TreeController = {
|
||||||
id: element.id,
|
id: element.id,
|
||||||
type: element.type,
|
type: element.type,
|
||||||
rootID: element.rootID,
|
rootID: element.rootID,
|
||||||
|
serverID: element.serverID,
|
||||||
rootType: element.rootType,
|
rootType: element.rootType,
|
||||||
filter: controller.filter
|
filter: controller.filter
|
||||||
},
|
},
|
||||||
|
@ -648,21 +690,23 @@ TreeNodeDetailController = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeControllers: function () {
|
removeControllers: function () {
|
||||||
if (TreeNodeDetailController.controllers.length > 0) {
|
try {
|
||||||
TreeNodeDetailController.controllers.forEach(function(elements, type) {
|
$.each(TreeNodeDetailController.controllers, function(type, elements) {
|
||||||
if (elements.length > 0) {
|
$.each(elements, function(id, element) {
|
||||||
elements.forEach(function(element, id) {
|
element.remove();
|
||||||
element.remove();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
// console.log(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getController: function () {
|
getController: function () {
|
||||||
var controller = {
|
var controller = {
|
||||||
recipient: '',
|
recipient: '',
|
||||||
type: 'none',
|
type: 'none',
|
||||||
id: -1,
|
id: -1,
|
||||||
|
serverID: -1,
|
||||||
emptyMessage: "Empty",
|
emptyMessage: "Empty",
|
||||||
errorMessage: "Error",
|
errorMessage: "Error",
|
||||||
baseURL: "",
|
baseURL: "",
|
||||||
|
@ -687,37 +731,33 @@ TreeNodeDetailController = {
|
||||||
this.container = $("<div></div>");
|
this.container = $("<div></div>");
|
||||||
this.container
|
this.container
|
||||||
.addClass("tree-element-detail")
|
.addClass("tree-element-detail")
|
||||||
|
.addClass("tree-element-detail-closed")
|
||||||
.append($label)
|
.append($label)
|
||||||
.data('label', $label)
|
.data('label', $label)
|
||||||
.append($content)
|
.append($content)
|
||||||
.data('content', $content)
|
.data('content', $content);
|
||||||
.hide();
|
|
||||||
|
|
||||||
$label.addClass('tree-element-detail-loading');
|
$label.addClass('tree-element-detail-loading');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.ajaxURL,
|
url: this.ajaxURL,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'html',
|
||||||
|
async: true,
|
||||||
data: {
|
data: {
|
||||||
page: this.ajaxPage,
|
page: this.ajaxPage,
|
||||||
getDetail: 1,
|
getDetail: 1,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
id: this.id
|
id: this.id,
|
||||||
|
serverID: this.serverID
|
||||||
},
|
},
|
||||||
complete: function(xhr, textStatus) {
|
complete: function(xhr, textStatus) {
|
||||||
$label.removeClass('tree-element-detail-loading');
|
$label.removeClass('tree-element-detail-loading');
|
||||||
},
|
},
|
||||||
success: function(data, textStatus, xhr) {
|
success: function(data, textStatus, xhr) {
|
||||||
if (data.success) {
|
$label.addClass('tree-element-detail-loaded');
|
||||||
$label.addClass('tree-element-detail-loaded');
|
$content.html(data);
|
||||||
$content.html(data.html);
|
|
||||||
|
|
||||||
controller.open();
|
controller.open();
|
||||||
}
|
|
||||||
else {
|
|
||||||
$label.addClass('tree-element-detail-error');
|
|
||||||
$content.html(controller.errorMessage);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function(xhr, textStatus, errorThrown) {
|
error: function(xhr, textStatus, errorThrown) {
|
||||||
$label.addClass('tree-element-detail-error');
|
$label.addClass('tree-element-detail-error');
|
||||||
|
@ -726,16 +766,15 @@ TreeNodeDetailController = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.recipient.append(this.container);
|
this.recipient.append(this.container);
|
||||||
this.open();
|
|
||||||
},
|
},
|
||||||
load: function () {
|
load: function () {
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
toggle: function () {
|
toggle: function () {
|
||||||
if (typeof this.container != 'undefined' && this.container.length > 0) {
|
if (typeof this.container == 'undefined' || this.container.length <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.container.isClosed) {
|
if (this.container.hasClass("tree-element-detail-closed")) {
|
||||||
this.open();
|
this.open();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -743,21 +782,23 @@ TreeNodeDetailController = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open: function () {
|
open: function () {
|
||||||
if (typeof this.container != 'undefined' && this.container.length > 0) {
|
if (typeof this.container == 'undefined' || this.container.length <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.container.isClosed) {
|
if (this.container.hasClass("tree-element-detail-closed")) {
|
||||||
this.container.data('content').slideLeft();
|
this.container
|
||||||
this.container.isClosed = false;
|
.removeClass("tree-element-detail-closed")
|
||||||
|
.data('content').show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close: function () {
|
close: function () {
|
||||||
if (typeof this.container != 'undefined' && this.container.length > 0) {
|
if (typeof this.container == 'undefined' || this.container.length <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!this.container.isClosed) {
|
if (!this.container.hasClass("tree-element-detail-closed")) {
|
||||||
this.container.data('content').slideRight();
|
this.container
|
||||||
this.container.isClosed = true;
|
.addClass("tree-element-detail-closed")
|
||||||
|
.data('content').hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
init: function (data) {
|
init: function (data) {
|
||||||
|
@ -785,6 +826,9 @@ TreeNodeDetailController = {
|
||||||
else {
|
else {
|
||||||
return false;
|
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) {
|
if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) {
|
||||||
this.emptyMessage = data.emptyMessage;
|
this.emptyMessage = data.emptyMessage;
|
||||||
}
|
}
|
||||||
|
@ -826,27 +870,29 @@ TreeNodeDetailController = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeOther: function () {
|
closeOther: function () {
|
||||||
if (TreeNodeDetailController.controllers.length > 0) {
|
try {
|
||||||
TreeNodeDetailController.controllers.forEach(function(elements, type) {
|
$.each(TreeNodeDetailController.controllers, function(type, elements) {
|
||||||
if (elements.length > 0) {
|
$.each(elements, function(id, element) {
|
||||||
elements.forEach(function(element, id) {
|
if (controller.type != type && controller.id != id)
|
||||||
if (this.type != type && this.id != id)
|
element.close();
|
||||||
element.close();
|
});
|
||||||
}, this);
|
});
|
||||||
}
|
}
|
||||||
}, this);
|
catch (error) {
|
||||||
|
// console.log(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeOther: function () {
|
removeOther: function () {
|
||||||
if (TreeNodeDetailController.controllers.length > 0) {
|
try {
|
||||||
TreeNodeDetailController.controllers.forEach(function(elements, type) {
|
TreeNodeDetailController.controllers.forEach(function(elements, type) {
|
||||||
if (elements.length > 0) {
|
elements.forEach(function(element, id) {
|
||||||
elements.forEach(function(element, id) {
|
if (controller.type != type && controller.id != id)
|
||||||
if (this.type != type && this.id != id)
|
element.remove();
|
||||||
element.remove();
|
});
|
||||||
}, this);
|
});
|
||||||
}
|
}
|
||||||
}, this);
|
catch (error) {
|
||||||
|
// console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
.tree-group {
|
.tree-group {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
padding-top: 4px;
|
padding-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tree-node {
|
.tree-node {
|
||||||
|
@ -22,11 +22,16 @@
|
||||||
background: 0 0;
|
background: 0 0;
|
||||||
}
|
}
|
||||||
.node-content {
|
.node-content {
|
||||||
height: 21px;
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.node-content>img {
|
||||||
|
position: relative;
|
||||||
|
top: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.node-content:hover {
|
.node-content:hover {
|
||||||
background-color: #9AB8DF;
|
background-color: #FFF;
|
||||||
|
|
||||||
-moz-border-radius: 3px;
|
-moz-border-radius: 3px;
|
||||||
-webkit-border-radius: 3px;
|
-webkit-border-radius: 3px;
|
||||||
|
@ -101,7 +106,9 @@
|
||||||
.tree-node>.node-content>img.module-server-type,
|
.tree-node>.node-content>img.module-server-type,
|
||||||
.tree-node>.node-content>img.agent-status,
|
.tree-node>.node-content>img.agent-status,
|
||||||
.tree-node>.node-content>img.agent-alerts-fired,
|
.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;
|
padding-right: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,3 +130,42 @@
|
||||||
font-size: 7pt;
|
font-size: 7pt;
|
||||||
cursor: default;
|
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
|
@ -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>
|
|
Loading…
Reference in New Issue