diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 3955f54193..312bc851d2 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150129 +Version: 6.0dev-150202 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 53acb65bc0..216882340b 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150129" +pandora_version="6.0dev-150202" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index ecc31bc26c..82e6922af4 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150129'; +use constant AGENT_BUILD => '150202'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d74e476745..f9571a9bf9 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150129 +%define release 150202 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index cd28932ad9..6dff49351f 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150129 +%define release 150202 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/configure.in b/pandora_agents/win32/configure.in index 51a3f8f739..77acf8d373 100644 --- a/pandora_agents/win32/configure.in +++ b/pandora_agents/win32/configure.in @@ -34,7 +34,7 @@ AC_CHECK_LIB([psapi], [main], , AC_MSG_ERROR([libpsapi not found.])) AC_CHECK_LIB([ole32], [main], , AC_MSG_ERROR([libole32 not found.])) AC_CHECK_LIB([oleaut32], [main], , AC_MSG_ERROR([liboleaut not found.])) AC_CHECK_LIB([uuid], [main], , AC_MSG_ERROR([libuuid not found.])) -AC_CHECK_LIB([boost_regex-mt-s], [main], , AC_MSG_ERROR([Boost.Regex not not found. Get it from http://www.boost.org/])) +AC_CHECK_LIB([boost_regex-mt], [main], , AC_MSG_ERROR([Boost.Regex not not found. Get it from http://www.boost.org/])) AC_CHECK_LIB([gdi32], [main], , AC_MSG_ERROR([libgdi32 not found.])) AC_CHECK_LIB([crypto], [main], , AC_MSG_ERROR([libcrypto not found.])) AC_CHECK_LIB([ssl], [main], , AC_MSG_ERROR([libssl not found.])) diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ad33f2b2c6..c139e76d4e 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150129} +{150202} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 2bc367bba3..0c6c1affdd 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("6.0dev(Build 150129)") +#define PANDORA_VERSION ("6.0dev(Build 150202)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 866911e472..8ecb32af98 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(6.0dev(Build 150129))" + VALUE "ProductVersion", "(6.0dev(Build 150202))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0fb663cf95..1162767340 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150129 +Version: 6.0dev-150202 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index de4bd661d7..5b153d86f8 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150129" +pandora_version="6.0dev-150202" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index d64d13f6e5..4d05a97be3 100755 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -17,15 +17,9 @@ if (isset($_GET['get_ptr'])) { if ($_GET['get_ptr'] == 1) { - if (file_exists("../include/config.php")) - require ("../include/config.php"); - else { - //TODO FIX AND SET AS RELATIVE DIRECTORY - if (file_exists("/var/www/pandora_console/include/config.php")) - require ("/var/www/pandora_console/include/config.php"); - if (file_exists("/srv/www/htdocs/pandora_console/include/config.php")) - require ("/srv/www/htdocs/pandora_console/include/config.php"); - } + $ownDir = dirname(__FILE__) . '/'; + $ownDir = str_replace("\\", "/", $ownDir); + require_once ($ownDir.'../include/config.php'); if (! isset ($_SESSION["id_usuario"])) { session_start (); diff --git a/pandora_console/godmode/audit_log_csv.php b/pandora_console/godmode/audit_log_csv.php index a4b1d1e559..5eed703e3f 100644 --- a/pandora_console/godmode/audit_log_csv.php +++ b/pandora_console/godmode/audit_log_csv.php @@ -10,21 +10,14 @@ // You cannnot redistribute it without written permission of copyright holder. // ============================================================================ -if (file_exists("../../../include/config.php")) - require ("../../../include/config.php"); -else { - //TODO FIX AND SET AS RELATIVE DIRECTORY - if (file_exists("/var/www/pandora_console/include/config.php")) - require ("/var/www/pandora_console/include/config.php"); - if (file_exists("/srv/www/htdocs/pandora_console/include/config.php")) - require ("/srv/www/htdocs/pandora_console/include/config.php"); -} +$ownDir = dirname(__FILE__) . '/'; +$ownDir = str_replace("\\", "/", $ownDir); +require_once ($ownDir.'../include/config.php'); global $config; - require_once ($config["homedir"]."/include/functions.php"); require_once ($config["homedir"]."/include/functions_db.php"); -require_once ($config["homedir"]."/enterprise/include/functions_reporting_csv.php"); +enterprise_include ($config["homedir"]."/enterprise/include/functions_reporting_csv.php"); require_once ($config["homedir"]."/include/auth/mysql.php"); error_reporting(E_ALL); diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index f3ac17c7c2..78a6da3621 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -82,14 +82,11 @@ foreach ($servers as $server) { } // Type - if ($server['type'] == 'data'){ - $data[2] = '<span style="white-space:nowrap;">'.$server["img"].'</span> (<span style="font-size:8px;">' . $server["version"]. '</span>)'; - } - else{ - $data[2] = '<span style="white-space:nowrap;">'.$server["img"].'</span> ('.ucfirst($server["type"]).")"; - } - if ($server["master"] == 1) - $data[2] .= ui_print_help_tip (__("This is a master server"), true); + $data[2] = '<span style="white-space:nowrap;">'.$server["img"]; + if ($server["master"] == 1){ + $data[2] .= ui_print_help_tip (__("This is a master server"), true); + } + $data[2] .= '</span> <span style="font-size:8px;"> v' . $server["version"]. '</span>'; switch ($server['type']) { case "snmp": diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 6e5e937da3..f25f422fec 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -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')); @@ -159,11 +160,13 @@ if ($get_module_detail) { "Data" => array( "data", "modules_format_data", - "align" => "left"), + "align" => "left", + "width" => 500), "Time" => array( "utimestamp", "modules_format_time", - "align" => "center") + "align" => "left", + "width" => 500) ); if ($selection_mode == "fromnow") { @@ -235,21 +238,21 @@ if ($get_module_detail) { $datos = "<span style='font-family: mono,monospace;'>" . $datos . "</span>"; // I dont why, but using index (value) method, data is automatically converted to html entities ¿? - $data[$attr[1]] = $datos; + $data[] = $datos; } elseif ($is_web_content_string) { //Fixed the goliat sends the strings from web //without HTML entities - $data[$attr[1]] = io_safe_input($row[$attr[0]]); + $data[] = io_safe_input($row[$attr[0]]); } else { // Just a string of alphanumerical data... just do print //Fixed the data from Selenium Plugin if ($row[$attr[0]] != strip_tags($row[$attr[0]])) - $data[$attr[1]] = io_safe_input($row[$attr[0]]); + $data[] = io_safe_input($row[$attr[0]]); else - $data[$attr[1]] = $row[$attr[0]]; + $data[] = $row[$attr[0]]; } } @@ -266,6 +269,9 @@ if ($get_module_detail) { html_print_table($table); } + if (defined ('METACONSOLE')) + metaconsole_restore_db(); + return; } diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 13639f97fa..46d1d1ef04 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -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')) { diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index d937a7d10e..982a5dd976 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -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(); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 7aac5a2a23..6191a1c1fa 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150129'; +$build_version = 'PC150202'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 720f567927..afaf619c50 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2230,9 +2230,14 @@ function print_audit_csv ($data) { header("Pragma: no-cache"); header("Expires: 0"); - echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n"; - foreach ($data as $line) { - echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; + if ($data){ + echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n"; + foreach ($data as $line) { + echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; + } + } + else{ + echo __('No data found to export'); } } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 22e1da590d..e6ce865e7b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2263,19 +2263,18 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) modules_get_status($module_id, $db_status, $module_value, $status, $title); $status_image = ui_print_status_image($status, $title, true); - $ip_target = ""; - if (isset($module['ip_target']) && !empty($module['ip_target'])) { - $ip_target = $module['ip_target']; - } + $ip_target = "--"; // Trying to get something like an IP from the description - else if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $module_description, $matches) + if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $module_description, $matches) || preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| - (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", $module_description, $matches)) { - if ($matches[0]) { - $ip_target = $matches[0]; - } + (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", $module_description, $matches) && $matches[0]) { + + $ip_target = $matches[0]; } - $mac = ""; + // else if (isset($module['ip_target']) && !empty($module['ip_target'])) { + // $ip_target = $module['ip_target']; + // } + $mac = "--"; // Trying to get something like a mac from the description if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i", $module_description, $matches)) { if ($matches[0]) { diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 98cb2224d8..bd1f69a121 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -1417,7 +1417,7 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c $group_ids = implode(',', $childrens_ids); } $sql = "SELECT id_usuario FROM tusuario_perfil - WHERE id_usuario = '".$config["id_user"]."' AND tags = $tags_user + WHERE id_usuario = '".$config["id_user"]."' AND tags = '$tags_user' AND id_perfil IN (SELECT id_perfil FROM tperfil WHERE ".get_acl_column($access)."=1) AND id_grupo IN ($group_ids)"; $has_perm = db_get_value_sql ($sql); diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index bb41341d0d..3a46ad414f 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -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, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>"; else $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 - 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, '[…]') .'</td></tr>'; + $row = array(); + $row['title'] = __('Description'); + $row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]'); + $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 " "; - echo '('.$module['unit'].')'; + $last_data_str .= " "; + $last_data_str .= '('.$module['unit'].')'; } - echo " "; - html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px')); + $last_data_str .= " "; + $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; @@ -488,6 +521,58 @@ function treeview_printTable($id_agente, $server_data = array()) { $events_graph .= '</div><br>'; ui_toggle($events_graph, __('Events (24h)')); + + // Table network interfaces + $network_interfaces_by_agents = agents_get_network_interfaces(array($agent)); + + $network_interfaces = array(); + if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) { + $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces']; + } + + if (!empty($network_interfaces)) { + $table = new stdClass(); + $table->id = 'agent_interface_info'; + $table->class = 'databox'; + $table->width = '100%'; + $table->style = array(); + $table->style['interface_status'] = 'width: 30px;'; + $table->style['interface_graph'] = 'width: 20px;'; + $table->head = array(); + $table->data = array(); + + foreach ($network_interfaces as $interface_name => $interface) { + if (!empty($interface['traffic'])) { + $params = array( + 'interface_name' => $interface_name, + 'agent_id' => $id_agente, + 'traffic_module_in' => $interface['traffic']['in'], + 'traffic_module_out' => $interface['traffic']['out'] + ); + $params_json = json_encode($params); + $params_encoded = base64_encode($params_json); + $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); + $graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" . + html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>"; + } + else { + $graph_link = ""; + } + + $data = array(); + $data['interface_name'] = "<strong>" . $interface_name . "</strong>"; + $data['interface_status'] = $interface['status_image']; + $data['interface_graph'] = $graph_link; + $data['interface_ip'] = $interface['ip']; + $data['interface_mac'] = $interface['mac']; + $table->data[] = $data; + } + //End of table network interfaces + $table_interfaces = html_print_table($table, true); + $table_interfaces .= "<br>"; + + ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)'); + } return; } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 49321db16d..552a017b3f 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -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,36 @@ 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); - } + // Add again the hover event to the 'force_callback' elements + forced_title_callback(); + + controller.open(); }, error: function(xhr, textStatus, errorThrown) { $label.addClass('tree-element-detail-error'); @@ -726,16 +769,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 +785,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 +829,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 +873,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); } } } diff --git a/pandora_console/include/styles/tree.css b/pandora_console/include/styles/tree.css index 2db5b7ae26..e9eb0863bc 100644 --- a/pandora_console/include/styles/tree.css +++ b/pandora_console/include/styles/tree.css @@ -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; -} \ No newline at end of file +} + +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;*/ +} diff --git a/pandora_console/install.php b/pandora_console/install.php index 17b5c7d06f..0048b1c1aa 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@ <div style='height: 10px'> <?php $version = '6.0dev'; -$build = '150129'; +$build = '150202'; $banner = "v$version Build $build"; error_reporting(0); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 5d2b9a82dd..6cdea6fa22 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -385,143 +385,59 @@ if ($last_incident != false) { // START: TABLE INTERFACES -$columns = array( - "id_agente_modulo", - "nombre", - "descripcion", - "ip_target" - ); -$filter = array( - "id_agente" => $id_agente, - "id_tipo_modulo" => (int)db_get_value("id_tipo", "ttipo_modulo", "nombre", "remote_snmp_proc"), - "disabled" => 0 - ); -$modules = agents_get_modules($id_agente, $columns, $filter, true, false); -$interfaces = array(); +$network_interfaces_by_agents = agents_get_network_interfaces(array($agent)); -if (!empty($modules)) { - foreach ($modules as $key => $module) { - // Trying to get the interface name from the module name - if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) { - if ($matches[1]) { - $interface_name = $matches[1]; - $interface_name_escaped = str_replace("/", "\/", $interface_name); - - if (!isset($interfaces[$interface_name]) - || (isset($interfaces[$interface_name]) - && preg_match ("/^ifOperStatus_$interface_name_escaped$/i", (string)$module['nombre'], $matches))) { - $interfaces[$interface_name] = $module; - } - - } - } - } - unset($modules); +$network_interfaces = array(); +if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) { + $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces']; +} + +if (!empty($network_interfaces)) { + $table_interface = new stdClass(); + $table_interface->id = 'agent_interface_info'; + $table_interface->class = 'databox'; + $table_interface->width = '100%'; + $table_interface->style = array(); + $table_interface->style['interface_status'] = 'width: 30px;'; + $table_interface->style['interface_graph'] = 'width: 20px;'; + $table_interface->head = array(); + $options = array( + "class" => "closed", + "style" => "vertical-align:middle; cursor:pointer;"); + $table_interface->head[0] = html_print_image("images/go.png", true, $options) . " "; + $table_interface->head[0] .= '<span style="vertical-align: middle;">' . __('Interface information') .' (SNMP)</span>'; + $table_interface->head_colspan = array(); + $table_interface->head_colspan[0] = 5; + $table_interface->data = array(); - if (!empty($interfaces)) { - - $table_interface = new stdClass(); - $table_interface->id = 'agent_interface_info'; - $table_interface->class = 'databox'; - $table_interface->width = '100%'; - $table_interface->style = array(); - $table_interface->style['interface_status'] = 'width: 30px;'; - $table_interface->style['interface_graph'] = 'width: 20px;'; - $table_interface->head = array(); - $options = array( - "class" => "closed", - "style" => "vertical-align:middle; cursor:pointer;"); - $table_interface->head[0] = html_print_image("images/go.png", true, $options) . " "; - $table_interface->head[0] .= '<span style="vertical-align: middle;">' . __('Interface information') .' (SNMP)</span>'; - $table_interface->head_colspan = array(); - $table_interface->head_colspan[0] = 5; - $table_interface->data = array(); - - foreach ($interfaces as $interface_name => $module) { - $interface_name_escaped = str_replace("/", "\/", $interface_name); - - $module_id = $module['id_agente_modulo']; - $db_status = modules_get_agentmodule_status($module_id); - $module_value = modules_get_last_value ($module_id); - modules_get_status($module_id, $db_status, $module_value, $status, $title); - $status = ui_print_status_image($status, $title, true); - - $ip_target = "--"; - // Trying to get something like an IP from the description - if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) || - preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| - (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", (string)$module['descripcion'], $matches)) { - if ($matches[0]) { - $ip_target = $matches[0]; - } - } - $mac = "--"; - // Trying to get something like a mac from the description - if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i", (string)$module['descripcion'], $matches)) { - if ($matches[0]) { - $mac = $matches[0]; - } - } - - // Get the ifInOctets and ifOutOctets modules of the interface - $columns = array( - "id_agente_modulo", - "nombre" - ); - $interface_traffic_modules = agents_get_modules($id_agente, $columns, "nombre LIKE 'if%Octets_$interface_name'"); - if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) { - $interface_traffic_modules_aux = array('in' => '', 'out' => ''); - foreach ($interface_traffic_modules as $interface_traffic_module) { - $interface_name_escaped = str_replace("/", "\/", $interface_name); - if (preg_match ("/^if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) { - if (strtolower($matches[1]) == 'in') { - $interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo']; - } - elseif (strtolower($matches[1]) == 'out') { - $interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo']; - } - } - } - if (!empty($interface_traffic_modules_aux['in']) && !empty($interface_traffic_modules_aux['out'])) { - $interface_traffic_modules = $interface_traffic_modules_aux; - } - else { - $interface_traffic_modules = false; - } - } - else { - $interface_traffic_modules = false; - } - - if ($interface_traffic_modules != false) { - $params = array( - 'interface_name' => $interface_name, - 'agent_id' => $id_agente, - 'traffic_module_in' => $interface_traffic_modules_aux['in'], - 'traffic_module_out' => $interface_traffic_modules_aux['out'] - ); - $params_json = json_encode($params); - $params_encoded = base64_encode($params_json); - $win_handle = dechex(crc32($module_id.$interface_name)); - $graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" . - html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>"; - } - else { - $graph_link = ""; - } - - $data = array(); - $data['interface_name'] = "<strong>" . $interface_name . "</strong>"; - $data['interface_status'] = $status; - $data['interface_graph'] = $graph_link; - $data['interface_ip'] = $ip_target; - $data['interface_mac'] = $mac; - $table_interface->data[] = $data; + foreach ($network_interfaces as $interface_name => $interface) { + if (!empty($interface['traffic'])) { + $params = array( + 'interface_name' => $interface_name, + 'agent_id' => $id_agente, + 'traffic_module_in' => $interface['traffic']['in'], + 'traffic_module_out' => $interface['traffic']['out'] + ); + $params_json = json_encode($params); + $params_encoded = base64_encode($params_json); + $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); + $graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" . + html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>"; } + else { + $graph_link = ""; + } + + $data = array(); + $data['interface_name'] = "<strong>" . $interface_name . "</strong>"; + $data['interface_status'] = $interface['status_image']; + $data['interface_graph'] = $graph_link; + $data['interface_ip'] = $interface['ip']; + $data['interface_mac'] = $interface['mac']; + $table_interface->data[] = $data; } - // This javascript piece of code is used to make expandible the body of the table - ?> +?> <script type="text/javascript"> $(document).ready (function () { $("#agent_interface_info").find("tbody").hide(); @@ -540,7 +456,7 @@ if (!empty($modules)) { .css('cursor', 'pointer'); }); </script> - <?php +<?php } // END: TABLE INTERFACES diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index e33366f9c0..0c88c4a1c6 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -66,7 +66,7 @@ switch ($status) { } if ($search != "") { - $sql_post .= " AND (evento LIKE '%" . io_safe_input($search) . "%' OR id_evento LIKE '%$search%')"; + $sql_post .= ' AND (evento LIKE "%'. io_safe_input($search) . '%"'. ' OR id_evento LIKE "%$search%")'; } if ($event_type != "") { diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index cb781137e8..738d26df05 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -14,900 +14,331 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - - -require_once("tree2.php"); -return; -//////////////////////////////////////////////////////////////////////// - - -define('ALL', -1); -define('NORMAL', 0); -define('WARNING', 2); -define('CRITICAL', 1); -define('UNKNOWN', 3); -define('NOT_INIT', 5); - - global $config; -require_once ($config['homedir'] . '/include/functions_treeview.php'); - -if (defined ('METACONSOLE')) { - // For each server defined: - $servers = db_get_all_rows_sql ("SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0"); - if ($servers === false) { - $servers = array(); - } -} - -if (is_ajax ()) { - require_once ($config['homedir'] . '/include/functions_reporting.php'); - require_once ($config['homedir'] . '/include/functions_users.php'); - require_once ($config['homedir'] . '/include/functions_servers.php'); - - global $config; - - $enterpriseEnable = false; - if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { - $enterpriseEnable = true; - require_once ('enterprise/include/functions_policies.php'); - require_once ('enterprise/meta/include/functions_ui_meta.php'); - } - - $type = get_parameter('type'); - $id = get_parameter('id'); - $id_father = get_parameter('id_father'); - $statusSel = get_parameter('status'); - $search_free = get_parameter('search_free', ''); - $printTable = get_parameter('printTable', 0); - $printAlertsTable = get_parameter('printAlertsTable', 0); - $printModuleTable = get_parameter('printModuleTable', 0); - $server_name = get_parameter('server_name', ''); - $server = array(); - if ($printTable) { - $id_agente = get_parameter('id_agente'); - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printTable($id_agente, $server); - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - if ($printAlertsTable) { - $id_module = get_parameter('id_module'); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printAlertsTable($id_module, $server); - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - if ($printModuleTable) { - $id_module = get_parameter('id_module'); - $id_agent = get_parameter('id_agent'); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printModuleTable($id_module, $server); - - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - - /* - * It's a binary for branch (0 show - 1 hide) - * and there are 2 position - * 0 0 - show 2 branch - * 0 1 - hide the 2º branch - * 1 0 - hide the 1º branch - * 1 1 - hide 2 branch - */ - $lessBranchs = get_parameter('less_branchs'); - - switch ($type) { - case 'group': - case 'os': - case 'module_group': - case 'policies': - case 'module': - case 'tag': - - $countRows = 0; - if (! defined ('METACONSOLE')) { - $avariableGroups = users_get_groups(); - $avariableGroupsIds = array_keys($avariableGroups); - $sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free); - - if ($sql === false) { - $rows = array (); - } - else { - $rows = db_get_all_rows_sql($sql); - } - } - else { - $rows = array (); - foreach ($servers as $server) { - if (metaconsole_connect($server) != NOERR) { - continue; - } - $avariableGroups = users_get_groups(); - $avariableGroupsIds = array_keys($avariableGroups); - $sql = treeview_getFirstBranchSQL ($type, $id, - $avariableGroupsIds, $statusSel, $search_free); - if ($sql === false) { - $server_rows = array (); - } - else { - $server_rows = db_get_all_rows_sql($sql); - if ($server_rows === false) { - $server_rows = array (); - } - } - // Add the server name - foreach ($server_rows as $key => $row) { - $server_rows[$key]['server_name'] = $server['server_name']; - } - $rows = array_merge($rows, $server_rows); - } - metaconsole_restore_db(); - } - $countRows = count ($rows); - - //Empty Branch - if ($countRows === 0) { - echo "<ul style='margin: 0; padding: 0;'>\n"; - echo "<li style='margin: 0; padding: 0;'>"; - if ($lessBranchs == 1) - echo html_print_image ("operation/tree/no_branch.png", true, array ("style" => 'vertical-align: middle;')); - else - echo html_print_image ("operation/tree/branch.png", true, array ("style" => 'vertical-align: middle;')); - echo "<i>" . __("Empty") . "</i>"; - echo "</li>"; - echo "</ul>"; - return; - } - - //Branch with items - $count = 0; - echo "<ul style='margin: 0; padding: 0;'>\n"; - - foreach ($rows as $row) { - $count++; - - $agent_info["monitor_alertsfired"] = $row["fired_count"]; - $agent_info["monitor_critical"] = $row["critical_count"]; - $agent_info["monitor_warning"] = $row["warning_count"]; - $agent_info["monitor_unknown"] = $row["unknown_count"]; - $agent_info["monitor_normal"] = $row["normal_count"]; - $agent_info["monitor_notinit"] = $row["notinit_count"]; - $agent_info["modules"] = $row["total_count"]; - - $agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]); - $agent_info["status_img"] = agents_tree_view_status_img( - $agent_info["monitor_critical"], - $agent_info["monitor_warning"], - $agent_info["monitor_unknown"], - $agent_info["modules"], - $agent_info["monitor_notinit"]); - - // Filter by status (only in policy view) - if ($type == 'policies') { - - if ($statusSel == NORMAL) { - if (strpos($agent_info["status_img"], 'ok') === false) - continue; - } - else if ($statusSel == WARNING) { - if (strpos($agent_info["status_img"], 'warning') === false) - continue; - } - else if ($statusSel == CRITICAL) { - if (strpos($agent_info["status_img"], 'critical') === false) - continue; - } - else if ($statusSel == UNKNOWN) { - if (strpos($agent_info["status_img"], 'down') === false) - continue; - } - } - - $less = $lessBranchs; - $tree_img_id = "tree_image" . $id . "_agent_" . $type . "_" . $row["server_name"] . "_" . $row["id_agente"]; - if ($count != $countRows) - $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "2")); - else { - $less = $less + 2; // $less = $less or 0b10 - $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "3")); - } - echo "<li style='margin: 0; padding: 0;'>"; - echo "<a onfocus='JavaScript: this.blur()' - href='javascript: loadSubTree(\"agent_" . $type . "\"," . $row["id_agente"] . ", " . $less . ", \"" . $id . "\", \"" . $row["server_name"] . "\")'>"; - - if ($lessBranchs == 1) - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - else - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - - echo $img; - echo "</a>"; - echo " "; - echo str_replace('.png' ,'_ball.png', - str_replace('img', 'img style="vertical-align: middle;"', $agent_info["status_img"]) - ); - echo " "; - echo str_replace('.png' ,'_ball.png', - str_replace('img', 'img style="vertical-align: middle;"', $agent_info["alert_img"]) - ); - echo "<a onfocus='JavaScript: this.blur()' - href='javascript: loadTable(\"agent_" . $type . "\"," . $row["id_agente"] . ", " . $less . ", \"" . $id . "\", \"" . $row['server_name'] . "\")'>"; - echo " "; - - echo ui_print_truncate_text($row["nombre"], 40, true); - - echo " (" . reporting_tiny_stats($row, true) . ")"; - - if ($row['quiet']) { - echo " "; - html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); - } - echo "</a>"; - echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div" . $id . "_agent_" . $type . "_" . $row["server_name"] . "_" . $row["id_agente"] . "'></div>"; - echo "</li>"; - } - - echo "</ul>\n"; - break; - - //also aknolegment as second subtree/branch - case 'agent_group': - case 'agent_module_group': - case 'agent_os': - case 'agent_policies': - case 'agent_module': - case 'agent_tag': - $fatherType = str_replace('agent_', '', $type); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - if (metaconsole_connect($server) != NOERR) { - continue; - } - } - - $sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father); - $rows = db_get_all_rows_sql($sql); - if (empty($rows)) { - $rows = array(); - } - $countRows = count ($rows); - - if ($countRows === 0) { - echo "<ul style='margin: 0; padding: 0;'>\n"; - echo "<li style='margin: 0; padding: 0;'>"; - switch ($lessBranchs) { - case 0: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 1: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 2: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 3: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - } - echo "<i>" . __("Empty") . "</i>"; - echo "</li>"; - echo "</ul>"; - return; - } - - $count = 0; - echo "<ul style='margin: 0; padding: 0;'>\n"; - foreach ($rows as $row) { - $count++; - echo "<li style='margin: 0; padding: 0;'><span style='min-width: 300px; display: inline-block;'>"; - - switch ($lessBranchs) { - case 0: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 1: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 2: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 3: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - } - - if ($countRows != $count) - html_print_image ("operation/tree/leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "1" )); - else - html_print_image ("operation/tree/last_leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "2" )); - - // Assign image and status depend on the status data - switch ($row["estado"]) { - case AGENT_MODULE_STATUS_NO_DATA: - case AGENT_MODULE_STATUS_UNKNOWN: - $status = STATUS_MODULE_NO_DATA; - $title = __('UNKNOWN'); - break; - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $status = STATUS_MODULE_CRITICAL; - $title = __('CRITICAL'); - break; - case AGENT_MODULE_STATUS_WARNING: - $status = STATUS_MODULE_WARNING; - $title = __('WARNING'); - break; - default: - $status = STATUS_MODULE_OK; - $title = __('NORMAL'); - break; - } - - if (is_numeric($row["datos"])) { - $title .= " : " . format_for_graph($row["datos"]); - } - else { - $title .= " : " . substr(io_safe_output($row["datos"]),0,42); - } - - echo str_replace('.png' ,'_ball.png', - str_replace('img', 'img style="vertical-align: middle;"', ui_print_status_image($status, $title,true)) - ); - echo " "; - echo str_replace('img', 'img style="vertical-align: middle;"', servers_show_type ($row['id_modulo'])); - echo " "; - $graph_type = return_graphtype ($row["id_tipo_modulo"]); - $win_handle=dechex(crc32($row["id_agente_modulo"] . $row["nombre"])); - - if (defined ('METACONSOLE')) { - $console_url = $server['server_url'] . '/'; - } - else { - $console_url = ''; - } - - - //Icon and link to the Module graph. - if (defined('METACONSOLE')) { - $url_module_graph = ui_meta_get_url_console_child( - $server, null, null, null, null, - "operation/agentes/stat_win.php?" . - "type=$graph_type&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"] . "&" . - "label=" . rawurlencode(urlencode(base64_encode($row["nombre"]))) . "&" . - "refresh=600"); - } - else { - $url_module_graph = $console_url . - "operation/agentes/stat_win.php?" . - "type=$graph_type&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"] . "&" . - "label=" . rawurlencode(urlencode(base64_encode($row["nombre"]))) . "&" . - "refresh=600"; - } - $link ="winopeng('" . $url_module_graph . "','day_".$win_handle."')"; - echo '<a href="javascript: '.$link.'">' . html_print_image ("images/chart_curve.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . '</a>'; - - - echo " "; - - - //Icon and link to the Module data. - if (defined('METACONSOLE')) { - - $url_module_data = ui_meta_get_url_console_child( - $server, - "estado", "operation/agentes/ver_agente", - "id_agente=" . $row['id_agente'] . "&" . - "tab=data_view&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"]); - } - else { - $url_module_data = $console_url . - "index.php?" . - "sec=estado&" . - "sec2=operation/agentes/ver_agente&" . - "id_agente=" . $row['id_agente'] . "&" . - "tab=data_view&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"]; - } - echo "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agente'].", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>"; - - echo " "; - - $nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"])); - - if($nmodule_alerts > 0) { - echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadAlertsTable(" . $row["id_agente_modulo"] . ", \"" . $server_name . "\")'>"; - echo html_print_image ("images/bell.png", true, array ("style" => 'vertical-align: middle;', "border" => "0", "title" => __('Module alerts') )); - echo "</a>"; - - echo " "; - } - - echo "<a style='vertical-align: middle;' onfocus='JavaScript: this.blur()' href='javascript: loadModuleTable(" . $row["id_agente_modulo"] . ", \"" . $server_name . "\"". "," . $id.")'>"; - echo ui_print_truncate_text(io_safe_output($row['nombre']), 40, true); - echo "</a>"; - if ($row['quiet']) { - echo " "; - html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); - } - - /* - if (is_numeric($row["datos"])) - $data = format_numeric($row["datos"]); - else - $data = "<span title='".$row['datos']."' style='white-space: nowrap;'>".substr(io_safe_output($row["datos"]),0,12)."</span>"; - - echo "</span><span style='margin-left: 20px;'>"; - if ($row['utimestamp'] != '') { - ui_print_help_tip ($row["timestamp"], '', 'images/clock2.png'); - echo " "; - } - echo $data; - if ($row['unit'] != '') { - echo " "; - echo '('.$row['unit'].')'; - } - * */ - echo "</span></li>"; - } - echo "</ul>\n"; - if (defined ('METACONSOLE')) { - metaconsole_restore_db_force(); - } - break; - } - - return; -} -//End of AJAX code. - -include_once($config['homedir'] . "/include/functions_groups.php"); -include_once($config['homedir'] . "/include/functions_os.php"); -include_once($config['homedir'] . "/include/functions_modules.php"); -include_once($config['homedir'] . "/include/functions_servers.php"); -include_once($config['homedir'] . "/include/functions_reporting.php"); -include_once($config['homedir'] . "/include/functions_ui.php"); - -global $config; $pure = get_parameter('pure', 0); +$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); +$strict_acl = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); + +// ---------------------Tabs ------------------------------------------- $enterpriseEnable = false; if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { $enterpriseEnable = true; } -///////// INI MENU AND TABS ///////////// -$img_style = array ("class" => "top", "width" => 16); -$activeTab = get_parameter('sort_by','group'); +$url = 'index.php?' . + 'sec=estado&' . + 'sec2=operation/tree&' . + 'refr=0&' . + 'pure='.$pure.'&' . + 'tab=%s'; -$os_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=os&pure=$pure'>" - . html_print_image ("images/operating_system.png", true, array ("title" => __('OS'))) . "</a>", 'active' => $activeTab == "os"); +$tabs = array(); -$group_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=group&pure=$pure'>" - . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>", 'active' => $activeTab == "group"); +if (!$strict_acl) { + $tabs['tag'] = array( + 'text' => "<a href='" . sprintf($url, "tag") . "'>" . + html_print_image("images/tag.png", true, + array("title" => __('Tags'))) . "</a>", + 'active' => ($tab == "tag")); -$module_group_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=module_group&pure=$pure'>" - . html_print_image ("images/module_group.png", true, array ("title" => __('Module groups'))) . "</a>", 'active' => $activeTab == "module_group"); + $tabs['os'] = array( + 'text' => "<a href='" . sprintf($url, "os") . "'>" . + html_print_image("images/operating_system.png", true, + array("title" => __('OS'))) . "</a>", + 'active' => ($tab == "os")); -if ($enterpriseEnable) { - $policies_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=policies&pure=$pure'>" - . html_print_image ("images/policies_mc.png", true, array ("title" => __('Policies'))) . "</a>", 'active' => $activeTab == "policies"); -} -else { - $policies_tab = ''; + $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")); + + 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")); + } } -$module_tab = array('text' => "<a href='index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by=module&pure=$pure'>" - . html_print_image("images/brick.png", - true, - array("title" => __('Modules'))) . "</a>", - 'active' => $activeTab == "module"); - -$tags_tab = array('text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&sort_by=tag&pure=$pure'>" - . html_print_image("images/tag.png", - true, - array("title" => __('Tags'))) . "</a>", - 'active' => $activeTab == "tag"); - -switch ($activeTab) { - case 'group': - $order = __('groups'); - break; - case 'module_group': - $order = __('module groups'); - break; - case 'policies': - $order = __('policies'); - break; - case 'module': - $order = __('modules'); +$header_title = __('Tree view'); +$header_sub_title = __('Sort the agents by %s'); +switch ($tab) { + case 'tag': + $header_sub_title = sprintf($header_sub_title, __('tags')); break; case 'os': - $order = __('OS'); + $header_sub_title = sprintf($header_sub_title, __('OS')); break; - case 'tag': - $order = __('tags'); + case 'group': + $header_sub_title = sprintf($header_sub_title, __('groups')); + break; + case 'module_group': + $header_sub_title = sprintf($header_sub_title, __('module groups')); + break; + case 'module': + $header_sub_title = sprintf($header_sub_title, __('modules')); + break; + case 'policies': + if ($enterpriseEnable) + $header_sub_title = sprintf($header_sub_title, __('policies')); break; } +if (defined('METACONSOLE')) { + if ($strict_acl) + $header_sub_title = ''; + + ui_meta_print_header($header_title, $header_sub_title, $tabs); +} +else{ + if (!$strict_acl) + $header_title = $header_title ." - ". $header_sub_title; + + ui_print_page_header($header_title, "images/extensions.png", false, "", false, $tabs); +} +// ---------------------Tabs ------------------------------------------- + + if (! defined ('METACONSOLE')) { - $onheader = array('tag' => $tags_tab, - 'os' => $os_tab, - 'group' => $group_tab, - 'module_group' => $module_group_tab, - 'policies' => $policies_tab, - 'module' => $module_tab); - - ui_print_page_header( - __('Tree view') . " - " . __('Sort the agents by ') . $order, - "images/extensions.png", - false, "", false, $onheader); + } else { - - ui_meta_add_breadcrumb(array( - 'link' => 'index.php?sec=monitoring&sec2=operation/tree', - 'text' => __('Tree View'))); - ui_meta_print_page_header($nav_bar); - - $img_style = array ("class" => "top", "width" => 16); - $activeTab = get_parameter('tab','group'); - // Check if the loaded tab is allowed or not - $allowed_tabs = array('group'); + // $allowed_tabs = array('group'); - if ($config['enable_tags_tree']) { - $allowed_tabs[] = 'tag'; - } + // if ($config['enable_tags_tree']) { + // $allowed_tabs[] = 'tag'; + // } - if (!in_array($activeTab, $allowed_tabs)) { - db_pandora_audit("HACK Attempt", - "Trying to access to not allowed tab on tree view"); - include ("general/noaccess.php"); + // if (!in_array($activeTab, $allowed_tabs)) { + // db_pandora_audit("HACK Attempt", + // "Trying to access to not allowed tab on tree view"); + // include ("general/noaccess.php"); - exit; - } + // exit; + // } // End of tab check - - $group_tab = array('text' => "<a href='index.php?sec=monitoring&sec2=operation/tree&refr=0&tab=group&pure=$pure'>" - . html_print_image ("images/group.png", true, - array ("title" => __('Groups'))) . "</a>", - 'active' => $activeTab == "group"); - - $subsections['group'] = $group_tab; - - if ($config['enable_tags_tree']) { - $tags_tab = array( - 'text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" . - html_print_image ("images/tag.png", true, - array ("title" => __('Tags'))) . "</a>", - 'active' => $activeTab == "tag"); - - $subsections['tag'] = $tags_tab; - } - - switch ($activeTab) { - case 'group': - $subsection = __('Groups'); - $tab = 'group'; - break; - case 'tag': - $subsection = __('Tags'); - $tab = 'tag'; - break; - } - ui_meta_print_header(__("Tree view"), $subsection, $subsections); } +// --------------------- form filter ----------------------------------- + +$table = new StdClass(); +$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; + enterprise_hook('open_meta_frame'); -if (tags_has_user_acl_tags()) { - ui_print_tags_warning(); +if (!$strict_acl) { + 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>'; } - -echo "<br>"; -if (! defined ('METACONSOLE')) { - echo '<form id="tree_search" method="post" action="index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by='.$activeTab.'&pure='.$pure.'">'; -} -else { - echo '<form id="tree_search" method="post" action="index.php?sec=monitoring&sec2=operation/tree&refr=0&tab='.$activeTab.'&pure='.$pure.'">'; -} - -echo "<b>" . __('Agent status') . "</b>"; - -$search_free = get_parameter('search_free', ''); -$select_status = get_parameter('status', -1); - -$fields = array (); -$fields[ALL] = __('All'); //default -$fields[NORMAL] = __('Normal'); -$fields[WARNING] = __('Warning'); -$fields[CRITICAL] = __('Critical'); -$fields[UNKNOWN] = __('Unknown'); -$fields[NOT_INIT] = __('Not init'); - -html_print_select ($fields, "status", $select_status); - -echo " "; -echo "<b>" . __('Search agent') . "</b>"; -echo " "; -html_print_input_text ("search_free", $search_free, '', 40,30, false); -echo " "; -html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); -echo "</form>"; -echo "<div class='pepito' id='a'></div>"; -echo "<div class='pepito' id='b'></div>"; -echo "<div class='pepito' id='c'></div>"; -///////// END MENU AND TABS ///////////// - -echo "<div id='module_details_window'></div>"; -ui_require_javascript_file('pandora_modules'); - -treeview_printTree($activeTab); - - -enterprise_hook('close_meta_frame'); +// --------------------- 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 class='tree-table'>"; +echo "<div class='tree-table-row'>"; +echo "<div class='tree-table-cell tree-table-cell-tree'>"; +echo "<div id='tree-controller-recipient'>"; +echo "</div>"; +echo "</div>"; +echo "<div class='tree-table-cell tree-table-cell-detail'>"; +echo "<div id='tree-controller-detail-recipient'>"; +echo "</div>"; +echo "</div>"; +echo "</div>"; +echo "</div>"; + +enterprise_hook('close_meta_frame'); + ?> -<script language="javascript" type="text/javascript"> +<script type="text/javascript"> + var treeController = TreeController.getController(); - var status = $('#status').val(); - var search_free = $('#text-search_free').val(); + processTreeSearch(); - /** - * loadSubTree asincronous load ajax the agents or modules (pass type, id to search and binary structure of branch), - * change the [+] or [-] image (with same more or less div id) of tree and anime (for show or hide) - * the div with id "div[id_father]_[type]_[div_id]" - * - * type string use in js and ajax php - * div_id int use in js and ajax php - * less_branchs int use in ajax php as binary structure 0b00, 0b01, 0b10 and 0b11 - * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one - */ - function loadSubTree(type, div_id, less_branchs, id_father, server_name) { - var id = id_father + '_' + type + '_' + server_name.replace('.','\\.') + '_' + div_id; - var hiddenDiv = $('#tree_div' + id).attr('hiddenDiv'); - var loadDiv = $('#tree_div' + id).attr('loadDiv'); + $("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 pos = parseInt($('#tree_image' + id).attr('pos_tree')); - - //If has yet ajax request running - if (loadDiv == 2) - return; - - if (loadDiv == 0) { - - //Put an spinner to simulate loading process - $('#tree_div' + id) - .html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>"); - $('#tree_div' + id) - .show('normal'); - - $('#tree_div'+id).attr('loadDiv', 2); - $.ajax({ - type: "POST", - url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, - data: { - "page": "operation/tree", - "ajax_treeview": 1, - "type": type, - "id": div_id, - "less_branchs": less_branchs, - "id_father": id_father, - "status": status, - "search_free": search_free, - "server_name": server_name - }, - success: function(msg) { - if (msg.length != 0) { - $('#tree_div'+id).hide(); - $('#tree_div'+id).html(msg); - $('#tree_div'+id).show('normal'); - - //change image of tree [+] to [-] - <?php if (! defined ('METACONSOLE')) { - echo 'var icon_path = \'operation/tree\';'; - } - else { - echo 'var icon_path = \'../../operation/tree\';'; - } - ?> - switch (pos) { - case 0: - $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png'); - break; - case 1: - $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png'); - break; - case 2: - $('#tree_image'+id).attr('src',icon_path+'/expanded.png'); - break; - case 3: - $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png'); - break; - } - $('#tree_div'+id).attr('hiddendiv',0); - $('#tree_div'+id).attr('loadDiv', 1); - } - - // Refresh forced title callback to work with html code created dinamicly - forced_title_callback(); - } - }); - } - else { - <?php - if (! defined ('METACONSOLE')) { - echo 'var icon_path = \'operation/tree\';'; - } - else { - echo 'var icon_path = \'../../operation/tree\';'; - } - ?> - if (hiddenDiv == 0) { - $('#tree_div'+id).hide('normal'); - $('#tree_div'+id).attr('hiddenDiv',1); - - //change image of tree [-] to [+] - switch (pos) { - case 0: - $('#tree_image'+id).attr('src',icon_path+'/first_closed.png'); - break; - case 1: - $('#tree_image'+id).attr('src',icon_path+'/one_closed.png'); - break; - case 2: - $('#tree_image'+id).attr('src',icon_path+'/closed.png'); - break; - case 3: - $('#tree_image'+id).attr('src',icon_path+'/last_closed.png'); - break; - } - } - else { - //change image of tree [+] to [-] - switch (pos) { - case 0: - $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png'); - break; - case 1: - $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png'); - break; - case 2: - $('#tree_image'+id).attr('src',icon_path+'/expanded.png'); - break; - case 3: - $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png'); - break; - } - - $('#tree_div'+id).show('normal'); - $('#tree_div'+id).attr('hiddenDiv',0); - } - } - } - - function changeStatus(newStatus) { - status = newStatus; - - //reset all subtree - $(".tree_view").each( - function(i) { - $(this).attr('loadDiv', 0); - $(this).attr('hiddenDiv',1); - $(this).hide(); - } - ); - - //clean all subtree - $(".tree_view").each( - function(i) { - $(this).html(''); - } - ); - } - - function loadTable(type, div_id, less_branchs, id_father, server_name) { - id_agent = div_id; - $.ajax({ - type: "POST", - url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, - data: "page=<?php echo $_GET['sec2']; ?>&printTable=1&id_agente=" + id_agent + "&server_name=" + server_name, - success: function(data) { - $('#cont').html(data); - forced_title_callback(); - } - }); - - loadSubTree(type, div_id, less_branchs, id_father, server_name); - } - - function loadAlertsTable(id_module, server_name) { - $.ajax({ - type: "POST", - url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, - data: "page=<?php echo $_GET['sec2']; ?>&printAlertsTable=1&id_module=" + id_module + "&server_name=" + server_name, - success: function(data) { - $('#cont').html(data); - forced_title_callback(); - } - }); - } - - function loadModuleTable(id_module, server_name, id_agent) { - $.ajax({ - type: "POST", - url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, - data: "page=<?php echo $_GET['sec2']; ?>&printModuleTable=1&id_module=" + id_module + "&server_name=" + server_name +"&id_agent="+id_agent, - success: function(data) { - $('#cont').html(data); - forced_title_callback(); - } - }); - } - - // Show the modal window of an module - function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) { - var extra_parameters = ''; - if (period == -1) { - period = $('#period').val(); - var selection_mode = $('input[name=selection_mode]:checked').val(); - var date_from = $('#text-date_from').val(); - var time_from = $('#text-time_from').val(); - var date_to = $('#text-date_to').val(); - var time_to = $('#text-time_to').val(); - - extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to; - } + 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: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period + extra_parameters, + 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: parameters['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'); ?>" + }, + alerts: { + 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 () @@ -925,7 +356,7 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri height: 500 }) .show (); - refresh_pagination_callback (module_id, id_agent, server_name); + refresh_pagination_callback(module_id, id_agent, server_name); datetime_picker_callback(); forced_title_callback(); } @@ -944,11 +375,10 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri 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; ?>"}); - $.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]); } - datetime_picker_callback(); function refresh_pagination_callback (module_id, id_agent, server_name) { @@ -966,4 +396,5 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri return false; }); } + </script> diff --git a/pandora_console/operation/tree2.php b/pandora_console/operation/tree2.php deleted file mode 100644 index 58056ce40c..0000000000 --- a/pandora_console/operation/tree2.php +++ /dev/null @@ -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> \ No newline at end of file diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 8dade6f405..a253f289c5 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150129 +%define release 150202 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 7b2804add2..46a438c5e5 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150129 +%define release 150202 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 4fc554d264..17ef26d345 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('graph_res','5'), ('step_compact','1'), ('db_scheme_version','6.0dev'), -('db_scheme_build','PD150129'), +('db_scheme_build','PD150202'), ('show_unknown','0'), ('show_lastalerts','1'), ('style','pandora'), diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 28afb3dfbd..1fb71a1a43 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 6.0dev-150129 +Version: 6.0dev-150202 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 0aa35e752f..db00032362 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150129" +pandora_version="6.0dev-150202" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index a0401ffcc2..f5e9d09940 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -43,7 +43,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "6.0dev"; -my $pandora_build = "150129"; +my $pandora_build = "150202"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index d3587caf2d..f3034a3e07 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2005,6 +2005,7 @@ sub pandora_update_server ($$$$$$;$$) { $queue_size = 0 unless defined ($queue_size); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime()); + my $version = $pa_config->{'version'} . ' (P) ' . $pa_config->{'build'}; # First run if ($server_id == 0) { @@ -2014,7 +2015,7 @@ sub pandora_update_server ($$$$$$;$$) { if (! defined ($server)) { $server_id = db_insert ($dbh, 'id_server', 'INSERT INTO tserver (name, server_type, description, version, threads, queued_modules) VALUES (?, ?, ?, ?, ?, ?)', $server_name, $server_type, - 'Autocreated at startup', $pa_config->{'version'} . ' (P) ' . $pa_config->{'build'}, $num_threads, $queue_size); + 'Autocreated at startup', $version, $num_threads, $queue_size); $server = get_db_single_row ($dbh, 'SELECT status FROM tserver WHERE id_server = ?', $server_id); if (! defined ($server)) { @@ -2023,15 +2024,14 @@ sub pandora_update_server ($$$$$$;$$) { } } - my $version = $pa_config->{'version'} . ' (P) ' . $pa_config->{'build'}; db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, laststart = ?, version = ?, threads = ?, queued_modules = ? WHERE id_server = ?', 1, $timestamp, $pa_config->{'pandora_master'}, $timestamp, $version, $num_threads, $queue_size, $server_id); return; } - db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, threads = ?, queued_modules = ? - WHERE id_server = ?', $status, $timestamp, $pa_config->{'pandora_master'}, $num_threads, $queue_size, $server_id); + db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, version = ?, threads = ?, queued_modules = ? + WHERE id_server = ?', $status, $timestamp, $pa_config->{'pandora_master'}, $version, $num_threads, $queue_size, $server_id); } ########################################################################## diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 2b503ee12c..0f5358c2b8 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150129 +%define release 150202 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 260e070116..2ea9b8f1e9 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150129 +%define release 150202 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 1bdc6ea639..d5e8b607ac 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "6.0dev PS150129"; +my $version = "6.0dev PS150202"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b2492ec568..3b421e2fd0 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -34,7 +34,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "6.0dev PS150129"; +my $version = "6.0dev PS150202"; # save program name for logging my $progname = basename($0);