From d8aee5f0fc6862f974e8536b4692294506991e73 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 8 Jan 2015 11:45:31 +0100 Subject: [PATCH] Improved the search filter and added new info icons to the modules in the tree view --- pandora_console/include/class/Tree.class.php | 146 +- .../include/javascript/tree/TreeController.js | 38 +- pandora_console/include/styles/pandora.css | 17 +- pandora_console/install.php | 1222 ----------------- pandora_console/operation/tree2.php | 91 ++ 5 files changed, 240 insertions(+), 1274 deletions(-) delete mode 100644 pandora_console/install.php diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 6f630cc080..32ed1d03e6 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -88,6 +88,12 @@ class Tree { $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; } + // Agent name filter + $agent_search = ""; + if (!empty($this->filter['search'])) { + $agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' "; + } + $list_os = os_get_os(); // Transform the os array to use the item id as key @@ -109,6 +115,7 @@ class Tree { WHERE ta.id_agente = tam.id_agente AND ta.disabled = 0 AND tam.disabled = 0 + $agent_search $group_acl ORDER BY ta.id_os ASC, ta.nombre ASC"; $data = db_process_sql($sql); @@ -233,9 +240,9 @@ class Tree { $filter = array(); $filter['parent'] = $parent; - if (!empty($this->filter['search'])) { - $filter['nombre'] = "%" . $this->filter['search'] . "%"; - } + // if (!empty($this->filter['search'])) { + // $filter['nombre'] = "%" . $this->filter['search'] . "%"; + // } // ACL groups if (isset($this->userGroups) && $this->userGroups === false) return array(); @@ -244,15 +251,15 @@ class Tree { $filter['id_grupo'] = array_keys($this->userGroups); // First filter by name and father - $groups = db_get_all_rows_filter('tgrupo', $filter, array('id_grupo', 'nombre')); + $groups = db_get_all_rows_filter('tgrupo', $filter, array('id_grupo', 'nombre', 'icon')); if (empty($groups)) $groups = array(); // Filter by status - $filter_status = AGENT_STATUS_ALL; - if (!empty($this->filter['status'])) { - $filter_status = $this->filter['status']; - } + // $filter_status = AGENT_STATUS_ALL; + // if (!empty($this->filter['status'])) { + // $filter_status = $this->filter['status']; + // } foreach ($groups as $iterator => $group) { // Counters @@ -269,39 +276,39 @@ class Tree { } $groups[$iterator]['status'] = $group_stats['status']; - $groups[$iterator]['icon'] = groups_get_icon($group['id_grupo']) . '.png'; + $groups[$iterator]['icon'] = !empty($group['icon']) ? $group['icon'] . '.png' : 'without_group.png'; - // Filter by status - if ($filter_status != AGENT_STATUS_ALL) { - $remove_group = true; - switch ($filter_status) { - case AGENT_STATUS_NORMAL: - if ($groups[$iterator]['status'] === "ok") - $remove_group = false; - break; - case AGENT_STATUS_WARNING: - if ($groups[$iterator]['status'] === "warning") - $remove_group = false; - break; - case AGENT_STATUS_CRITICAL: - if ($groups[$iterator]['status'] === "critical") - $remove_group = false; - break; - case AGENT_STATUS_UNKNOWN: - if ($groups[$iterator]['status'] === "unknown") - $remove_group = false; - break; - case AGENT_STATUS_NOT_INIT: - if ($groups[$iterator]['status'] === "not_init") - $remove_group = false; - break; - } + // // Filter by status + // if ($filter_status != AGENT_STATUS_ALL) { + // $remove_group = true; + // switch ($filter_status) { + // case AGENT_STATUS_NORMAL: + // if ($groups[$iterator]['status'] === "ok") + // $remove_group = false; + // break; + // case AGENT_STATUS_WARNING: + // if ($groups[$iterator]['status'] === "warning") + // $remove_group = false; + // break; + // case AGENT_STATUS_CRITICAL: + // if ($groups[$iterator]['status'] === "critical") + // $remove_group = false; + // break; + // case AGENT_STATUS_UNKNOWN: + // if ($groups[$iterator]['status'] === "unknown") + // $remove_group = false; + // break; + // case AGENT_STATUS_NOT_INIT: + // if ($groups[$iterator]['status'] === "not_init") + // $remove_group = false; + // break; + // } - if ($remove_group) { - unset($groups[$iterator]); - continue; - } - } + // if ($remove_group) { + // unset($groups[$iterator]); + // continue; + // } + // } if (is_null($limit)) { $groups[$iterator]['children'] = @@ -309,9 +316,7 @@ class Tree { } else if ($limit >= 1) { $groups[$iterator]['children'] = - $this->getGroupsRecursive( - $group['id_grupo'], - ($limit - 1)); + $this->getGroupsRecursive($group['id_grupo'], ($limit - 1)); } switch ($this->countAgentStatusMethod) { @@ -368,8 +373,11 @@ class Tree { } protected function processModule (&$module) { + global $config; + $module['type'] = 'module'; $module['id'] = (int) $module['id_agente_modulo']; + $module['agentID'] = (int) $module['id_agente']; $module['name'] = $module['nombre']; $module['id_module_type'] = (int) $module['id_tipo_modulo']; // $module['icon'] = modules_get_type_icon($module['id_tipo_modulo']); @@ -398,6 +406,23 @@ class Tree { $module['status'] = "ok"; break; } + + // 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 + ); } protected function processModules ($modules_aux, &$modules) { @@ -441,12 +466,19 @@ class Tree { $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; } + // Agent name filter + $agent_search = ""; + if (!empty($this->filter['search'])) { + $agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' "; + } + $sql = "SELECT tam.nombre AS module_name, tam.id_agente_modulo, tam.id_tipo_modulo, ta.id_agente, ta.nombre AS agent_name FROM tagente ta, tagente_modulo tam WHERE ta.id_agente = tam.id_agente AND ta.disabled = 0 AND tam.disabled = 0 + $agent_search $group_acl ORDER BY tam.nombre ASC, ta.nombre ASC"; $data = db_process_sql($sql); @@ -540,8 +572,10 @@ class Tree { $agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']); + $agent['statusRaw'] = agents_get_status($agent['id']); + // Status - switch (agents_get_status($agent['id'])) { + switch ($agent['statusRaw']) { case AGENT_STATUS_NORMAL: $agent['status'] = "ok"; break; @@ -608,11 +642,13 @@ class Tree { if (!isset($this->userGroups[$parent])) return array(); } - $filter = array( - 'id_grupo' => $parent, - 'status' => $this->filter['status'], - 'nombre' => "%" . $this->filter['search'] . "%" - ); + $filter = array(); + $filter['id_grupo'] = $parent; + if (isset($this->filter['status']) && $this->filter['status'] != -1) + $filter['status'] = $this->filter['status']; + if (!empty($this->filter['search'])) + $filter['nombre'] = "%" . $this->filter['search'] . "%"; + $agents = agents_get_agents($filter, array('id_agente', 'nombre')); if (empty($agents)) { $agents = array(); @@ -645,6 +681,12 @@ class Tree { $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; } + // Agent name filter + $agent_search = ""; + if (!empty($this->filter['search'])) { + $agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' "; + } + $module_groups = modules_get_modulegroups(); if (!empty($module_groups)) { @@ -655,6 +697,7 @@ class Tree { WHERE ta.id_agente = tam.id_agente AND ta.disabled = 0 AND tam.disabled = 0 + $agent_search $group_acl ORDER BY tam.nombre ASC, ta.nombre ASC"; $data = db_process_sql($sql); @@ -789,6 +832,12 @@ class Tree { $group_acl = " AND ta.id_grupo IN ($user_groups_str) "; } + // Agent name filter + $agent_search = ""; + if (!empty($this->filter['search'])) { + $agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' "; + } + $sql = "SELECT tam.nombre AS module_name, tam.id_agente_modulo, tam.id_tipo_modulo, tam.id_module_group, ta.id_agente, ta.nombre AS agent_name, @@ -799,6 +848,7 @@ class Tree { AND ttm.id_tag = tt.id_tag AND ta.disabled = 0 AND tam.disabled = 0 + $agent_search $group_acl ORDER BY tt.name ASC, ta.nombre ASC"; $data = db_process_sql($sql); diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index dd390608d1..62d640f013 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -309,7 +309,43 @@ TreeController = { $content.append(element.name); break; case 'module': - $content.append(element.name); + // Graph pop-up + var $graphImage = $(' '); + $graphImage + .addClass('module-graph') + .click(function (e) { + e.preventDefault(); + + try { + winopeng(element.moduleGraph.url, element.moduleGraph.handle); + } + catch (error) { + console.log(error); + } + }); + + // Data pop-up + var $dataImage = $(' '); + $dataImage + .addClass('module-data') + .click(function (e) { + e.preventDefault(); + + try { + if ($("#module_details_window").length > 0) + show_module_detail_dialog(element.id, element.agentID, '', 0, 86400); + } + catch (error) { + console.log(error); + } + }); + + $content + .append($graphImage) + .append($dataImage) + .append(element.name); break; case 'os': if (typeof element.icon != 'undefined' && element.icon.length > 0) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d69c0539a9..e112980478 100755 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -2931,15 +2931,26 @@ table#policy_modules td * { max-width: 20px; } -.tree-node-counters, .tree-node-counter { +.tree-node>.node-content>img.module-data, +.tree-node>.node-content>img.module-graph { + cursor: pointer; + padding-right: 3px; +} + +.tree-node>.node-content>.tree-node-counters, +.tree-node>.node-content>.tree-node-counters>.tree-node-counter { display: inline; } -.tree-node-counters { +.tree-node>.node-content>.tree-node-counters { } -.tree-node-counter { +.tree-node>.node-content>img { + vertical-align: middle; +} + +.tree-node>.node-content>.tree-node-counters>.tree-node-counter { font-weight: bold; font-size: 7pt; cursor: default; diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 5d8a573401..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1222 +0,0 @@ - - - - - Pandora FMS - Installation Wizard - - - - - - - - - - - - - -
- -
- - - -"; - echo " $label "; - echo ""; - if (!extension_loaded($ext)) { - echo ""; - return 1; - } - else { - echo ""; - return 0; - } - echo ""; -} - -function check_include ( $ext, $label ) { - echo ""; - echo " $label "; - echo ""; - if (!include($ext)) { - echo ""; - return 1; - } - else { - echo ""; - return 0; - } - echo ""; -} - -function check_exists ( $file, $label ) { - echo ""; - echo " $label "; - echo ""; - if (!file_exists ($file)) { - echo " "; - return 1; - } - else { - echo " "; - return 0; - } - echo ""; -} - -function check_generic ( $ok, $label ) { - echo ""; - echo " $label "; - echo ""; - if ($ok == 0 ) { - echo " "; - return 1; - } - else { - echo " "; - return 0; - } - echo ""; -} - -function check_writable ( $fullpath, $label ) { - echo ""; - echo " $label "; - echo ""; - if (file_exists($fullpath)) - if (is_writable($fullpath)) { - echo " "; - echo ""; - return 0; - } - else { - echo " "; - echo ""; - return 1; - } - else { - echo " "; - echo ""; - return 1; - } - -} - -function check_variable ( $var, $value, $label, $mode ) { - echo ""; - echo " $label "; - echo ""; - if ($mode == 1) { - if ($var >= $value) { - echo " "; - return 0; - } - else { - echo " "; - return 1; - } - } - elseif ($var == $value) { - echo " "; - return 0; - } - else { - echo " "; - return 1; - } - echo ""; -} - -function parse_mysql_dump($url) { - if (file_exists($url)) { - $file_content = file($url); - $query = ""; - foreach($file_content as $sql_line) { - if (trim($sql_line) != "" && strpos($sql_line, "--") === false) { - $query .= $sql_line; - if(preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); //Uncomment for debug - echo "
$query
"; - return 0; - } - $query = ""; - } - } - } - return 1; - } - else - return 0; -} - -function parse_postgresql_dump($connection, $url, $debug = false) { - if (file_exists($url)) { - $file_content = file($url); - - $query = ""; - - foreach ($file_content as $sql_line) { - $clean_line = trim($sql_line); - $comment = preg_match("/^(\s|\t)*--.*$/", $clean_line); - if ($comment) { - continue; - } - - if (empty($clean_line)) { - continue; - } - - $query .= $clean_line; - - //Check if the end of query with the the semicolon and any returns in the end of line - if(preg_match("/;[\040]*\$/", $clean_line)) { - //And execute and clean buffer - pg_send_query($connection, $query); - - $result = pg_get_result($connection); - - if ($debug) { - var_dump($query); - var_dump(pg_result_error($result)); - } - - if (pg_result_status($result) == PGSQL_FATAL_ERROR) { - echo pg_result_error($result); - echo "
$query
"; - - return 0; - } - - $query = ""; - } - } - - return 1; - } - else { - return 0; - } -} - -function parse_oracle_dump($connection, $url, $debug = false) { - if (file_exists($url)) { - $file_content = file($url); - - $query = ""; - $plsql_block = false; - - foreach ($file_content as $sql_line) { - $clean_line = trim($sql_line); - $comment = preg_match("/^(\s|\t)*--.*$/", $clean_line); - if ($comment) { - continue; - } - - if (empty($clean_line)) { - continue; - } - - //Support for PL/SQL blocks - if (preg_match("/^BEGIN$/", $clean_line)) { - $query .= $clean_line . ' '; - $plsql_block = true; - } - else{ - $query .= $clean_line; - } - - //Check query's end with a back slash and any returns in the end of line or if it's a PL/SQL block 'END;;' string - if ((preg_match("/;[\040]*\$/", $clean_line) && !$plsql_block) || - (preg_match("/^END;;[\040]*\$/", $clean_line) && $plsql_block)) { - $plsql_block = false; - //Execute and clean buffer - - //Delete the last semicolon from current query - $query = substr($query, 0, strlen($query) - 1); - $sql = oci_parse($connection, $query); - $result = oci_execute($sql); - - if ($debug) { - var_dump($query); - } - - if (!$result) { - $e = oci_error($sql); - echo "
Errors creating schema:
"; - echo htmlentities($e['message'], ENT_QUOTES); - echo "
$query
"; - echo "
"; - - return 0; - } - - $query = ""; - oci_free_statement($sql); - } - } - - return 1; - } - else { - return 0; - } -} - -function oracle_drop_all_objects ($connection) { - //Drop all objects of the current installation - $stmt = oci_parse($connection, - "BEGIN " . - "FOR cur_rec IN (SELECT object_name, object_type " . - "FROM user_objects " . - "WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " . - "BEGIN " . - "IF cur_rec.object_type = 'TABLE' THEN " . - "EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\" CASCADE CONSTRAINTS'; " . - "ELSE " . - "EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'; " . - "END IF; " . - "EXCEPTION " . - "WHEN OTHERS THEN " . - "DBMS_OUTPUT.put_line('FAILED: DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'); " . - "END; " . - "END LOOP; " . - "END; "); - - $result = oci_execute($stmt); - oci_free_statement($stmt); - - return 0; -} - -function random_name ($size) { - $temp = ""; - for ($a=0;$a< $size;$a++) - $temp = $temp. chr(rand(122,97)); - - return $temp; -} - -function print_logo_status ($step, $step_total) { - global $banner; - - return " -
-
-
- $banner -
-
- Install step $step of $step_total -
-
"; -} - -// -// This function adjusts path settings in pandora db for FreeBSD. -// -// All packages and configuration files except operating system's base files -// are installed under /usr/local in FreeBSD. So, path settings in pandora db -// for some programs should be changed from the Linux default. -// -function adjust_paths_for_freebsd($engine, $connection = false) { - - $adjust_sql = array( - "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", - "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", - "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", - "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", - "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", - "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');" - ); - - for ($i = 0; $i < count ($adjust_sql); $i++) { - switch ($engine) { - case 'mysql': - $result = mysql_query($adjust_sql[$i]); - break; - case 'oracle': - //Delete the last semicolon from current query - $query = substr($adjust_sql[$i], 0, strlen($adjust_sql[$i]) - 1); - $sql = oci_parse($connection, $query); - $result = oci_execute($sql); - break; - case 'pgsql': - pg_send_query($connection, $adjust_sql[$i]); - $result = pg_get_result($connection); - break; - } - if (!$result) { - return 0; - } - } - - return 1; -} - -function install_step1() { - global $banner; - - echo " -
-
- " . print_logo_status (1,6) . " -
-

Welcome to Pandora FMS installation Wizard

-

This wizard helps you to quick install Pandora FMS console and main database in your system.

-

In four steps, this installer will check all dependencies and will create your configuration, ready to use.

-

For more information, please refer to documentation.
- Pandora FMS Development Team

- "; - if (file_exists("include/config.php")) { - echo "
Warning: You already have a config.php file. - Configuration and database would be overwritten if you continued.
"; - } - echo "
"; - echo ""; - $writable = check_writable ( "include", "Checking if ./include is writable"); - if (file_exists("include/config.php")) - $writable += check_writable ( "include/config.php", "Checking if include/config.php is writable"); - echo "
"; - - echo "
Warning: This installer will overwrite and destroy - your existing Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database.
-
"; - - echo "
Upgrade: - If you want to upgrade from Pandora FMS 4.x to 5.0 version, please use the migration tool inside /extras directory in this setup. -
"; - - if ($writable == 0) { - echo "
"; - echo ""; - } - else { - echo "
ERROR:You need to setup permissions to be able to write in ./include directory
"; - echo "
"; - } - - echo "
"; - echo " -
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
- "; -} - -function install_step1_licence() { - echo " -
-
- " . print_logo_status (2,6) . " -
-

GPL2 Licence terms agreement

-

Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms.. -

For more information, please refer to our website at http://pandorafms.org and contact us if you have any kind of question about the usage of Pandora FMS

-

If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.

- "; - - if (!file_exists("COPYING")) { - echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; - echo "
"; - } - else { - echo "
"; - echo ""; - echo "

"; - echo "

"; - } - echo "
"; - - echo "
-
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - -function install_step2() { - - echo " -
-
- " . print_logo_status (3,6) . " -
"; - echo "

Checking software dependencies

"; - echo ""; - $res = 0; - $res += check_variable(phpversion(),"5.2","PHP version >= 5.2",1); - $res += check_extension("gd","PHP GD extension"); - $res += check_extension("ldap","PHP LDAP extension"); - $res += check_extension("snmp","PHP SNMP extension"); - $res += check_extension("session","PHP session extension"); - $res += check_extension("gettext","PHP gettext extension"); - $res += check_extension("mbstring","PHP Multibyte String"); - $res += check_extension("zip","PHP Zip"); - $res += check_extension("zlib","PHP Zlib extension"); - $res += check_extension("curl","CURL (Client URL Library)"); - if (PHP_OS == "FreeBSD") { - $res += check_exists ("/usr/local/bin/twopi","Graphviz Binary"); - } - else if (PHP_OS == "NetBSD") { - $res += check_exists ("/usr/pkg/bin/twopi","Graphviz Binary"); - } - else { - $res += check_exists ("/usr/bin/twopi","Graphviz Binary"); - } - - echo ""; - check_extension("mysql", "PHP MySQL extension"); - check_extension("pgsql", "PHP PostgreSQL extension"); - check_extension("oci8", "PHP Oracle extension"); - echo "
"; - echo "DB Engines"; - echo ""; - echo "
"; - - if ($res > 0) { - echo " -
You have some incomplete - dependencies. Please correct them or this installer - will not be able to finish your installation. -
-
- Remember, if you install any PHP module to comply - with these dependences, you need to restart - your HTTP/Apache server after it to use the new - modules. -
-
- Ignore it. Force install Step #3 -
"; - echo "
"; - } - else { - echo "
"; - echo "
-
-
"; - } - echo " -
-
- -
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
- "; -} - - -function install_step3() { - $options = ''; - if (extension_loaded("mysql")) { - $options .= ""; - } - if (extension_loaded("pgsql")) { - $options .= ""; - } - if (extension_loaded("oci8")) { - $options .= ""; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
-
- " . print_logo_status (4,6) . " -
-

Environment and database setup

-

- This wizard will create your Pandora FMS database, - and populate it with all the data needed to run for the first time. -

-

- You need a privileged user to create database schema, this is usually root user. - Information about root user will not be used or stored anymore. -

-

- You can also deploy the scheme into an existing Database. - In this case you need a privileged Database user and password of that instance. -

-

- Now, please, complete all details to configure your database and environment setup. -

-
- Warning: This installer will overwrite and destroy your existing - Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database. -

-
"; - - if (extension_loaded("oci8")) { - echo "
For Oracle installation an existing Database with a privileged user is needed.
"; - } - if (!$error) { - echo ""; - } - - echo ""; - echo "
"; - echo "DB Engine
"; - - - if ($error) { - echo " -
- Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
"; - } - else { - echo ""; - - echo "
"; - echo " Installation in
"; - echo ""; - } - echo "
DB User with privileges
- - -
DB Password for this user
- - -
DB Hostname
- - -
DB Name (pandora by default)
- - -
- Drop Database if exists
- - - -
Full path to HTTP publication directory
- For example /var/www/pandora_console/ -
- - -
URL path to Pandora FMS Console
- For example '/pandora_console' -
- -
- "; - - - echo "
"; - - if (!$error) { - echo ""; - } - - echo ""; - - echo "
"; - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - -function install_step4() { - $pandora_config = "include/config.php"; - - if ( (! isset($_POST["user"])) || (! isset($_POST["dbname"])) || (! isset($_POST["host"])) || - (! isset($_POST["pass"])) || (!isset($_POST['engine'])) || (! isset($_POST["db_action"])) ) { - $dbpassword = ""; - $dbuser = ""; - $dbhost = ""; - $dbname = ""; - $engine = ""; - $dbaction = ""; - } - else { - $engine = $_POST['engine']; - $dbpassword = $_POST["pass"]; - $dbuser = $_POST["user"]; - $dbhost = $_POST["host"]; - $dbaction = $_POST["db_action"]; - if (isset($_POST["drop"])) - $dbdrop = $_POST["drop"]; - else - $dbdrop = 0; - - $dbname = $_POST["dbname"]; - if (isset($_POST["url"])) - $url = $_POST["url"]; - else - $url = "http://localhost"; - if (isset($_POST["path"])) { - $path = $_POST["path"]; - $path = str_replace("\\", "/", $path); // Windows compatibility - } - else - $path = "/var/www"; - } - $everything_ok = 0; - $step1=0; - $step2=0; - $step3=0; - $step4=0; $step5=0; $step6=0; $step7=0; - - echo " -
-
- " . print_logo_status(5,6) . " -
-

Creating database and default configuration file

- "; - switch ($engine) { - case 'mysql': - if (! mysql_connect ($dbhost, $dbuser, $dbpassword)) { - check_generic ( 0, "Connection with Database"); - } - else { - check_generic ( 1, "Connection with Database"); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query ("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query ("CREATE DATABASE `$dbname`"); - check_generic ($step1, "Creating database '$dbname'"); - } - else { - $step = 1; - } - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic ($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump("pandoradb.sql"); - check_generic ($step3, "Creating schema"); - - $step4 = parse_mysql_dump("pandoradb_data.sql"); - check_generic ($step4, "Populating database"); - if (PHP_OS == "FreeBSD") { - $step_freebsd = adjust_paths_for_freebsd ($engine); - check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD"); - } - - $random_password = random_name (8); - $host = 'localhost'; - if ($dbhost != 'localhost') - $host = $_SERVER['SERVER_ADDR']; - $step5 = mysql_query ("GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'"); - mysql_query ("FLUSH PRIVILEGES"); - check_generic ($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - $step6 = is_writable("include"); - check_generic ($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen ("include/config.inc.php","r"); - $cfgout = fopen ($pandora_config,"w"); - $config_contents = fread ($cfgin, filesize("include/config.inc.php")); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs ($cfgout, $config_new); - $step7 = $step7 + fputs ($cfgout, $config_contents); - if ($step7 > 0) - $step7 = 1; - fclose ($cfgin); - fclose ($cfgout); - chmod ($pandora_config, 0600); - check_generic ($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - case 'oracle': - $connection = oci_connect($dbuser, $dbpassword, '//' . $dbhost . '/' . $dbname); - if (!$connection) { - check_generic(0, "Connection with Database"); - } - else { - check_generic(1, "Connection with Database"); - - // Drop all objects if needed - if ($dbdrop == 1) { - oracle_drop_all_objects($connection); - } - - $step1 = parse_oracle_dump($connection, "pandoradb.oracle.sql"); - - check_generic($step1, "Creating schema"); - - if ($step1) { - $step2 = parse_oracle_dump($connection, "pandoradb.data.oracle.sql"); - } - - check_generic ($step2, "Populating database"); - - if (PHP_OS == "FreeBSD") - { - $step_freebsd = adjust_paths_for_freebsd ($engine, $connection); - check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD"); - } - - echo ""; - - if ($step2) { - $step3 = is_writable("include"); - } - - check_generic ($step3, "Write permissions to save config file in './include'"); - - if ($step3) { - $cfgin = fopen ("include/config.inc.php","r"); - $cfgout = fopen ($pandora_config,"w"); - $config_contents = fread ($cfgin, filesize("include/config.inc.php")); - $dbtype = 'oracle'; - $config_new = ''; - $step4 = fputs ($cfgout, $config_new); - $step4 = $step4 + fputs ($cfgout, $config_contents); - if ($step4 > 0) - $step4 = 1; - fclose ($cfgin); - fclose ($cfgout); - chmod ($pandora_config, 0600); - } - - check_generic ($step4, "Created new config file at '" . $pandora_config . "'"); - - if (($step4 + $step3 + $step2 + $step1) == 4) { - $everything_ok = 1; - } - - } - break; - case 'pgsql': - $step1 = $step2 = $step3 = $step4 = $step5 = $step6 = $step7 = 0; - - $connection = pg_connect("host='" . $dbhost . "' dbname='postgres' user='" . $dbuser . "' password='" . $dbpassword . "'"); - if ($connection === false) { - check_generic(0, "Connection with Database"); - } - else { - check_generic(1, "Connection with Database"); - - // Drop database if needed - if ($dbdrop == 1 && $dbaction == 'db_exist') { - $result = pg_query($connection, "DROP DATABASE \"" . $dbname . "\";"); - } - - if ($dbaction != 'db_exist' || $dbdrop == 1) { - pg_send_query($connection, "CREATE DATABASE \"" . $dbname . "\" WITH ENCODING 'utf8';"); - $result = pg_get_result($connection); - if (pg_result_status($result) != PGSQL_FATAL_ERROR) { - $step1 = 1; - } - - check_generic ($step1, "Creating database '$dbname'"); - } - else { - $step1 = 1; - } - - check_generic ($step1, "Creating database '$dbname'"); - - if ($step1 == 1) { - //Reopen DB because I don't know how to use DB in PostgreSQL - pg_close($connection); - - $connection = pg_connect("host='" . $dbhost . "' dbname='" . $dbname . - "' user='" . $dbuser . "' password='" . $dbpassword . "'"); - - if ($connection !== false) { - $step2 = 1; - } - } - - check_generic ($step2, "Opening database '$dbname'"); - - if ($step2) { - $step3 = parse_postgresql_dump($connection, "pandoradb.postgreSQL.sql"); - } - - check_generic($step3, "Creating schema"); - - if ($step3) { - $step4 = parse_postgresql_dump($connection, "pandoradb.data.postgreSQL.sql"); - } - - check_generic ($step4, "Populating database"); - - if (PHP_OS == "FreeBSD") - { - $step_freebsd = adjust_paths_for_freebsd ($engine, $connection); - check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD"); - } - - if ($step4) { - $random_password = random_name (8); - - pg_query($connection, "DROP USER pandora"); - pg_send_query($connection, "CREATE USER pandora WITH PASSWORD '" . $random_password . "'"); - $result = pg_get_result($connection); - - if (pg_result_status($result) != PGSQL_FATAL_ERROR) { - //Set the privileges for DB - pg_send_query($connection, "GRANT ALL PRIVILEGES ON DATABASE pandora TO pandora;"); - $result = pg_get_result($connection); - - $setDBPrivileges = 0; - if (pg_result_status($result) != PGSQL_FATAL_ERROR) { - $setDBPrivileges = 1; - } - - if ($setDBPrivileges) { - //Set the privileges for each tables. - pg_send_query($connection, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';"); - $result = pg_get_result($connection); - - $tables = array(); - while ($row = pg_fetch_assoc($result)) { - $tables[] = $row['table_name']; - } - - $correct = 1; - foreach ($tables as $table) { - pg_send_query($connection, "GRANT ALL PRIVILEGES ON TABLE " . $table . " TO pandora;"); - $result = pg_get_result($connection); - - if (pg_result_status($result) == PGSQL_FATAL_ERROR) { - $correct = 0; - break; - } - - //For each table make owner pandora - pg_send_query($connection, "ALTER TABLE " . $table . " OWNER TO pandora;"); - $result = pg_get_result($connection); - - if (pg_result_status($result) == PGSQL_FATAL_ERROR) { - $correct = 0; - break; - } - - //INI ----- Grant for secuences - pg_send_query($connection, "SELECT column_name FROM information_schema.columns WHERE table_name = '" . $table . "';"); - $result2 = pg_get_result($connection); - - $columns = array(); - while ($row = pg_fetch_assoc($result2)) { - $columns[] = $row['column_name']; - } - - //Check for each column if it have a sequence to grant - foreach ($columns as $column) { - pg_send_query($connection, "SELECT pg_get_serial_sequence('" . $table . "', '" . $column . "');"); - $result3 = pg_get_result($connection); - - $sequence = pg_fetch_assoc($result3); - if (!empty($sequence['pg_get_serial_sequence'])) { - pg_send_query($connection, "GRANT ALL PRIVILEGES ON SEQUENCE " . $sequence['pg_get_serial_sequence'] . " to pandora;"); - $result4 = pg_get_result($connection); - - if (pg_result_status($result4) == PGSQL_FATAL_ERROR) { - $correct = 0; - break; - } - } - } - //END ----- Grant for secuences - - } - - if ($correct) { - $step5 = 1; - } - } - } - } - - check_generic ($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - if ($step5) { - $step6 = is_writable("include"); - } - - check_generic ($step6, "Write permissions to save config file in './include'"); - - if ($step6) { - $cfgin = fopen ("include/config.inc.php","r"); - $cfgout = fopen ($pandora_config,"w"); - $config_contents = fread ($cfgin, filesize("include/config.inc.php")); - $dbtype = 'postgresql'; - $config_new = ''; - $step7 = fputs ($cfgout, $config_new); - $step7 = $step7 + fputs ($cfgout, $config_contents); - if ($step7 > 0) - $step7 = 1; - fclose ($cfgin); - fclose ($cfgout); - chmod ($pandora_config, 0600); - } - - check_generic ($step7, "Created new config file at '".$pandora_config."'"); - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - } - break; - } - echo "
Please, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file and set database password.
"; - - if ($everything_ok == 1) { - echo "
"; - echo "
-
"; - } - else { - $info = "
There were some problems. - Installation was not completed. -

Please correct failures before trying again. - All database "; - if ($engine == 'oracle') - $info .= "objects "; - else - $info .= "schemes "; - - $info .= "created in this step have been dropped.

-
"; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != "") { - echo "
ERROR: ". mysql_error().".
"; - } - - if ($step1 == 1) { - mysql_query ("DROP DATABASE $dbname"); - } - break; - case 'pgsql': - break; - case 'oracle': - oracle_drop_all_objects($connection); - break; - } - echo "
"; - } - - echo "
"; - echo " -
-
- Pandora FMS is an Open Source Software project registered at - SourceForge -
- "; -} - - -function install_step5() { - echo " -
-
- " . print_logo_status (6,6) . " -
-

Installation complete

-

For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

-

Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

-

Don't forget to check http://pandorafms.com - for updates. -


Click here to access to your Pandora FMS console. -

-
"; - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} -?> diff --git a/pandora_console/operation/tree2.php b/pandora_console/operation/tree2.php index e386827a5b..760f6e86e3 100644 --- a/pandora_console/operation/tree2.php +++ b/pandora_console/operation/tree2.php @@ -132,6 +132,8 @@ html_print_table($table); echo ''; // --------------------- 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, @@ -234,4 +236,93 @@ echo ""; }); } + // Show the modal window of an module + var moduleDetailsWindow = $("
"); + 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: "", + 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: '', + timeOnlyTitle: '', + timeText: '', + hourText: '', + minuteText: '', + secondText: '', + currentText: '', + closeText: ''}); + + $.datepicker.setDefaults($.datepicker.regional[ ""]); + $("#text-date_from, #text-date_to").datepicker({dateFormat: ""}); + + } + + 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; + }); + } + \ No newline at end of file