diff --git a/extras/chrome_extension/css/popup.css b/extras/chrome_extension/css/popup.css index a736abea57..e505e720cc 100644 --- a/extras/chrome_extension/css/popup.css +++ b/extras/chrome_extension/css/popup.css @@ -247,4 +247,11 @@ button h3 { } .sev-Maintenance { background: #A8A8A8; +} +.sev-Minor { + background: #F099A2; + color: #333; +} +.sev-Major { + background: #C97A4A; } \ No newline at end of file diff --git a/extras/chrome_extension/js/background.js b/extras/chrome_extension/js/background.js index 14960d849a..521ecc19eb 100644 --- a/extras/chrome_extension/js/background.js +++ b/extras/chrome_extension/js/background.js @@ -29,11 +29,13 @@ function main() { if (isFetching) return; isFetching = true; - var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"]; + var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=json&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"]; + req = new XMLHttpRequest(); req.onload = handleResponse; req.onerror = handleError; req.open("GET", feedUrl, true); + req.withCredentials = true req.send(null); } @@ -132,25 +134,23 @@ function fetchNewEvents(A,B){ function parseReplyEvents (reply) { // Split the API response - var e_array = reply.split("\n"); + var data = JSON.parse(reply) + var e_array = JSON.parse(reply).data; // Form a properly object var fetchedEvents=new Array(); for(var i=0;i \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/shellscript/linux/tentacle_client b/pandora_agents/shellscript/linux/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/shellscript/linux/tentacle_client +++ b/pandora_agents/shellscript/linux/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/shellscript/mac_osx/tentacle_client b/pandora_agents/shellscript/mac_osx/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/shellscript/mac_osx/tentacle_client +++ b/pandora_agents/shellscript/mac_osx/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 86b23fdb7a..41cc911f04 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.729-181121 +Version: 7.0NG.729-181205 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 9c23f55258..8f76eb020a 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="7.0NG.729-181121" +pandora_version="7.0NG.729-181205" 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 7950a9ac3b..55a4df5cfb 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.729'; -use constant AGENT_BUILD => '181121'; +use constant AGENT_BUILD => '181205'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 36ab5fd73a..107458342e 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 7.0NG.729 -%define release 181121 +%define release 181205 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 e40aa2d331..824db2d44f 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 7.0NG.729 -%define release 181121 +%define release 181205 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 4472239b6e..15ce482e20 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181121" +PI_BUILD="181205" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/tentacle_client b/pandora_agents/unix/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/unix/tentacle_client +++ b/pandora_agents/unix/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 474db7ba2c..a04af66252 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181121} +{181205} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 6e4ccb69da..80251b3ad4 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 ("7.0NG.729(Build 181121)") +#define PANDORA_VERSION ("7.0NG.729(Build 181205)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 839789b48d..76824914ca 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", "(7.0NG.729(Build 181121))" + VALUE "ProductVersion", "(7.0NG.729(Build 181205))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index e82acca4ce..50ed14c136 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.729-181121 +Version: 7.0NG.729-181205 Architecture: all Priority: optional Section: admin Installed-Size: 42112 Maintainer: Artica ST Homepage: http://pandorafms.org/ -Depends: php | php7.2, php7.2-snmp | php-snmp, php7.2-gd | php-gd, php7.2-mysqlnd | php-mysqlnd, php-db, php7.2-xmlrpc | php-xmlrpc, php-gettext, php7.2-curl | php-curl, graphviz, dbconfig-common, php7.2-ldap | php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc +Depends: php | php7.2, php7.2-snmp | php-snmp, php7.2-gd | php-gd, php7.2-mysqlnd | php-mysqlnd, php-db, php7.2-xmlrpc | php-xmlrpc, php-gettext, php7.2-curl | php-curl, graphviz, dbconfig-common, php7.2-ldap | php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php7.2-zip | php-zip Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index bd4a3bd65d..7e7319dc37 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="7.0NG.729-181121" +pandora_version="7.0NG.729-181205" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index 6947bfcc3a..97ffe031a9 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -18,9 +18,8 @@ if ((! file_exists("include/config.php")) || (! is_readable("include/config.php" exit; } -// Real start -session_start(); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('include/config.php'); require_once ('include/functions.php'); require_once ('include/functions_db.php'); @@ -82,7 +81,6 @@ if (isset($config['metaconsole'])) { if ($config['metaconsole']) define ('METACONSOLE', true); } -session_write_close (); if (file_exists ($page)) { require_once ($page); diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index 9c67bbec1c..092b90b3f3 100755 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -16,14 +16,14 @@ if (isset($_GET['get_ptr'])) { if ($_GET['get_ptr'] == 1) { - - session_start (); - session_write_close (); - + $ownDir = dirname(__FILE__) . '/'; $ownDir = str_replace("\\", "/", $ownDir); + + // Don't start a session before this import. + // The session is configured and started inside the config process. require_once ($ownDir.'../include/config.php'); - + // Login check if (!isset($_SESSION["id_usuario"])) { $config['id_user'] = null; diff --git a/pandora_console/extras/mr/23.sql b/pandora_console/extras/mr/23.sql new file mode 100644 index 0000000000..a602023e3b --- /dev/null +++ b/pandora_console/extras/mr/23.sql @@ -0,0 +1,9 @@ +START TRANSACTION; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0'; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0'; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index e27569a0cf..5b98fdbec0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1180,13 +1180,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 22); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 23); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '729'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '730'); -- --------------------------------------------------------------------- -- Table `tconfig_os` @@ -1826,3 +1826,9 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `module_search` varchar(600) default '', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0'; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0'; diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index 33c8493e26..be002871ac 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -32,9 +32,7 @@ if (!$config["MR"]) { echo ''; -if(enterprise_installed()){ - enterprise_include_once("../include/functions_update_manager.php"); -} +include_once ($config["homedir"]."/include/functions_update_manager.php"); $current_package = update_manager_get_current_package(); @@ -48,7 +46,7 @@ else{ echo sprintf(__('%s %s - Build %s - MR %s', get_product_name(), $pandora_version, $build_package_version, $config["MR"])); echo '
'; -echo ''. __('Page generated at') . ' '. date('F j, Y h:i a'); //Always use timestamp here +echo ''. __('Page generated at') . ' '. date($config["date_format"]); echo '
® '.get_copyright_notice().''; if (isset ($config['debug'])) { diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 2c4ca1e6cb..8cb37fa2c4 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -335,11 +335,8 @@ $(document).ready( function() { handsIn = 0; handsIn2 = 0; - //Daniel maya 02/06/2016 Display menu with click --INI if(!click_display){ - //Daniel barbero 10/08/2016 Display menu with click --INI if (autohidden_menu) { - //Daniel barbero 10/08/2016 Display menu with click --END $('.menu_icon').mouseenter(function() { table_hover = $(this); handsIn = 1; @@ -359,37 +356,10 @@ $(document).ready( function() { } }, 2500); }); - //Daniel barbero 10/08/2016 Display menu with click --INI - } else { - $('.menu_icon').mouseenter(function() { - table_hover = $(this); - handsIn = 1; - openTime = new Date().getTime(); - $("ul#sub"+table_hover[0].id).show(); - if( typeof(table_noHover) != 'undefined') - if ( "ul#sub"+table_hover[0].id != "ul#sub"+table_noHover[0].id ) - $("ul#sub"+table_noHover[0].id).hide(); - }).mouseleave(function() { - table_noHover = $(this); - handsIn = 0; - $("ul#sub"+table_hover[0].id).hide(); - /* - setTimeout(function() { - opened = new Date().getTime() - openTime; - if(opened > 3000 && handsIn == 0) { - openTime = 4000; - $("ul#sub"+table_hover[0].id).hide(); - } - }, 2500); - */ - }); } - //Daniel barbero 10/08/2016 Display menu with click --END }else{ $(document).ready(function() { - //Daniel barbero 10/08/2016 Display menu with click --INI if (autohidden_menu) { - //Daniel barbero 10/08/2016 Display menu with click --END $('.menu_icon').on("click", function() { if( typeof(table_hover) != 'undefined'){ $("ul#sub"+table_hover[0].id).hide(); @@ -409,7 +379,6 @@ $(document).ready( function() { } }, 5500); }); - //Daniel barbero 10/08/2016 Display menu with click --INI } else { $('.menu_icon').on("click", function() { if( typeof(table_hover) != 'undefined'){ @@ -421,10 +390,8 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).show(); }); } - //Daniel barbero 10/08/2016 Display menu with click --END }); } - //Daniel maya 02/06/2016 Display menu with click --END - $('.has_submenu').mouseenter(function() { table_hover2 = $(this); diff --git a/pandora_console/general/pandora_help.php b/pandora_console/general/pandora_help.php index 72ed4ec827..eef5cfddb2 100644 --- a/pandora_console/general/pandora_help.php +++ b/pandora_console/general/pandora_help.php @@ -14,8 +14,10 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../include/config.php"); + require_once ("../include/functions.php"); require_once ("../include/functions_html.php"); ?> @@ -33,11 +35,6 @@ require_once ("../include/functions_html.php"); $id = get_parameter ('id'); $id_user = get_parameter ('id_user'); -if (! isset($_SESSION['id_usuario'])) { - session_start(); - session_write_close(); -} - $user_language = get_user_language ($id_user); if (file_exists ('../include/languages/'.$user_language.'.mo')) { diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php index a884912e63..ae35e31cb7 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php @@ -261,7 +261,7 @@ if ($snmpwalk) { } if ($create_modules) { - $modules = get_parameter("module", array()); + $modules = io_safe_output(get_parameter("module", array())); $devices = array(); $processes = array(); diff --git a/pandora_console/godmode/agentes/planned_downtime.export_csv.php b/pandora_console/godmode/agentes/planned_downtime.export_csv.php index 5b9a6a06e7..bdac1eca41 100644 --- a/pandora_console/godmode/agentes/planned_downtime.export_csv.php +++ b/pandora_console/godmode/agentes/planned_downtime.export_csv.php @@ -13,9 +13,10 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start (); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); + require_once ("../../include/functions.php"); require_once ("../../include/functions_db.php"); require_once ("../../include/functions_users.php"); diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 2c2357541d..a1ae9afca5 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -215,6 +215,7 @@ if ($delete_action) { __('Could not be deleted')); } +$table = new stdClass(); $table->width = '100%'; $table->class = 'databox data'; $table->data = array (); diff --git a/pandora_console/godmode/audit_log_csv.php b/pandora_console/godmode/audit_log_csv.php index b09b90f827..7043853f66 100644 --- a/pandora_console/godmode/audit_log_csv.php +++ b/pandora_console/godmode/audit_log_csv.php @@ -12,19 +12,17 @@ $ownDir = dirname(__FILE__) . '/'; $ownDir = str_replace("\\", "/", $ownDir); -require_once($ownDir . "../include/config.php"); -require_once($config["homedir"] . "/include/functions.php"); -require_once($config["homedir"] . "/include/functions_db.php"); -require_once($config["homedir"] . "/include/auth/mysql.php"); +// Don't start a session before this import. +// The session is configured and started inside the config process. +require_once ($ownDir . "../include/config.php"); + +require_once ($config["homedir"] . "/include/functions.php"); +require_once ($config["homedir"] . "/include/functions_db.php"); +require_once ($config["homedir"] . "/include/auth/mysql.php"); global $config; -if (! isset($_SESSION["id_usuario"])) { - session_start(); - session_write_close(); -} - // Login check if (!isset($_SESSION["id_usuario"])) { $config['id_user'] = null; diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index c8911c0f44..e7e3ba779f 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -229,15 +229,31 @@ $(document).ready (function () { }); $("#left").click (function () { + var current_fields_size = ($('#fields_selected option').length); + var selected_fields = []; + var selected_fields_total = ''; + jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { - field_name = $(value).html(); - if (field_name != ) { - id_field = $(value).attr('value'); - $("select[name='fields_available[]']").append($("").val(id_field).html('' + field_name + '')); - $("#fields_selected").find("option[value='" + id_field + "']").remove(); - $("#fields_available").find("option[value='0']").remove(); - } + field_name = $(value).html(); + selected_fields.push(field_name); + selected_fields_total = selected_fields.length; }); + + if(selected_fields_total === current_fields_size){ + display_confirm_dialog( + "'.__('There must be at least one custom field. Timestamp will be set by default').''; ?>", + "", + "", + function () { + move_left(); + $("#fields_available").find("option[value='timestamp']").remove(); + $("select[name='fields_selected[]']").append($("").val('timestamp').html('' + 'Timestamp' + '')); + } + ); + } + else{ + move_left(); + } }); $("#submit-upd_button").click(function () { @@ -247,4 +263,16 @@ $(document).ready (function () { }); }); }); + +function move_left(){ + jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { + field_name = $(value).html(); + if (field_name != ) { + id_field = $(value).attr('value'); + $("select[name='fields_available[]']").append($("").val(id_field).html('' + field_name + '')); + $("#fields_selected").find("option[value='" + id_field + "']").remove(); + $("#fields_available").find("option[value='0']").remove(); + } + }); +} diff --git a/pandora_console/godmode/events/event_responses.list.php b/pandora_console/godmode/events/event_responses.list.php index 09b5f7353d..6e707eadb2 100644 --- a/pandora_console/godmode/events/event_responses.list.php +++ b/pandora_console/godmode/events/event_responses.list.php @@ -16,6 +16,8 @@ global $config; +include_once($config['homedir'] . "/include/functions_event_responses.php"); + check_login (); if (! check_acl($config['id_user'], 0, "PM")) { @@ -25,14 +27,7 @@ if (! check_acl($config['id_user'], 0, "PM")) { return; } -if (!is_user_admin($config['id_user'])) { - $id_groups = array_keys(users_get_groups(false, "PM")); - $event_responses = db_get_all_rows_filter('tevent_response', - array('id_group' => $id_groups)); -} -else { - $event_responses = db_get_all_rows_in_table('tevent_response'); -} +$event_responses = event_responses_get_responses(); if(empty($event_responses)) { ui_print_info_message ( array('no_close'=>true, 'message'=> __('No responses found') ) ); diff --git a/pandora_console/godmode/events/event_responses.php b/pandora_console/godmode/events/event_responses.php index 638774ab56..d06dc0932a 100644 --- a/pandora_console/godmode/events/event_responses.php +++ b/pandora_console/godmode/events/event_responses.php @@ -40,24 +40,9 @@ switch($action) { $values['modal_height'] = get_parameter('modal_height'); $values['new_window'] = get_parameter('new_window'); $values['params'] = get_parameter('params'); - if (enterprise_installed()) { - if ($values['type'] == 'command') { - $values['server_to_exec'] = get_parameter('server_to_exec'); - } - else { - $values['server_to_exec'] = 0; - } - } - else { - $values['server_to_exec'] = 0; - } - - if($values['new_window'] == 1) { - $values['modal_width'] = 0; - $values['modal_height'] = 0; - } - - $result = db_process_sql_insert('tevent_response', $values); + $values['server_to_exec'] = get_parameter('server_to_exec'); + + $result = event_responses_create_response($values); if($result) { ui_print_success_message(__('Response added succesfully')); @@ -78,26 +63,10 @@ switch($action) { $values['modal_height'] = get_parameter('modal_height'); $values['new_window'] = get_parameter('new_window'); $values['params'] = get_parameter('params'); - if (enterprise_installed()) { - if ($values['type'] == 'command') { - $values['server_to_exec'] = get_parameter('server_to_exec'); - } - else { - $values['server_to_exec'] = 0; - } - } - else { - $values['server_to_exec'] = 0; - } - - if($values['new_window'] == 1) { - $values['modal_width'] = 0; - $values['modal_height'] = 0; - } - + $values['server_to_exec'] = get_parameter('server_to_exec'); $response_id = get_parameter('id_response',0); - - $result = db_process_sql_update('tevent_response', $values, array('id' => $response_id)); + + $result = event_responses_update_response($response_id, $values); if($result) { ui_print_success_message(__('Response updated succesfully')); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 8ad895ff35..71fac6bf03 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -120,7 +120,9 @@ if (check_acl ($config['id_user'], 0, "AW")) { $sub2["godmode/massive/massive_operations&tab=massive_users"]["text"] = __('Users operations'); } $sub2["godmode/massive/massive_operations&tab=massive_alerts"]["text"] = __('Alerts operations'); - enterprise_hook('massivepolicies_submenu'); + if ($config["centralized_management"] != 1) { + enterprise_hook('massivepolicies_submenu'); + } enterprise_hook('massivesnmp_submenu'); enterprise_hook('massivesatellite_submenu'); diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index f2a10e2158..77b9fceda5 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -49,7 +49,7 @@ You can of course remove the warnings, that's why we include the source and do n ui_print_page_header (__('Module management') . ' » ' . __('Network component management'), "", false, - "network_component", true,"",true,"modulemodal"); + "network_component", true,"",false,"modulemodal"); $sec = 'gmodules'; } diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 38091f1023..75c8564ae3 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1574,7 +1574,8 @@ You can of course remove the warnings, that's why we include the source and do n - + ') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:right;'); - } else if(values['label_position'] == 'right'){ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:left;'); - } else{ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png"); - } - - + $('#'+idItem).append($image); - } - + if ((values['width'] == 0) || (values['height'] == 0)) { - $("#image_" + idItem).removeAttr('width'); - $("#image_" + idItem).removeAttr('height'); - $("#image_" + idItem).attr('width', 520); - $("#image_" + idItem).attr('height', 80); - $("#image_" + idItem).css('width', '520px'); - $("#image_" + idItem).css('height', '80px'); - $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); - + $("#image_" + idItem).removeAttr('width'); + $("#image_" + idItem).removeAttr('height'); + $("#image_" + idItem).attr('width', 520); + $("#image_" + idItem).attr('height', 80); + $("#image_" + idItem).css('width', '520px'); + $("#image_" + idItem).css('height', '80px'); + $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); } else { $("#image_" + idItem).removeAttr('width'); @@ -328,49 +314,36 @@ function update_button_palette_callback() { $("#image_" + idItem).css('width', values['width'] + 'px'); $("#image_" + idItem).css('height', values['height'] + 'px'); $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); - } - + } } else{ - if ((values['width'] == 0) || (values['height'] == 0)) { - if(values['image'] != '' && values['image'] != 'none'){ - if (!$('#image_'+idItem).length) { - if(values['label_position'] == 'left'){ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:right;'); - } else if(values['label_position'] == 'right'){ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:left;'); - } else{ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png"); - } - - + $('#'+idItem).append($image); - } - + if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){ $("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('height'); @@ -382,15 +355,11 @@ function update_button_palette_callback() { else{ $("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('height'); - $("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight); $("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight); $("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px'); - $("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px'); - - + $("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px'); } - } else{ $("#image_" + idItem).removeAttr('width'); @@ -401,7 +370,6 @@ function update_button_palette_callback() { $("#image_" + idItem).css('height', '70px'); $("#image_" + idItem).remove(); } - } else { $("#image_" + idItem).removeAttr('width'); @@ -411,14 +379,9 @@ function update_button_palette_callback() { $("#image_" + idItem).css('width', values['width'] + 'px'); $("#image_" + idItem).css('height', values['height'] + 'px'); } - } - - - break; case 'static_graph': - if($('input[name=width]').val() == ''){ alert('Undefined width'); return false; @@ -433,10 +396,8 @@ function update_button_palette_callback() { } $("#text_" + idItem).html(values['label']); - + if(values['show_statistics'] == 1){ - - if ((values['width'] == 0) || (values['height'] == 0)) { $("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('height'); @@ -445,7 +406,6 @@ function update_button_palette_callback() { $("#image_" + idItem).css('width', '520px'); $("#image_" + idItem).css('height', '80px'); $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); - } else { $("#image_" + idItem).removeAttr('width'); @@ -455,50 +415,35 @@ function update_button_palette_callback() { $("#image_" + idItem).css('width', values['width'] + 'px'); $("#image_" + idItem).css('height', values['height'] + 'px'); $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); - } - + } } else{ - if ((values['width'] == 0) || (values['height'] == 0)) { - if(values['image'] != '' && values['image'] != 'none'){ - if (!$('#image_'+idItem).length) { - if(values['label_position'] == 'left'){ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:right;'); - } else if(values['label_position'] == 'right'){ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png") .attr('style','float:left;'); - } else{ - var $image = $('') .attr('id', 'image_' + idItem) .attr('class', 'image') .attr('src', 'images/console/icons/'+values["image"]+".png"); - } - - $('#'+idItem).append($image); - } - - + if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){ $("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('height'); @@ -510,15 +455,11 @@ function update_button_palette_callback() { else{ $("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('height'); - $("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight); $("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight); $("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px'); - $("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px'); - - + $("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px'); } - } else{ $("#image_" + idItem).removeAttr('width'); @@ -529,7 +470,6 @@ function update_button_palette_callback() { $("#image_" + idItem).css('height', '70px'); $("#image_" + idItem).remove(); } - } else { $("#image_" + idItem).removeAttr('width'); @@ -539,9 +479,7 @@ function update_button_palette_callback() { $("#image_" + idItem).css('width', values['width'] + 'px'); $("#image_" + idItem).css('height', values['height'] + 'px'); } - } - break; case 'percentile_bar': case 'percentile_item': @@ -549,13 +487,15 @@ function update_button_palette_callback() { alert('Undefined width'); return false; } + if($('input[name=height_percentile]').val() == ''){ alert('Undefined height'); return false; } - + $("#text_" + idItem).html(values['label']); $("#image_" + idItem).attr("src", "images/spinner.gif"); + if (values['type_percentile'] == 'bubble') { setPercentileBubble(idItem, values); } @@ -568,7 +508,7 @@ function update_button_palette_callback() { else { setPercentileBar(idItem, values); } - + break; case 'module_graph': if($('#dir_items').html() == 'horizontal'){ @@ -801,6 +741,10 @@ function readFields() { values['label'] = $("input[name=label]").val(); var text = tinymce.get('text-label').getContent(); values['label'] = text; + + if ($("input[name=percentile_label]").val().length > 0) + values['label'] = $("input[name=percentile_label]").val(); + values['line-height'] = $("#text-label_ifr").contents().find("p").css('line-height'); values['type_graph'] = $("select[name=type_graph]").val(); values['image'] = $("select[name=image]").val(); @@ -2479,7 +2423,6 @@ function setPercentileCircular (id_data, values) { width_percentile = values['width_percentile']; var parameter = Array(); - parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_value"}); parameter.push ({name: "id_element", value: id_data}); @@ -2514,7 +2457,7 @@ function setPercentileCircular (id_data, values) { else { value_text = module_value + " " + unit_text; } - + $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/circular-progress-bar.png'); if($('#text-width_percentile').val() == 0){ $("#" + id_data + " img").css('width', '130px'); @@ -2524,12 +2467,12 @@ function setPercentileCircular (id_data, values) { $("#" + id_data + " img").css('width', $('#text-width_percentile').val()+'px'); $("#" + id_data + " img").css('height', $('#text-width_percentile').val()+'px'); } - + if($('#'+id_data+' table').css('float') == 'right' || $('#'+id_data+ ' table').css('float') == 'left'){ - $('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2); + $('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2); } else{ - $('#'+id_data+ ' img').css('margin-left',parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2); + $('#'+id_data+ ' img').css('margin-left',parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2); } } }); @@ -3835,14 +3778,12 @@ function updateDB_visual(type, idElement , values, event, top, left) { case 'clock': case 'auto_sla_graph': case 'donut_graph': - - if ((typeof(values['mov_left']) != 'undefined') && - (typeof(values['mov_top']) != 'undefined')) { + if ((typeof(values['absolute_left']) != 'undefined') && + (typeof(values['absolute_top']) != 'undefined')) { $("#" + idElement).css('top', '0px').css('top', top + 'px'); $("#" + idElement).css('left', '0px').css('left', left + 'px'); } - else if ((typeof(values['absolute_left']) != 'undefined') && - (typeof(values['absolute_top']) != 'undefined')) { + else{ $("#" + idElement).css('top', '0px').css('top', top + 'px'); $("#" + idElement).css('left', '0px').css('left', left + 'px'); } @@ -3952,7 +3893,6 @@ function updateDB(type, idElement , values, event) { parameter.push({name: key, value: val}); }); - switch (type) { // -- line_item -- case 'handler_start': diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 19d46d9769..d8902f2bc0 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -1208,21 +1208,21 @@ $(".logo_preview").click (function(e) { switch (e.target.id) { case 'button-custom_logo_preview': icon_name = $("select#custom_logo option:selected").val(); - icon_path = "images/custom_logo/" + icon_name; + icon_path = "images/custom_logo/" + icon_name; options.grayed = true; break; case 'button-custom_logo_white_bg_preview': icon_name = $("select#custom_logo_white_bg option:selected").val(); - icon_path = "images/custom_logo/" + icon_name; + icon_path = "images/custom_logo/" + icon_name; break; case 'button-custom_logo_login_preview': icon_name = $("select#custom_logo_login option:selected").val(); - icon_path = "images/custom_logo_login/" + icon_name; + icon_path = "images/custom_logo_login/" + icon_name; options.grayed = true; break; case 'button-custom_splash_login_preview': icon_name = $("select#custom_splash_login option:selected").val(); - icon_path = "images/custom_splash_login/" + icon_name; + icon_path = "images/custom_splash_login/" + icon_name; options.title = ""; break; case 'button-custom_docs_logo_preview': diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index 7ba51d3791..a2b666f25f 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -175,7 +175,7 @@ if ($id_profile || $new_profile) { $vconsole_management = (bool) $profile["vconsole_management"]; $id_audit = db_pandora_audit("User management", - "Edit profile ". $name); + "Edit profile ". io_safe_output($name)); enterprise_include_once('include/functions_audit.php'); $info = 'Name: ' . $name . diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index c009da746f..597fb4e7ba 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -66,40 +66,19 @@ $id_profile = (int) get_parameter ('id'); // Profile deletion if ($delete_profile) { - - $count_users_admin_in_profile = db_get_value_sql(" - SELECT COUNT(*) - FROM tusuario - WHERE is_admin = 1 AND id_user IN ( - SELECT id_usuario - FROM tusuario_perfil - WHERE id_perfil = " . $id_profile . ")"); - - if ($count_users_admin_in_profile >= 1) { - ui_print_error_message( - __('Unsucessful delete profile. Because the profile is used by some admin users.')); + // Delete profile + $profile = db_get_row('tperfil', 'id_perfil', $id_profile); + $ret = profile_delete_profile_and_clean_users ($id_profile); + if ($ret === false) { + ui_print_error_message(__('There was a problem deleting the profile')); } else { - // Delete profile - $profile = db_get_row('tperfil', 'id_perfil', $id_profile); - $sql = sprintf ('DELETE FROM tperfil WHERE id_perfil = %d', $id_profile); - $ret = db_process_sql ($sql); - if ($ret === false) { - ui_print_error_message(__('There was a problem deleting the profile')); - } - else { - db_pandora_audit("Profile management", - "Delete profile ". $profile['name']); - - ui_print_success_message(__('Successfully deleted')); - } - - //Delete profile from user data - $sql = sprintf ('DELETE FROM tusuario_perfil WHERE id_perfil = %d', $id_profile); - db_process_sql ($sql); - - $id_profile = 0; + db_pandora_audit("Profile management", + "Delete profile ". io_safe_output($profile['name'])); + ui_print_success_message(__('Successfully deleted')); } + + $id_profile = 0; } // Store the variables when create or update @@ -208,7 +187,7 @@ if ($update_profile) { "'.get_product_name().' Management":"'.$pandora_management.'"}'; db_pandora_audit("User management", - "Update profile ". $name, false, false, $info); + "Update profile ".io_safe_output($name), false, false, $info); ui_print_success_message(__('Successfully updated')); } @@ -255,7 +234,7 @@ if ($create_profile) { "'.get_product_name().' Management":"'.$pandora_management.'"}'; db_pandora_audit("User management", - "Created profile ". $name, false, false, $info); + "Created profile ". io_safe_output($name), false, false, $info); } else { ui_print_error_message(__('There was a problem creating this profile')); diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 91a3ddb115..8500166413 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -32,6 +32,7 @@ $append_tab_filter = (bool)get_parameter('append_tab_filter', 0); $create_filter_cf = (bool)get_parameter('create_filter_cf', 0); $update_filter_cf = (bool)get_parameter('update_filter_cf', 0); $delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0); +$change_name_filter = (bool)get_parameter('change_name_filter', 0); if ($get_custom_fields_data){ $name_custom_fields = get_parameter("name_custom_fields", 0); @@ -40,7 +41,6 @@ if ($get_custom_fields_data){ return; } - if($build_table_custom_fields){ $order = get_parameter("order", ''); $length = get_parameter("length", 20); @@ -237,6 +237,7 @@ if($build_table_child_custom_fields){ $id_agent = get_parameter("id_agent", 0); $id_server = get_parameter("id_server", 0); $module_search = str_replace('amp;', '',get_parameter("module_search", '')); + $module_status = get_parameter("module_status", 0); if(!$id_server || !$id_agent){ return false; @@ -246,6 +247,46 @@ if($build_table_child_custom_fields){ $name_where = " AND tam.nombre LIKE '%" . $module_search . "%'"; } + //filter by status module + $and_module_status = ""; + if(is_array($module_status)){ + if(!in_array(-1, $module_status)){ + if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status)){ + if(count($module_status) > 0){ + $and_module_status = " AND ( "; + foreach ($module_status as $key => $value) { + $and_module_status .= ($key != 0) + ? " OR (" + : " ("; + switch ($value) { + default: + case AGENT_STATUS_NORMAL: + $and_module_status .= " tae.estado = 0 OR tae.estado = 300 ) "; + break; + case AGENT_STATUS_CRITICAL: + $and_module_status .= " tae.estado = 1 OR tae.estado = 100 ) "; + break; + case AGENT_STATUS_WARNING: + $and_module_status .= " tae.estado = 2 OR tae.estado = 200 ) "; + break; + case AGENT_STATUS_UNKNOWN: + $and_module_status .= " tae.estado = 3 ) "; + break; + case AGENT_STATUS_NOT_INIT: + $and_module_status .= " tae.estado = 4 OR tae.estado = 5 ) "; + break; + } + } + $and_module_status .= " ) "; + } + } + else{ + //not normal + $and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 "; + } + } + } + if (is_metaconsole()) { $server = metaconsole_get_connection_by_id ($id_server); metaconsole_connect($server); @@ -262,9 +303,10 @@ if($build_table_child_custom_fields){ INNER JOIN tagente_estado tae ON tam.id_agente_modulo = tae.id_agente_modulo WHERE tam.id_agente = %d - %s", + %s %s", $id_agent, - $name_where + $name_where, + $and_module_status ); $modules = db_get_all_rows_sql ($query); @@ -282,7 +324,7 @@ if($build_table_child_custom_fields){ $table_modules->head[5] = __('Status'); $table_modules->data = array(); - $status_agent = -1; + if(isset($modules) && is_array($modules)){ foreach ($modules as $key => $value) { $table_modules->data[$key][0] = $value['nombre']; @@ -311,9 +353,6 @@ if($build_table_child_custom_fields){ switch ($value['estado']) { case 0: case 300: - if($status_agent != 1 && $status_agent != 2 && $status_agent != 3){ - $status_agent = 0; - } $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_normal.png', true, @@ -324,7 +363,6 @@ if($build_table_child_custom_fields){ break; case 1: case 100: - $status_agent = 1; $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_critical.png', true, @@ -335,10 +373,6 @@ if($build_table_child_custom_fields){ break; case 2: case 200: - if($status_agent != 1){ - $status_agent = 2; - } - $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_warning.png', true, @@ -348,10 +382,6 @@ if($build_table_child_custom_fields){ ); break; case 3: - if($status_agent != 1 && $status_agent != 2){ - $status_agent = 3; - } - $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_maintenance.png', true, @@ -362,9 +392,6 @@ if($build_table_child_custom_fields){ break; case 4: case 5: - if($status_agent == -1 || $status_agent == 4){ - $status_agent = 5; - } $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_informational.png', true, @@ -374,10 +401,6 @@ if($build_table_child_custom_fields){ ); break; default: - if($status_agent != 1 && $status_agent != 2 && $status_agent != 3){ - $status_agent = 0; - } - $table_modules->data[$key][5] = html_print_image( 'images/status_sets/default/severity_normal.png', true, @@ -390,6 +413,8 @@ if($build_table_child_custom_fields){ } } + $status_agent = agents_get_status($id_agent, true); + if (is_metaconsole()) { metaconsole_restore_db(); } @@ -433,17 +458,19 @@ if($build_table_save_filter){ $table->id = 'save_filter_form'; $table->width = '100%'; $table->class = 'databox'; - + $array_filters = get_filters_custom_fields_view(0, true); + $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_select( $array_filters, 'id_name', '', '', '', '', true, false, true, '', false ); + $table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true); - - echo "
"; + + echo ""; html_print_table($table); echo "
"; } @@ -462,7 +489,16 @@ if($append_tab_filter){ echo "
"; $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); - $table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); + + $table->data[0][2] = __('Group'); + $table->data[0][3] = html_print_select_groups( + $config['id_user'], 'AR', true, 'group_search_cr', + 0, '', '', '0', true, false, + false, '', false, '', false, false, + 'id_grupo', false + ); + + $table->data[0][4] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); } else{ echo "
"; @@ -470,12 +506,22 @@ if($append_tab_filter){ $array_filters = get_filters_custom_fields_view(0, true); $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_select( - $array_filters, 'id_name', - '', '', __('None'), -1, - true, false, true, '', false + $array_filters, 'id_name', '', + 'filter_name_change_group(this.value)', + __('None'), -1, true, false, true, + '', false ); + + $table->data[1][0] = __('Group'); + $table->data[1][1] = html_print_select_groups( + $config['id_user'], 'AR', true, 'group_search_up', + $group, '', '', '0', true, false, + false, '', false, '', false, false, + 'id_grupo', false + ); + $table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true); - $table->data[0][3] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); + $table->data[1][2] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); } html_print_table($table); @@ -491,6 +537,7 @@ if($create_filter_cf){ //initialize vars $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $name_filter = get_parameter("name_filter", ''); + $group_search = get_parameter("group_search", 0); //check that the name is not empty if($name_filter == ''){ @@ -529,11 +576,14 @@ if($create_filter_cf){ //insert $values = array(); $values['name'] = $name_filter; + $values['group_search'] = $group_search; $values['id_group'] = $filters['group']; $values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_status'] = json_encode($filters['id_status']); $values['module_search'] = $filters['module_search']; + $values['module_status'] = json_encode($filters['module_status']); + $values['recursion'] = $filters['recursion']; $insert = db_process_sql_insert('tagent_custom_fields_filter', $values); @@ -565,6 +615,7 @@ if($update_filter_cf){ //initialize vars $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $id_filter = get_parameter("id_filter", ''); + $group_search = get_parameter("group_search", 0); //check selected filter if($id_filter == -1){ @@ -595,10 +646,13 @@ if($update_filter_cf){ //array values update $values = array(); $values['id_group'] = $filters['group']; + $values['group_search'] = $group_search; $values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_status'] = json_encode($filters['id_status']); $values['module_search'] = $filters['module_search']; + $values['module_status'] = json_encode($filters['module_status']); + $values['recursion'] = $filters['recursion']; //update $update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition); @@ -669,7 +723,17 @@ if($delete_filter_cf){ return; } +if($change_name_filter){ + $id_filter = get_parameter("id_filter", 0); + if(isset($id_filter)){ + $res = get_group_filter_custom_field_view($id_filter); + echo json_encode($res); + return; + } + + return json_encode(false); +} -} \ No newline at end of file +} diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 417b8f2003..75491d1fa2 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -472,16 +472,17 @@ if ($list_modules) { $sort = get_parameter('sort', 'none'); $selected = 'border: 1px solid black;'; + $order[] = array('field' => 'tmodule_group.name', 'order' => 'ASC'); switch ($sortField) { case 'type': switch ($sort) { case 'up': $selectTypeUp = $selected; - $order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC'); + $order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC'); break; case 'down': $selectTypeDown = $selected; - $order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC'); + $order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC'); break; } break; @@ -489,11 +490,11 @@ if ($list_modules) { switch ($sort) { case 'up': $selectNameUp = $selected; - $order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC'); + $order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; - $order = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC'); + $order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC'); break; } break; @@ -501,11 +502,11 @@ if ($list_modules) { switch ($sort) { case 'up': $selectStatusUp = $selected; - $order = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => ''); + $order[] = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => ''); break; case 'down': $selectStatusDown = $selected; - $order = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => ''); + $order[] = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => ''); break; } break; @@ -513,11 +514,11 @@ if ($list_modules) { switch ($sort) { case 'up': $selectLastContactUp = $selected; - $order = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC'); + $order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC'); break; case 'down': $selectLastContactDown = $selected; - $order = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC'); + $order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC'); break; } break; @@ -533,7 +534,7 @@ if ($list_modules) { $selectLastContactUp = ''; $selectLastContactDown = ''; - $order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC'); + $order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC'); break; } @@ -588,7 +589,20 @@ if ($list_modules) { } //Count monitors/modules - $order_sql = $order['field'] . " " . $order['order']; + + // Build the order sql + $first = true; + foreach ($order as $ord) { + if ($first) { + $first = false; + } + else { + $order_sql .= ','; + } + + $order_sql .= $ord['field'].' '.$ord['order']; + } + $sql_condition = "FROM tagente_modulo $tags_join INNER JOIN tagente_estado diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 2af9bf6d9e..a68d906918 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -25,13 +25,12 @@ if ($get_image_path_status){ $only_src = get_parameter("only_src", 0); $result = array(); - + $result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src); $result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src); $result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src); - $result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src); $result['normal'] = html_print_image($img_src . '.png', true, '', $only_src); - + echo json_encode($result); return; } diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index de84850890..6d5a5abcc8 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -72,18 +72,14 @@ switch($info) { if (isInACL($ipOrigin)) { if (empty($apiPassword) || (!empty($apiPassword) && $api_password === $apiPassword)) { $user_in_db = process_user_login($user, $password, true); - if ($user_in_db !== false) { $config['id_user'] = $user_in_db; $correctLogin = true; - - //XXXX - session_start(); + + if (session_status() === PHP_SESSION_NONE) session_start(); $_SESSION["id_usuario"] = $user; session_write_close(); - file_put_contents(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id(), $user); - } else { $no_login_msg = "Incorrect user credentials"; @@ -186,11 +182,6 @@ if ($correctLogin) { returnError('no_exist_operation', $returnType); } } - - //XXXXX - if (file_exists(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id())) { - unlink(session_save_path() . DIRECTORY_SEPARATOR . "pansess_" . session_id()); - } } else { // TODO: Implement a new switch in config to enable / disable diff --git a/pandora_console/include/auth/dev.php b/pandora_console/include/auth/dev.php deleted file mode 100644 index 8c5774daaa..0000000000 --- a/pandora_console/include/auth/dev.php +++ /dev/null @@ -1,160 +0,0 @@ - - - -Pandora FMS - The Flexible Monitoring System - Console error - - - - - - - - - - - -
-
-
-

You cannot access this file

-
- -
-
- ERROR: - You can\'t access this file directly! -
-
-
- - -'); -} - -$config["user_can_update_password"] = false; -$config["admin_can_add_user"] = false; -$config["admin_can_delete_user"] = false; -$config["admin_can_disable_user"] = false; - -global $dev_cache; //This variable needs to be globalized because this file is called from within a function and thus local - -//DON'T USE THIS IF YOU DON'T KNOW WHAT YOU'RE DOING -die ("This is a very dangerous authentication scheme. Only use for programming in case you should uncomment this line"); - -/** - * process_user_login accepts $login and $pass and handles it according to current authentication scheme - * - * @param string $login - * @param string $pass - * - * @return mixed False in case of error or invalid credentials, the username in case it's correct. - */ -function process_user_login ($login, $pass) { - return false; //Error - return $login; //Good -} - -/** - * Checks if a user is administrator. - * - * @param string User id. - * - * @return bool True is the user is admin - */ -function is_user_admin ($user) { - return true; //User is admin - return false; //User isn't -} - -/** - * Check is a user exists in the system - * - * @param string User id. - * - * @return bool True if the user exists. - */ -function is_user ($id_user) { - return true; - return false; -} - -/** - * Gets the users real name - * - * @param string User id. - * - * @return string The users full name - */ -function get_user_fullname ($id_user) { - return "admin"; - return ""; - return false; -} - -/** - * Gets the users email - * - * @param string User id. - * - * @return string The users email address - */ -function get_user_email ($id_user) { - return "test@example.com"; - return ""; - return false; -} - -/** - * Get a list of all users in an array [username] => real name - * - * @param string Field to order by (id_usuario, nombre_real or fecha_registro) - * - * @return array An array of users - */ -function get_users ($order = "nombre_real") { - return array ("admin" => "Admini Strator"); -} - -/** - * Sets the last login for a user - * - * @param string User id - */ -function process_user_contact ($id_user) { - //void -} - -/** - * Deletes the user - * - * @param string User id - */ -function delete_user ($id_user) { - return true; - return false; -} - -//Reference the global use authorization error to last ldap error. -$config["auth_error"] = &$dev_cache["auth_error"]; -?> diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 794ef5684f..f73d146424 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -13,17 +13,8 @@ // GNU General Public License for more details. // Global & session manageme + session_id($_REQUEST["session_id"]); -if (file_exists(session_save_path() . "/pansess_" . session_id()) ) { - $user = file_get_contents(session_save_path() . "/pansess_" . session_id()); -} -session_start(); -if (isset($user)) { - $_SESSION["id_usuario"] = $user; -} -session_write_close(); - - require_once ('config.php'); require_once ($config['homedir'] . '/include/auth/mysql.php'); @@ -132,7 +123,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) { $params['height'], $params['water_mark_url'], $params['font'], - $params['font_size'], + $config['font_size'], $params['legend_position'], $params['colors'], $params['hide_labels'] @@ -151,7 +142,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) { $params['water_mark_url'], $params['homedir'], $params['font'], - $params['font_size'], + $config['font_size'], $params['from_ux'], $params['from_wux'], $params['backgroundColor'], @@ -165,7 +156,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) { $params['height'], $params['water_mark_url'], $params['font'], - $params['font_size'], + $config['font_size'], $params['backgroundColor'], $params['tick_color'], $params['val_min'], @@ -185,7 +176,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) { '', $params['water_mark'], $params['font'], - $params['font_size'], + $config['font_size'], $params['unit'], $params['ttl'], $params['homeurl'], @@ -211,7 +202,9 @@ if (file_exists ('languages/'.$user_language.'.mo')) { $params['id_agent'], $params['full_legend_daterray'], $params['not_interactive'], - 1 + $params['ttl'], + $params['widgets'], + $params['show'] ); break; default: @@ -222,6 +215,16 @@ if (file_exists ('languages/'.$user_language.'.mo')) { $config['font_size'] = $aux_font_size; ?> + + diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ee7ab047b5..1f6c20bbc6 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 = 'PC181121'; +$build_version = 'PC181205'; $pandora_version = 'v7.0NG.729'; // Do not overwrite default timezone set if defined. @@ -176,7 +176,7 @@ date_default_timezone_set("Europe/Madrid"); ////////////////////////////////////// require_once ($config["homedir"].'/include/load_session.php'); -if (session_id() == '') session_start(); +if (session_status() === PHP_SESSION_NONE) session_start(); config_process_config(); config_prepare_session(); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ff2ce52deb..d36c68ada2 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1787,10 +1787,7 @@ function check_login ($output = true) { } else { require_once($config["homedir"].'/mobile/include/user.class.php'); - if(session_id() == '') { - session_start (); - } - session_write_close (); + if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $id_user = $user->getIdUser(); @@ -3323,12 +3320,13 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal . ' "' . $session_id . '"' . ' "' . $params['return_img_base_64'] . '"'; - $result = exec($cmd); + exec($cmd, $result); + $img_content = join("\n", $result); if($params['return_img_base_64']){ // To be used in alerts $width_img = 500; - return $result; + return $img_content; } else{ // to be used in PDF files @@ -3372,7 +3370,7 @@ function get_copyright_notice () { */ function generate_csrf_code() { // Start session to make this var permanent - session_start(); + if (session_status() === PHP_SESSION_NONE) session_start(); $_SESSION['csrf_code'] = md5(uniqid(mt_rand(), true)); session_write_close(); return $_SESSION['csrf_code']; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 16bdb974c6..d69a27d8fe 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -361,11 +361,13 @@ function agents_get_agents ($filter = false, $fields = false, break; case AGENT_STATUS_NOT_NORMAL: $status_sql = "( - critical_count > 0 - OR warning_count > 0 - OR unknown_count > 0 - OR total_count = 0 + normal_count <> total_count OR total_count = notinit_count)"; + //The AGENT_STATUS_NOT_NORMAL filter must show all agents that are not in normal status + /*"( + normal_count <> total_count + AND + (normal_count + notinit_count) <> total_count)";*/ break; case AGENT_STATUS_NOT_INIT: $status_sql = "( diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index dbe18fe4d7..57677b8dea 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1845,9 +1845,9 @@ function get_group_alerts($id_group, $filter = '', $options = false, } } - $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name'; + $selectText = 'DISTINCT talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name'; if ($count !== false) { - $selectText = 'COUNT(talert_template_modules.id) AS count'; + $selectText = 'COUNT(DISTINCT talert_template_modules.id) AS count'; } $sql = sprintf ("SELECT %s @@ -1871,7 +1871,7 @@ function get_group_alerts($id_group, $filter = '', $options = false, return $alerts[0]['count']; } else { - return $alerts; + return $alerts; } } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3cc0e58a67..53479ae7ed 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -30,6 +30,8 @@ include_once($config['homedir'] . "/include/functions_network_components.php"); include_once($config['homedir'] . "/include/functions_netflow.php"); include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_event_responses.php"); enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_agents.php'); @@ -1410,10 +1412,6 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) { returnError('forbidden', 'string'); return; } - - if (defined ('METACONSOLE')) { - return; - } $values = array(); @@ -1429,6 +1427,11 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) { $resultOrId = false; if ($other['data'][0] != '') { $resultOrId = db_process_sql_insert('tconfig_os', $values); + + if ($resultOrId) + echo __('Success creating OS'); + else + echo __('Error creating OS'); } } @@ -1436,10 +1439,6 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) { function api_set_update_os($id_os, $thrash2, $other, $thrash3) { global $config; - if (defined ('METACONSOLE')) { - return; - } - if (!check_acl($config['id_user'], 0, "AW")) { returnError('forbidden', 'string'); return; @@ -1457,7 +1456,10 @@ function api_set_update_os($id_os, $thrash2, $other, $thrash3) { if ($other['data'][0] != '') { - $result = db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os)); + if (db_process_sql_update('tconfig_os', $values, array('id_os' => $id_os))) + echo __('Success updating OS'); + else + echo __('Error updating OS'); } } @@ -8721,9 +8723,213 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) { returnData('string', array('type' => 'string', 'data' => __('Delete user profile.'))); } +/** + * List all user profiles. + * + * @param Reserved $thrash1 + * @param Reserved $thrash2 + * @param Reserved $thrash3 + * @param string Return type (csv, json, string...) + * + * api.php?op=get&op2=user_profiles_info&return_type=json&apipass=1234&user=admin&pass=pandora + */ +function api_get_user_profiles_info ($thrash1, $thrash2, $thrash3, $returnType) { + global $config; + + if (!check_acl($config['id_user'], 0, "PM")){ + returnError('forbidden', 'string'); + return; + } + + $profiles = db_get_all_rows_filter( + 'tperfil', + array(), + array( + "id_perfil", + "name", + "incident_view as IR", + "incident_edit as IW", + "incident_management as IM", + "agent_view as AR", + "agent_edit as AW", + "agent_disable as AD", + "alert_edit as LW", + "alert_management as LM", + "user_management as UM", + "db_management as DM", + "event_view as ER", + "event_edit as EW", + "event_management as EM", + "report_view as RR", + "report_edit as RW", + "report_management as RM", + "map_view as MR", + "map_edit as MW", + "map_management as MM", + "vconsole_view as VR", + "vconsole_edit as VW", + "vconsole_management as VM", + "pandora_management as PM" + ) + ); + + if ($profiles === false) { + returnError('error_list_profiles', __('Error retrieving profiles')); + } else { + returnData($returnType, array('type' => 'array', 'data' => $profiles)); + } +} + +/** + * Create an user profile. + * + * @param Reserved $thrash1 + * @param Reserved $thrash2 + * @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM + * @param string Return type (csv, json, string...) + * + * api.php?op=set&op2=create_user_profile_info&return_type=json&other=API_profile%7C1%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora + */ +function api_set_create_user_profile_info ($thrash1, $thrash2, $other, $returnType) { + global $config; + + if (!check_acl($config['id_user'], 0, "PM")){ + returnError('forbidden', 'string'); + return; + } + + $values = array( + 'name' => (string)$other['data'][0], + 'incident_view' => (bool)$other['data'][1] ? 1 : 0, + 'incident_edit' => (bool)$other['data'][2] ? 1 : 0, + 'incident_management' => (bool)$other['data'][3] ? 1 : 0, + 'agent_view' => (bool)$other['data'][4] ? 1 : 0, + 'agent_edit' => (bool)$other['data'][5] ? 1 : 0, + 'agent_disable' => (bool)$other['data'][6] ? 1 : 0, + 'alert_edit' => (bool)$other['data'][7] ? 1 : 0, + 'alert_management' => (bool)$other['data'][8] ? 1 : 0, + 'user_management' => (bool)$other['data'][9] ? 1 : 0, + 'db_management' => (bool)$other['data'][10] ? 1 : 0, + 'event_view' => (bool)$other['data'][11] ? 1 : 0, + 'event_edit' => (bool)$other['data'][12] ? 1 : 0, + 'event_management' => (bool)$other['data'][13] ? 1 : 0, + 'report_view' => (bool)$other['data'][14] ? 1 : 0, + 'report_edit' => (bool)$other['data'][15] ? 1 : 0, + 'report_management' => (bool)$other['data'][16] ? 1 : 0, + 'map_view' => (bool)$other['data'][17] ? 1 : 0, + 'map_edit' => (bool)$other['data'][18] ? 1 : 0, + 'map_management' => (bool)$other['data'][19] ? 1 : 0, + 'vconsole_view' => (bool)$other['data'][20] ? 1 : 0, + 'vconsole_edit' => (bool)$other['data'][21] ? 1 : 0, + 'vconsole_management' => (bool)$other['data'][22] ? 1 : 0, + 'pandora_management' => (bool)$other['data'][23] ? 1 : 0 + ); + + $return = db_process_sql_insert('tperfil', $values); + + if ($return === false) { + returnError('error_create_user_profile_info', __('Error creating user profile')); + } else { + returnData($returnType, array('type' => 'array', 'data' => 1)); + } +} + +/** + * Update an user profile. + * + * @param int Profile id + * @param Reserved $thrash1 + * @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM + * @param string Return type (csv, json, string...) + * + * api.php?op=set&op2=update_user_profile_info&return_type=json&id=6&other=API_profile_updated%7C%7C%7C%7C1%7C1%7C1%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora + */ +function api_set_update_user_profile_info ($id_profile, $thrash1, $other, $returnType) { + global $config; + + if (!check_acl($config['id_user'], 0, "PM")){ + returnError('forbidden', 'string'); + return; + } + + $profile = db_get_row ('tperfil', 'id_perfil', $id_profile); + if ($profile === false) { + returnError('id_not_found', 'string'); + return; + } + + $values = array( + 'name' => $other['data'][0] == '' ? $profile['name'] : (string)$other['data'][0], + 'incident_view' => $other['data'][1] == '' ? $profile['incident_view'] : (bool)$other['data'][1] ? 1 : 0, + 'incident_edit' => $other['data'][2] == '' ? $profile['incident_edit'] : (bool)$other['data'][2] ? 1 : 0, + 'incident_management' => $other['data'][3] == '' ? $profile['incident_management'] : (bool)$other['data'][3] ? 1 : 0, + 'agent_view' => $other['data'][4] == '' ? $profile['agent_view'] : (bool)$other['data'][4] ? 1 : 0, + 'agent_edit' => $other['data'][5] == '' ? $profile['agent_edit'] : (bool)$other['data'][5] ? 1 : 0, + 'agent_disable' => $other['data'][6] == '' ? $profile['agent_disable'] : (bool)$other['data'][6] ? 1 : 0, + 'alert_edit' => $other['data'][7] == '' ? $profile['alert_edit'] : (bool)$other['data'][7] ? 1 : 0, + 'alert_management' => $other['data'][8] == '' ? $profile['alert_management'] : (bool)$other['data'][8] ? 1 : 0, + 'user_management' => $other['data'][9] == '' ? $profile['user_management'] : (bool)$other['data'][9] ? 1 : 0, + 'db_management' => $other['data'][10] == '' ? $profile['db_management'] : (bool)$other['data'][10] ? 1 : 0, + 'event_view' => $other['data'][11] == '' ? $profile['event_view'] : (bool)$other['data'][11] ? 1 : 0, + 'event_edit' => $other['data'][12] == '' ? $profile['event_edit'] : (bool)$other['data'][12] ? 1 : 0, + 'event_management' => $other['data'][13] == '' ? $profile['event_management'] : (bool)$other['data'][13] ? 1 : 0, + 'report_view' => $other['data'][14] == '' ? $profile['report_view'] : (bool)$other['data'][14] ? 1 : 0, + 'report_edit' => $other['data'][15] == '' ? $profile['report_edit'] : (bool)$other['data'][15] ? 1 : 0, + 'report_management' => $other['data'][16] == '' ? $profile['report_management'] : (bool)$other['data'][16] ? 1 : 0, + 'map_view' => $other['data'][17] == '' ? $profile['map_view'] : (bool)$other['data'][17] ? 1 : 0, + 'map_edit' => $other['data'][18] == '' ? $profile['map_edit'] : (bool)$other['data'][18] ? 1 : 0, + 'map_management' => $other['data'][19] == '' ? $profile['map_management'] : (bool)$other['data'][19] ? 1 : 0, + 'vconsole_view' => $other['data'][20] == '' ? $profile['vconsole_view'] : (bool)$other['data'][20] ? 1 : 0, + 'vconsole_edit' => $other['data'][21] == '' ? $profile['vconsole_edit'] : (bool)$other['data'][21] ? 1 : 0, + 'vconsole_management' => $other['data'][22] == '' ? $profile['vconsole_management'] : (bool)$other['data'][22] ? 1 : 0, + 'pandora_management' => $other['data'][23] == '' ? $profile['pandora_management'] : (bool)$other['data'][23] ? 1 : 0 + ); + + $return = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile)); + + if ($return === false) { + returnError('error_update_user_profile_info', __('Error updating user profile')); + } else { + returnData($returnType, array('type' => 'array', 'data' => 1)); + } +} + +/** + * Delete an user profile. + * + * @param int Profile id + * @param Reserved $thrash1 + * @param Reserved $thrash2 + * @param string Return type (csv, json, string...) + * + * api.php?op=set&op2=delete_user_profile_info&return_type=json&id=7&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora + */ +function api_set_delete_user_profile_info ($id_profile, $thrash1, $thrash2, $returnType) { + global $config; + + if (!check_acl($config['id_user'], 0, "PM")){ + returnError('forbidden', 'string'); + return; + } + + $profile = db_get_value ('id_perfil', 'tperfil', 'id_perfil', $id_profile); + if ($profile === false) { + returnError('id_not_found', 'string'); + return; + } + + $return = profile_delete_profile_and_clean_users($id_profile); + + if ($return === false) { + returnError('error_delete_user_profile_info', __('Error deleting user profile')); + } else { + returnData($returnType, array('type' => 'array', 'data' => 1)); + } +} + /** * Create new incident in Pandora. - * + * * @param $thrash1 Don't use. * @param $thrash2 Don't use. * @param array $other it's array, $other as param is ;<description>; @@ -11468,6 +11674,159 @@ function api_get_modules_id_name_by_cluster_name ($cluster_name){ } + /** + * @param $trash1 + * @param $trash2 + * @param mixed $trash3 + * @param $returnType + * Example: + * api.php?op=get&op2=event_responses&return_type=csv&apipass=1234&user=admin&pass=pandora + */ +function api_get_event_responses($trash1, $trash2, $trash3, $returnType) { + global $config; + + // Error if user cannot read event responses. + if (!check_acl($config['id_user'], 0, "PM")) { + returnError('forbidden', $returnType); + return; + } + + $responses = event_responses_get_responses(); + if (empty($responses)) { + returnError('no_data_to_show', $returnType); + return; + } + + returnData ($returnType, array('type' => 'array', 'data' => $responses)); +} + + /** + * @param $id_response + * @param $trash2 + * @param mixed $trash3 + * @param $returnType + * Example: + * api.php?op=set&op2=delete_event_response&id=7&apipass=1234&user=admin&pass=pandora + */ +function api_set_delete_event_response($id_response, $trash1, $trash2, $returnType) { + global $config; + + // Error if user cannot read event responses. + if (!check_acl($config['id_user'], 0, "PM")) { + returnError('forbidden', $returnType); + return; + } + + // Check if id exists + $event_group = db_get_value('id_group', 'tevent_response','id', $id_response); + if ($event_group === false) { + returnError('id_not_found', $returnType); + return; + } + + // Check user if can edit the module + if (!check_acl($config['id_user'], $event_group, "PM")) { + returnError('forbidden', $returnType); + return; + } + + $result = db_process_sql_delete('tevent_response', array('id' => $id_response)); + returnData ($returnType, array('type' => 'string', 'data' => $result)); +} + +/** + * @param $trash1 + * @param $trash2 + * @param mixed $other. Serialized params + * @param $returnType + * Example: + * api.php?op=set&op2=create_event_response&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora + */ +function api_set_create_event_response($trash1, $trash2, $other, $returnType) { + global $config; + + // Error if user cannot read event responses. + if (!check_acl($config['id_user'], 0, "PM")) { + returnError('forbidden', $returnType); + return; + } + + $values = array(); + $values['name'] = $other['data'][0]; + $values['description'] = $other['data'][1]; + $values['target'] = $other['data'][2]; + $values['type'] = $other['data'][3]; + $values['id_group'] = $other['data'][4]; + $values['modal_width'] = $other['data'][5]; + $values['modal_height'] = $other['data'][6]; + $values['new_window'] = $other['data'][7]; + $values['params'] = $other['data'][8]; + $values['server_to_exec'] = $other['data'][9]; + + // Error if user has not permission for the group. + if (!check_acl($config['id_user'], $values['id_group'], "PM")) { + returnError('forbidden', $returnType); + return; + } + + $return = event_responses_create_response($values) ? 1 : 0; + + returnData ($returnType, array('type' => 'string', 'data' => $return)); +} + +/** + * @param $id_response + * @param $trash2 + * @param mixed $other. Serialized params + * @param $returnType + * Example: + * api.php?op=set&op2=update_event_response&id=7&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora + */ +function api_set_update_event_response($id_response, $trash1, $other, $returnType) { + global $config; + + // Error if user cannot read event responses. + if (!check_acl($config['id_user'], 0, "PM")) { + returnError('forbidden', $returnType); + return; + } + + // Check if id exists + $event_response = db_get_row('tevent_response','id', $id_response); + if ($event_response === false) { + returnError('id_not_found', $returnType); + return; + } + + // Check user if can edit the module + if (!check_acl($config['id_user'], $event_response['id_group'], "PM")) { + returnError('forbidden', $returnType); + return; + } + + $values = array(); + $values['name'] = $other['data'][0] == '' ? $event_response['name'] : $other['data'][0]; + $values['description'] = $other['data'][1] == '' ? $event_response['description'] : $other['data'][1]; + $values['target'] = $other['data'][2] == '' ? $event_response['target'] : $other['data'][2]; + $values['type'] = $other['data'][3] == '' ? $event_response['type'] : $other['data'][3]; + $values['id_group'] = $other['data'][4] == '' ? $event_response['id_group'] : $other['data'][4]; + $values['modal_width'] = $other['data'][5] == '' ? $event_response['modal_width'] : $other['data'][5]; + $values['modal_height'] = $other['data'][6] == '' ? $event_response['modal_height'] : $other['data'][6]; + $values['new_window'] = $other['data'][7] == '' ? $event_response['new_window'] : $other['data'][7]; + $values['params'] = $other['data'][8] == '' ? $event_response['params'] : $other['data'][8]; + $values['server_to_exec'] = $other['data'][9] == '' ? $event_response['server_to_exec'] : $other['data'][9]; + + // Error if user has not permission for the group. + if (!check_acl($config['id_user'], $values['id_group'], "PM")) { + returnError('forbidden', $returnType); + return; + } + + $return = event_responses_update_response($id_response, $values) ? 1 : 0; + + returnData ($returnType, array('type' => 'string', 'data' => $return)); +} + function api_get_cluster_items ($cluster_id){ global $config; @@ -11512,8 +11871,142 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access = return false; } +function api_set_validate_traps ($id, $thrash2, $other, $thrash3) { + + if (defined ('METACONSOLE')) { + return; + } + + if($id == 'all'){ + $result = db_process_sql_update('ttrap',array('status' => 1)); + } + else{ + $result = db_process_sql_update('ttrap', + array('status' => 1), array('id_trap' => $id)); + } + + if (is_error($result)) { + // TODO: Improve the error returning more info + returnError('error_update_trap', __('Error in trap update.')); + } + else { + returnData('string', + array('type' => 'string', + 'data' => __('Validated traps.'))); + } + } + + function api_set_delete_traps ($id, $thrash2, $other, $thrash3) { + + if (defined ('METACONSOLE')) { + return; + } + + if($id == 'all'){ + $result = db_process_sql ('delete from ttrap'); + } + else{ + $result = db_process_sql_delete('ttrap',array('id_trap' => $id)); + } + + if (is_error($result)) { + // TODO: Improve the error returning more info + returnError('error_delete_trap', __('Error in trap delete.')); + } + else { + returnData('string', + array('type' => 'string', + 'data' => __('Deleted traps.'))); + } + } + + function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT id_grupo + FROM tgrupo WHERE nombre = "'.$other['data'].'"'); + + $group_id = db_get_all_rows_sql($sql); + + if (count($group_id) > 0 and $group_id !== false) { + $data = array('type' => 'array', 'data' => $group_id); + + returnData('csv', $data, ';'); + } + else { + returnError('error_group_name', 'No groups retrieved.'); + } + } + + function api_get_timezone($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "timezone"'); + + $timezone = db_get_all_rows_sql($sql); + + if (count($timezone) > 0 and $timezone !== false) { + + $data = array('type' => 'string', 'data' => $timezone); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_timezone', 'No timezone retrieved.'); + } + } - + function api_get_language($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "language"'); + + $language = db_get_all_rows_sql($sql); + + if (count($language) > 0 and $language !== false) { + + $data = array('type' => 'string', 'data' => $language); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_language', 'No language retrieved.'); + } + } + + function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "session_timeout"'); + + $language = db_get_all_rows_sql($sql); + + if (count($language) > 0 and $language !== false) { + + $data = array('type' => 'string', 'data' => $language); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_session_timeout', 'No session timeout retrieved.'); + } + } + + ?> diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 90b6ebaa4e..dcc038b620 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -191,7 +191,7 @@ function get_custom_fields_data ($custom_field_name) { } function agent_counters_custom_fields($filters){ - //filter by status + //filter by status agent $and_status = ""; if(is_array($filters['id_status'])){ if(!in_array(-1, $filters['id_status'])){ @@ -241,17 +241,100 @@ function agent_counters_custom_fields($filters){ } } + //filter by status module + $and_module_status = ""; + if(is_array($filters['module_status'])){ + if(!in_array(-1, $filters['module_status'])){ + if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['module_status'])){ + if(count($filters['module_status']) > 0){ + $and_module_status = " AND ( "; + foreach ($filters['module_status'] as $key => $value) { + $and_module_status .= ($key != 0) + ? " OR (" + : " ("; + switch ($value) { + default: + case AGENT_STATUS_NORMAL: + $and_module_status .= " tae.estado = 0 OR tae.estado = 300 ) "; + break; + case AGENT_STATUS_CRITICAL: + $and_module_status .= " tae.estado = 1 OR tae.estado = 100 ) "; + break; + case AGENT_STATUS_WARNING: + $and_module_status .= " tae.estado = 2 OR tae.estado = 200 ) "; + break; + case AGENT_STATUS_UNKNOWN: + $and_module_status .= " tae.estado = 3 ) "; + break; + case AGENT_STATUS_NOT_INIT: + $and_module_status .= " tae.estado = 4 OR tae.estado = 5 ) "; + break; + } + } + $and_module_status .= " ) "; + } + } + else{ + //not normal + $and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 "; + } + } + } + + //filters module + if($filters['module_search']){ + $and_module_search = 'AND nombre LIKE "%' . $filters['module_search'] . '%"'; + } + + $module_filter = ""; + if($and_module_search != '' || $and_module_status != ''){ + $module_filter = ' AND ( + SELECT count(*) AS n + FROM tagente_modulo tam + INNER JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + WHERE tam.id_agente=ta.id_agente + '. $and_module_search . ' ' . $and_module_status .' + ) > 0 '; + } + //filter group and check ACL groups $groups_and = ""; if (!users_can_manage_group_all("AR")) { - if(!$filters['group']){ - $id_groups = explode(", ", array_keys(users_get_groups())); + if($filters['group']){ + $user_groups = array_keys(users_get_groups()); + $id_groups = implode(", ", $user_groups); $groups_and = " AND (ta.id_grupo IN ($id_groups) OR tasg.id_group IN($id_groups))"; } } if($filters['group']){ - $groups_and = " AND (ta.id_grupo =". $filters['group']." OR tasg.id_group =". $filters['group'].")"; + //recursion check acl + if($filters['recursion']){ + $recursion_groups = groups_get_id_recursive($filters['group'], true); + if (!users_can_manage_group_all("AR")) { + if(isset($user_groups) && is_array($user_groups)){ + $groups_intersect = array_intersect($user_groups, $recursion_groups); + if(isset($groups_intersect) && is_array($groups_intersect)){ + $groups_intersect = implode(", ", $groups_intersect); + $groups_and = " AND (ta.id_grupo IN ($groups_intersect) OR tasg.id_group IN($groups_intersect))"; + } + else{ + return false; + } + } + else{ + return false; + } + } + else{ + $recursion_groups = implode(", ", $recursion_groups); + $groups_and = " AND (ta.id_grupo IN ($recursion_groups) OR tasg.id_group IN($recursion_groups))"; + } + } + else{ + $groups_and = " AND (ta.id_grupo =". $filters['group']." OR tasg.id_group =". $filters['group'].")"; + } } //filter custom data @@ -264,17 +347,6 @@ function agent_counters_custom_fields($filters){ //filter custom name $custom_field_name = $filters['id_custom_fields']; - //filters module - $module_filter = ""; - if($filters['module_search']){ - $module_filter = ' AND ( - SELECT count(*) AS n - FROM tagente_modulo - WHERE nombre LIKE "%' . $filters['module_search'] . '%" - AND id_agente=ta.id_agente - ) > 0 '; - } - if(is_metaconsole()){ $metaconsole_connections = metaconsole_get_connection_names(); // For all nodes @@ -385,36 +457,38 @@ function agent_counters_custom_fields($filters){ ); foreach ($result_meta as $k => $nodo) { - foreach ($nodo as $key => $value) { - //Sum counters total - $final_result['counters_total']['t_m_normal'] += $value['m_normal']; - $final_result['counters_total']['t_m_critical'] += $value['m_critical']; - $final_result['counters_total']['t_m_warning'] += $value['m_warning']; - $final_result['counters_total']['t_m_unknown'] += $value['m_unknown']; - $final_result['counters_total']['t_m_not_init'] += $value['m_not_init']; - $final_result['counters_total']['t_m_alerts'] += $value['m_alerts']; - $final_result['counters_total']['t_m_total'] += $value['m_total']; - $final_result['counters_total']['t_a_critical'] += $value['a_critical']; - $final_result['counters_total']['t_a_warning'] += $value['a_warning']; - $final_result['counters_total']['t_a_unknown'] += $value['a_unknown']; - $final_result['counters_total']['t_a_normal'] += $value['a_normal']; - $final_result['counters_total']['t_a_not_init'] += $value['a_not_init']; - $final_result['counters_total']['t_a_agents'] += $value['a_agents']; + if(isset($nodo) && is_array($nodo)){ + foreach ($nodo as $key => $value) { + //Sum counters total + $final_result['counters_total']['t_m_normal'] += $value['m_normal']; + $final_result['counters_total']['t_m_critical'] += $value['m_critical']; + $final_result['counters_total']['t_m_warning'] += $value['m_warning']; + $final_result['counters_total']['t_m_unknown'] += $value['m_unknown']; + $final_result['counters_total']['t_m_not_init'] += $value['m_not_init']; + $final_result['counters_total']['t_m_alerts'] += $value['m_alerts']; + $final_result['counters_total']['t_m_total'] += $value['m_total']; + $final_result['counters_total']['t_a_critical'] += $value['a_critical']; + $final_result['counters_total']['t_a_warning'] += $value['a_warning']; + $final_result['counters_total']['t_a_unknown'] += $value['a_unknown']; + $final_result['counters_total']['t_a_normal'] += $value['a_normal']; + $final_result['counters_total']['t_a_not_init'] += $value['a_not_init']; + $final_result['counters_total']['t_a_agents'] += $value['a_agents']; - //Sum counters for data - $array_data[$value['name_data']]['m_normal'] += $value['m_normal']; - $array_data[$value['name_data']]['m_critical'] += $value['m_critical']; - $array_data[$value['name_data']]['m_warning'] += $value['m_warning']; - $array_data[$value['name_data']]['m_unknown'] += $value['m_unknown']; - $array_data[$value['name_data']]['m_not_init'] += $value['m_not_init']; - $array_data[$value['name_data']]['m_alerts'] += $value['m_alerts']; - $array_data[$value['name_data']]['m_total'] += $value['m_total']; - $array_data[$value['name_data']]['a_critical'] += $value['a_critical']; - $array_data[$value['name_data']]['a_warning'] += $value['a_warning']; - $array_data[$value['name_data']]['a_unknown'] += $value['a_unknown']; - $array_data[$value['name_data']]['a_normal'] += $value['a_normal']; - $array_data[$value['name_data']]['a_not_init'] += $value['a_not_init']; - $array_data[$value['name_data']]['a_agents'] += $value['a_agents']; + //Sum counters for data + $array_data[$value['name_data']]['m_normal'] += $value['m_normal']; + $array_data[$value['name_data']]['m_critical'] += $value['m_critical']; + $array_data[$value['name_data']]['m_warning'] += $value['m_warning']; + $array_data[$value['name_data']]['m_unknown'] += $value['m_unknown']; + $array_data[$value['name_data']]['m_not_init'] += $value['m_not_init']; + $array_data[$value['name_data']]['m_alerts'] += $value['m_alerts']; + $array_data[$value['name_data']]['m_total'] += $value['m_total']; + $array_data[$value['name_data']]['a_critical'] += $value['a_critical']; + $array_data[$value['name_data']]['a_warning'] += $value['a_warning']; + $array_data[$value['name_data']]['a_unknown'] += $value['a_unknown']; + $array_data[$value['name_data']]['a_normal'] += $value['a_normal']; + $array_data[$value['name_data']]['a_not_init'] += $value['a_not_init']; + $array_data[$value['name_data']]['a_agents'] += $value['a_agents']; + } } } @@ -432,8 +506,16 @@ function agent_counters_custom_fields($filters){ } function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){ + //filter group and check ACL groups + $groups_and = ""; + if (!users_can_manage_group_all()) { + $user_groups = array_keys(users_get_groups(false, "AR", false)); + $id_groups = implode(", ", $user_groups); + $groups_and = " AND (group_search IN ($id_groups)) "; + } + if($for_select){ - $query = "SELECT id, `name` FROM tagent_custom_fields_filter"; + $query = "SELECT id, `name` FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and; $rs = db_get_all_rows_sql($query); if(isset($rs) && is_array($rs)){ foreach ($rs as $key => $value) { @@ -445,7 +527,7 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = "" } } else{ - $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1"; + $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and; if($id){ $query .= " AND id = " . $id; @@ -459,4 +541,13 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = "" } return $result; } + +function get_group_filter_custom_field_view ($id){ + if(isset($id)){ + $res = db_get_row_filter('tagent_custom_fields_filter',array('id' => $id)); + return $res; + } + return false; +} + ?> \ No newline at end of file diff --git a/pandora_console/include/functions_event_responses.php b/pandora_console/include/functions_event_responses.php new file mode 100644 index 0000000000..474b628da3 --- /dev/null +++ b/pandora_console/include/functions_event_responses.php @@ -0,0 +1,80 @@ +<?php + +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2018 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. + +/** + * @package Include + * @subpackage Event Responses + */ + +/** + * Get all event responses with all values that user can access + * + * @return array With all table values + */ +function event_responses_get_responses() { + global $config; + $filter = array(); + + // Apply a filter if user cannot see all groups + if (!users_can_manage_group_all()) { + $id_groups = array_keys(users_get_groups(false, "PM")); + $filter = array('id_group' => $id_groups); + } + return db_get_all_rows_filter('tevent_response', $filter); +} + +/** + * Validate the responses data to store in database + * + * @param array (by reference) Array with values to validate and modify + */ +function event_responses_validate_data (&$values) { + if ($values['type'] != "command" || !enterprise_installed()) { + $values['server_to_exec'] = 0; + } + if ($values['new_window'] == 1) { + $values['modal_width'] = 0; + $values['modal_height'] = 0; + } +} + +/** + * Create an event response + * + * @param array With all event response data + * + * @return True if successful insertion + */ +function event_responses_create_response($values) { + event_responses_validate_data($values); + return db_process_sql_insert('tevent_response', $values); +} + +/** + * Update an event response + * + * @param array With all event response data + * + * @return True if successful insertion + */ +function event_responses_update_response($response_id, $values) { + event_responses_validate_data($values); + return db_process_sql_update( + 'tevent_response', $values, array('id' => $response_id) + ); +} + +?> diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 2f874ac72b..b646a26945 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -95,7 +95,7 @@ function events_get_events ($filter = false, $fields = false) { * * @return mixed False in case of error or invalid values passed. Event row otherwise */ -function events_get_event ($id, $fields = false) { +function events_get_event ($id, $fields = false, $meta = false, $history = false) { if (empty ($id)) return false; global $config; @@ -104,8 +104,10 @@ function events_get_event ($id, $fields = false) { if (! in_array ('id_grupo', $fields)) $fields[] = 'id_grupo'; } + + $table = events_get_events_table($meta, $history); - $event = db_get_row ('tevento', 'id_evento', $id, $fields); + $event = db_get_row ($table, 'id_evento', $id, $fields); if (! check_acl ($config['id_user'], $event['id_grupo'], 'ER')) return false; @@ -851,10 +853,15 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret $filter = '1 = 1'; } + $secondary_join = ''; + if (!users_can_manage_group_all("ER")) { + $secondary_join = "LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent"; + } + $sql = sprintf ("SELECT DISTINCT tevento.* - FROM tevento LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent + FROM tevento %s WHERE %s %s - ORDER BY utimestamp DESC LIMIT %d", $agent_condition, $filter, $limit); + ORDER BY utimestamp DESC LIMIT %d", $secondary_join, $agent_condition, $filter, $limit); $result = db_get_all_rows_sql ($sql); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index cc993331ec..b53f0041ca 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -238,7 +238,7 @@ function grafico_modulo_sparse_data( } } - if($array_data === false){ + if($array_data === false || !isset($array_data['sum1']['data'][0][1])){ return false; } @@ -912,7 +912,9 @@ function grafico_modulo_sparse ($params) { else{ $return = graph_nodata_image( $params['width'], - $params['height'] + $params['height'], + 'area', + __('No data to display within the selected interval') ); } } @@ -2456,7 +2458,9 @@ function graph_sla_slicebar ( 0, array(), true, - $ttl + $ttl, + false, + false ); } @@ -3188,16 +3192,14 @@ function graph_custom_sql_graph ($id, $width, $height, * @param string homeurl * @param bool return or echo the result */ -function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false) { +function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false, $widgets=false) { global $config; global $graphic_type; $data = array (); - //$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph - $resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph - - $interval = (int) ($period / $resolution); + //TODO interval + $interval = 24; $date = get_system_time (); $datelimit = $date - $period; $periodtime = floor ($period / $interval); @@ -3206,7 +3208,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho $legend = array(); $full_legend = array(); $full_legend_date = array(); - + $cont = 0; for ($i = 0; $i < $interval; $i++) { $bottom = $datelimit + ($periodtime * $i); @@ -3216,24 +3218,24 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho else { $name = $bottom; } - + // Show less values in legend if ($cont == 0 or $cont % 2) $legend[$cont] = $name; - + if ($from_agent_view) { $full_date = date('Y/m/d', $bottom); $full_legend_date[$cont] = $full_date; } $full_legend[$cont] = $name; - + $top = $datelimit + ($periodtime * ($i + 1)); $event = db_get_row_filter ('tevento', array ('id_agente' => $id_agent, 'utimestamp > '.$bottom, 'utimestamp < '.$top), 'criticity, utimestamp'); - + if (!empty($event['utimestamp'])) { $data[$cont]['utimestamp'] = $periodtime; switch ($event['criticity']) { @@ -3258,7 +3260,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho $colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN); // Draw slicebar graph - $out = flot_slicesbar_graph($data, $period, 100, 40, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date); + $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date, 0, 1, $widgets); if ($return) { return $out; @@ -3284,13 +3286,10 @@ function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $pe $data = array (); - //$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph - $resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph - $interval = (int) ($period / $resolution); - $date = get_system_time (); + $interval = 24; + $date = get_system_time(); $datelimit = $date - $period; $periodtime = floor ($period / $interval); - $time = array (); $data = array (); $legend = array(); $full_legend = array(); @@ -3594,6 +3593,7 @@ function fullscale_data ( } } else{ + if ($data_uncompress === false) $data_uncompress = array(); foreach ($data_uncompress as $k) { foreach ($k["data"] as $v) { if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data @@ -3662,7 +3662,9 @@ function fullscale_data ( $data["sum" . $series_suffix]['min'] = $min_value_min; $data["sum" . $series_suffix]['max'] = $max_value_max; - $data["sum" . $series_suffix]['avg'] = $sum_data/$count_data; + $data["sum" . $series_suffix]['avg'] = $count_data == 0 + ? 0 + : $sum_data/$count_data; } if($show_percentil && !$compare){ @@ -4070,19 +4072,17 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu } function graph_nodata_image($width = 300, $height = 110, $type = 'area', $text = '') { - $image = ui_get_full_url('images/image_problem_area_small.png', + $image = ui_get_full_url('images/image_problem_area.png', false, false, false); // if ($text == '') { // $text = __('No data to show'); // } + $text_div = '<div class="nodata_text" style="text-align:center; padding: 30px 0; display:block; font-size:9.5pt;">' . $text . '</div>'; - $text_div = '<div class="nodata_text">' . $text . '</div>'; + $image_div = $text_div . '<div class="nodata_container" style="background-position: top; width:40%;height:40%;background-size: contain;background-image: url(\'' . $image . '\');"><div></div></div>'; - $image_div = '<div class="nodata_container" style="width:80%;height:80%;background-size: 80% 80%;background-image: url(\'' . $image . '\');">' . - $text_div . '</div>'; - - $div = '<div style="width:' . $width . 'px; height:' . $height . 'px; border: 1px dotted #ddd; background-color: white; margin: 0 auto;">' . + $div = '<div style="width:' . $width . 'px; height:' . $height . 'px; background-color: white; margin: 0 auto;">' . $image_div . '</div>'; return $div; diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index 22df6a582b..90d6ef3022 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -175,6 +175,7 @@ function networkmap_process_networkmap($id = 0) { $nodes_and_relations['nodes'] = array(); $index = 0; foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id'] = $node["id"]; $nodes_and_relations['nodes'][$index]['id_map'] = $id; $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; @@ -303,6 +304,7 @@ function networkmap_process_networkmap($id = 0) { $index = 0; $node_center = array(); foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id'] = $node["id"]; $nodes_and_relations['nodes'][$index]['id_map'] = $id; $children_count = 0; @@ -1072,6 +1074,7 @@ function networkmap_loadfile($id = 0, $file = '', $node_id = $items[1]; $node_x = $items[2] * 100; //200 is for show more big $node_y = $height_map - $items[3] * 100; //200 is for show more big + $data['id'] = $node_id; $data['text'] = ''; $data['image'] = ''; $data['width'] = 10; diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 62306ec060..01d876697d 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -144,6 +144,25 @@ function profile_delete_profile ($id_profile) { return (bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile)); } +/** + * Delete profile from database and remove from the assigned users (tusuario_perfil) + * + * @param int Profile ID + * + * @return bool Whether or not it's deleted in both tables + */ +function profile_delete_profile_and_clean_users ($id_profile) { + + $profile_deletion = (bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile)); + + // Delete in tusuario_perfil only if is needed + if (!(bool)db_get_value('id_perfil', 'tusuario_perfil', 'id_perfil', $id_profile)) { + return $profile_deletion; + } + return $profile_deletion && + (bool)db_process_sql_delete('tusuario_perfil', array('id_perfil' => $id_profile)); +} + /** * Print the table to display, create and delete profiles * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 765ded33ca..613574ee27 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -144,6 +144,35 @@ function reporting_make_reporting_data($report = null, $id_report, $metaconsole_on = is_metaconsole(); $index_content = 0; foreach ($contents as $content) { + + if (!empty($content["id_agent_module"]) && !empty($content["id_agent"]) + && tags_has_user_acl_tags($config['id_user'])) { + $where_tags = tags_get_acl_tags( + $config['id_user'], + $id_groups, + 'AR', + 'module_condition', + 'AND', + 'tagente_modulo', + false, + array(), + true); + + $sql_tags_join = "INNER JOIN tagente ON tagente.id_agente = t1.id_agente + INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo"; + + $sql = sprintf('SELECT count(*) FROM tagente_modulo t1 + %s WHERE t1.delete_pending = 0 AND t1.id_agente_modulo = '. $content["id_agent_module"] .' + AND t1.id_agente = ' . $content['id_agent'] . ' %s', + $sql_tags_join, $where_tags); + + $result_tags = db_get_value_sql($sql); + + if (!$result_tags) { + continue; + } + } + $server_name = $content['server_name']; // General reports with 0 period means last value @@ -218,11 +247,11 @@ function reporting_make_reporting_data($report = null, $id_report, } } - if(sizeof($content['id_agent']) != 1){ + if(is_array($content['id_agent']) && sizeof($content['id_agent']) != 1){ $content['style']['name_label'] = str_replace("_agent_",sizeof($content['id_agent']).__(' agents'),$content['style']['name_label']); } - if(sizeof($content['id_agent_module']) != 1){ + if(is_array($content['id_agent_module']) && sizeof($content['id_agent_module']) != 1){ $content['style']['name_label'] = str_replace("_module_",sizeof($content['id_agent_module']).__(' modules'),$content['style']['name_label']); } @@ -320,25 +349,33 @@ function reporting_make_reporting_data($report = null, $id_report, $report['contents'][] = reporting_value( $report, $content, - 'max',$pdf); + 'max', + $pdf + ); break; case 'avg_value': $report['contents'][] = reporting_value( $report, $content, - 'avg',$pdf); + 'avg', + $pdf + ); break; case 'min_value': $report['contents'][] = reporting_value( $report, $content, - 'min',$pdf); + 'min', + $pdf + ); break; case 'sumatory': $report['contents'][] = reporting_value( $report, $content, - 'sum'); + 'sum', + $pdf + ); break; case 'historical_data': $report['contents'][] = reporting_historical_data( @@ -349,25 +386,33 @@ function reporting_make_reporting_data($report = null, $id_report, $report['contents'][] = reporting_value( $report, $content, - 'MTTR'); + 'MTTR', + $pdf + ); break; case 'MTBF': $report['contents'][] = reporting_value( $report, $content, - 'MTBF'); + 'MTBF', + $pdf + ); break; case 'TTO': $report['contents'][] = reporting_value( $report, $content, - 'TTO'); + 'TTO', + $pdf + ); break; case 'TTRT': $report['contents'][] = reporting_value( $report, $content, - 'TTRT'); + 'TTRT', + $pdf + ); break; case 'agent_configuration': $report['contents'][] = reporting_agent_configuration( @@ -618,7 +663,9 @@ function reporting_make_reporting_data($report = null, $id_report, $content, $type, $force_width_chart, - $force_height_chart); + $force_height_chart, + $pdf + ); break; case 'module_histogram_graph': $report['contents'][] = reporting_enterprise_module_histogram_graph( @@ -1156,10 +1203,10 @@ function reporting_event_top_n($report, $content, $type = 'dinamic', } } - $ag_name = modules_get_agentmodule_agent_alias($row ['id_agent_module']); + $ag_name = modules_get_agentmodule_agent_alias($row ['id_agent_module']); $mod_name = modules_get_agentmodule_name ($row ['id_agent_module']); $unit = db_get_value('unit', 'tagente_modulo', - 'id_agente_modulo', $row ['id_agent_module']); + 'id_agente_modulo', $row ['id_agent_module']); switch ($top_n) { @@ -3774,7 +3821,7 @@ function reporting_agent_configuration($report, $content) { return reporting_check_structure_content($return); } -function reporting_value($report, $content, $type,$pdf) { +function reporting_value($report, $content, $type, $pdf) { global $config; $return = array(); @@ -6047,6 +6094,7 @@ function reporting_general($report, $content) { $i = 0; $index = 0; $is_string = array(); + foreach ($generals as $row) { //Metaconsole connection $server_name = $row ['server_name']; @@ -6336,7 +6384,17 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', } } else{ - $modules[] = $content['id_agent_module']; + if ($content['id_agent_module']) { + $modules[] = $content['id_agent_module']; + } else { + // restore to metaconsole database + metaconsole_restore_db(); + $module_source = db_get_all_rows_sql("SELECT id_agent_module FROM tgraph_source WHERE id_graph = " . $content['id_gs']); + foreach ($module_source as $key => $value) { + $modules[$key] = $value['id_agent_module']; + } + metaconsole_connect($server); + } } $id_graph = 0; } @@ -6391,7 +6449,7 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', break; } - if ($config['metaconsole'] && $type_report != 'automatic_graph') { + if ($config['metaconsole']) { metaconsole_restore_db(); } @@ -7487,8 +7545,8 @@ function reporting_get_stats_alerts($data, $links = false) { $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&pure=" . $config['pure']; $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure=" . $config['pure']; } else { - $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; - $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + $urls['monitor_alerts'] = $config['homeurl']."index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; + $urls['monitor_alerts_fired'] = $config['homeurl']."index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; } } @@ -7544,19 +7602,19 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he // Link URLS if ($links === false) { $urls = array(); - $urls['monitor_critical'] = "index.php?" . + $urls['monitor_critical'] = $config['homeurl']."index.php?" . "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD . "&pure=" . $config['pure']; - $urls['monitor_warning'] = "index.php?" . + $urls['monitor_warning'] = $config['homeurl']."index.php?" . "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_WARNING . "&pure=" . $config['pure']; - $urls['monitor_ok'] = "index.php?" . + $urls['monitor_ok'] = $config['homeurl']."index.php?" . "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_NORMAL . "&pure=" . $config['pure']; - $urls['monitor_unknown'] = "index.php?" . + $urls['monitor_unknown'] = $config['homeurl']."index.php?" . "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_UNKNOWN . "&pure=" . $config['pure']; - $urls['monitor_not_init'] = "index.php?" . + $urls['monitor_not_init'] = $config['homeurl']."index.php?" . "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_NOT_INIT . "&pure=" . $config['pure']; } @@ -7659,8 +7717,8 @@ function reporting_get_stats_agents_monitors($data) { } else { $urls = array(); - $urls['total_agents'] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; - $urls['monitor_checks'] = "index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1"; + $urls['total_agents'] = $config['homeurl']."index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; + $urls['monitor_checks'] = $config['homeurl']."index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1"; } // Agents and modules table @@ -9284,6 +9342,7 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, $id_module_type); $module_interval = modules_get_interval ($id_agent_module); $uncompressed_module = is_module_uncompressed ($module_name); + // Wrong module type if (is_module_data_string ($module_name)) { @@ -9292,46 +9351,23 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, // Incremental modules are treated differently $module_inc = is_module_inc ($module_name); - - // Get module data - $interval_data = db_get_all_rows_sql(' + + if ($uncompressed_module) { + // Get module data + $interval_data = db_get_all_rows_sql(' SELECT * FROM tagente_datos WHERE id_agente_modulo = ' . (int) $id_agent_module . ' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp < ' . (int) $date . ' ORDER BY utimestamp ASC', $search_in_history_db); + + } + else + $interval_data = db_uncompress_module_data((int) $id_agent_module, (int) $datelimit, (int) $date); + if ($interval_data === false) $interval_data = array (); - // Uncompressed module data - if ($uncompressed_module) { - $min_necessary = 1; - - // Compressed module data - } - else { - // Get previous data - $previous_data = modules_get_previous_data ($id_agent_module, $datelimit); - if ($previous_data !== false) { - $previous_data['utimestamp'] = $datelimit; - array_unshift ($interval_data, $previous_data); - } - - // Get next data - $next_data = modules_get_next_data ($id_agent_module, $date); - if ($next_data !== false) { - $next_data['utimestamp'] = $date; - array_push ($interval_data, $next_data); - } - else if (count ($interval_data) > 0) { - // Propagate the last known data to the end of the interval - $next_data = array_pop ($interval_data); - array_push ($interval_data, $next_data); - $next_data['utimestamp'] = $date; - array_push ($interval_data, $next_data); - } - - $min_necessary = 2; - } + $min_necessary = 1; if (count ($interval_data) < $min_necessary) { return false; @@ -9339,11 +9375,14 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, // Set initial conditions $total = 0; - if (! $uncompressed_module) { - $previous_data = array_shift ($interval_data); - } - + $partial_total = 0; + $count_sum = 0; + foreach ($interval_data as $data) { + + $partial_total = 0; + $count_sum = 0; + switch ($config["dbtype"]) { case "mysql": case "postgresql": @@ -9354,18 +9393,25 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, oracle_format_float_to_php($data['datos']); break; } - - if ($uncompressed_module) { - $total += $data['datos']; - } - else if ($module_inc) { - $total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']); + + if (!$module_inc) { + foreach ($data['data'] as $val) { + if (is_numeric($val['datos'])) { + $partial_total += $val['datos']; + $count_sum++; + } + } + + if ($count_sum===0) continue; + + $total += $partial_total/$count_sum; } else { - $total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']) / $module_interval; + $last = end($data['data']); + $total += $last['datos']; } - $previous_data = $data; } + return $total; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index f9fc970918..3df0b56cfe 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2466,61 +2466,57 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $sla_value = sla_truncate($chart['sla_value'], $config['graph_precision']) . '%'; $checks_resume = "(" . $chart['checks_ok'] . "/" . $chart['checks_total'] . ")"; } - $table1->data[] = array( - $chart['agent'] . "<br />" . $chart['module'], - $chart['chart'], - "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>" . - $sla_value . - '</span>', - $checks_resume - ); + + $table1->data[0][0] = $chart['agent'] . "<br />" . $chart['module']; + $table1->data[0][1] = $chart['chart']; + $table1->data[0][2] = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>" . $sla_value . '</span>'; + $table1->data[0][3] = $checks_resume; } if($item['type'] == 'availability_graph'){ + //table_legend_graphs; + $table2 = new stdClass(); + $table2->width = '99%'; + $table2->data = array (); + $table2->size = array (); + $table2->size[0] = '2%'; + $table2->data[0][0] = '<img src ="'. $src .'images/square_green.png">'; + $table2->size[1] = '14%'; + $table2->data[0][1] = '<span>'.__('OK') . '</span>'; - //table_legend_graphs; - $table2 = new stdClass(); - $table2->width = '99%'; - $table2->data = array (); - $table2->size = array (); - $table2->size[0] = '2%'; - $table2->data[0][0] = '<img src ="'. $src .'images/square_green.png">'; - $table2->size[1] = '14%'; - $table2->data[0][1] = '<span>'.__('OK') . '</span>'; + $table2->size[2] = '2%'; + $table2->data[0][2] = '<img src ="'. $src .'images/square_red.png">'; + $table2->size[3] = '14%'; + $table2->data[0][3] = '<span>'.__('Critical'). '</span>'; - $table2->size[2] = '2%'; - $table2->data[0][2] = '<img src ="'. $src .'images/square_red.png">'; - $table2->size[3] = '14%'; - $table2->data[0][3] = '<span>'.__('Critical'). '</span>'; + $table2->size[4] = '2%'; + $table2->data[0][4] = '<img src ="'. $src .'images/square_gray.png">'; + $table2->size[5] = '14%'; + $table2->data[0][5] = '<span>'.__('Unknow'). '</span>'; - $table2->size[4] = '2%'; - $table2->data[0][4] = '<img src ="'. $src .'images/square_gray.png">'; - $table2->size[5] = '14%'; - $table2->data[0][5] = '<span>'.__('Unknow'). '</span>'; + $table2->size[6] = '2%'; + $table2->data[0][6] = '<img src ="'. $src .'images/square_blue.png">'; + $table2->size[7] = '14%'; + $table2->data[0][7] = '<span>'.__('Not Init'). '</span>'; - $table2->size[6] = '2%'; - $table2->data[0][6] = '<img src ="'. $src .'images/square_blue.png">'; - $table2->size[7] = '14%'; - $table2->data[0][7] = '<span>'.__('Not Init'). '</span>'; - - $table2->size[8] = '2%'; - $table2->data[0][8] = '<img src ="'. $src .'images/square_violet.png">'; - $table2->size[9] = '14%'; - $table2->data[0][9] = '<span>'.__('Downtimes'). '</span>'; - - $table2->size[10] = '2%'; - $table2->data[0][10] = '<img src ="'. $src .'images/square_light_gray.png">'; - $table2->size[11] = '15%'; - $table2->data[0][11] = '<span>'.__('Ignore time'). '</span>'; + $table2->size[8] = '2%'; + $table2->data[0][8] = '<img src ="'. $src .'images/square_violet.png">'; + $table2->size[9] = '14%'; + $table2->data[0][9] = '<span>'.__('Downtimes'). '</span>'; + $table2->size[10] = '2%'; + $table2->data[0][10] = '<img src ="'. $src .'images/square_light_gray.png">'; + $table2->size[11] = '15%'; + $table2->data[0][11] = '<span>'.__('Ignore time'). '</span>'; } $table->colspan['charts']['cell'] = 2; $table->data['charts']['cell'] = html_print_table($table1, true); $table->colspan['legend']['cell'] = 2; $table->data['legend']['cell'] = html_print_table($table2, true); + if($pdf){ - return html_print_table($table, true); + return html_print_table($table1, true) . '<br />' . html_print_table($table2, true); } } @@ -3640,7 +3636,9 @@ function reporting_get_event_histogram ($events, $text_header_event = false) { 0, array(), true, - $ttl + $ttl, + false, + false ); $table->data[0][0] = $slicebar; @@ -3823,7 +3821,9 @@ function reporting_get_event_histogram_meta ($width) { 0, $full_legend_date, true, - 1 + 1, + false, + false ); $table->data[0][0] = $slicebar; @@ -3915,4 +3915,4 @@ function reporting_html_planned_downtimes_table ($planned_downtimes) { return $downtimes_table; } -?> \ No newline at end of file +?> diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 1fd26770c5..72a222becd 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -714,20 +714,15 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals ui_toggle($table_advanced, __('Advanced information')); - // Blank space below title, DONT remove this, this - // Breaks the layout when Flash charts are enabled :-o - //echo '<div id="id_div" style="height: 10px"> </div>'; - if ($config["agentaccess"]) { $access_graph = '<div style="width:100%; height:130px;">'; - $access_graph .= graphic_agentaccess($id_agente, 380, 120, SECONDS_1DAY, true, true); + $access_graph .= graphic_agentaccess ($id_agente, 380, 120, SECONDS_1DAY, true, true); $access_graph .= '</div>'; ui_toggle($access_graph, __('Agent access rate (24h)')); } - $events_graph = '<div style="margin-left: 10px;">'; - $events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, - SECONDS_1DAY, '', true); + $events_graph = '<div style="margin-left:10px; width:100%;">'; + $events_graph .= graph_graphic_agentevents ($id_agente, 375, 45, SECONDS_1DAY, '', true, false, true); $events_graph .= '</div><br>'; ui_toggle($events_graph, __('Events (24h)')); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index cba6670e4c..40f3bb77e9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -548,7 +548,7 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small" $link = false; if ($link) - $output = '<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">'; + $output = '<a href="'.$config["homeurl"].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">'; if ($config['show_group_name']) { $output .= '<span title="'. groups_get_name($id_group, true) .'">' . diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 1451cb80d3..09fee29e70 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1205,7 +1205,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:right;height:'.$himg.'px;">'. hbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '</div>'; } @@ -1213,7 +1213,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:right;height:'.$himg.'px;">'. vbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '</div>'; } @@ -1223,7 +1223,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:left;height:'.$himg.'px;">'. hbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '</div>'; } @@ -1231,7 +1231,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:left;height:'.$himg.'px;">'. vbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '</div>'; } @@ -1240,14 +1240,14 @@ function visual_map_print_item($mode = "read", $layoutData, if ($layoutData['type_graph'] == 'horizontal') { $img = hbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); } else { $img = vbar_graph($module_data, 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); } @@ -1259,7 +1259,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:right;height:'.$himg.'px;">'. hbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '</div>'; } @@ -1267,7 +1267,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:right;height:'.$himg.'px;">'. vbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '</div>'; } @@ -1277,7 +1277,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:left;height:'.$himg.'px;">'. hbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '</div>'; } @@ -1285,7 +1285,7 @@ function visual_map_print_item($mode = "read", $layoutData, $img = '<div style="float:left;height:'.$himg.'px;">'. vbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '</div>'; } @@ -1294,14 +1294,14 @@ function visual_map_print_item($mode = "read", $layoutData, if ($layoutData['type_graph'] == 'horizontal') { $img = hbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); } else { $img = vbar_graph($module_data, $width, $height, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area.png", false, false, false), "", "", $water_mark, $config['fontpath'], 6, "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); } @@ -1633,78 +1633,11 @@ function visual_map_print_item($mode = "read", $layoutData, break; case STATIC_GRAPH: case GROUP_ITEM: - - - if (! defined ('METACONSOLE')) { - } - else { - // For each server defined and not disabled: - $servers = db_get_all_rows_sql ('SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0'); - if ($servers === false) - $servers = array(); - - $result = array(); - $count_modules = 0; - foreach ($servers as $server) { - // If connection was good then retrieve all data server - if (metaconsole_connect($server) == NOERR) - $connection = true; - else - $connection = false; - - $result_server = db_get_all_rows_sql ($sql); - - if (!empty($result_server)) { - - // Create HASH login info - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd,true); - - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; - } - - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&' . - 'loginhash=auto&' . - 'loginhash_data=' . $hashdata . '&' . - 'loginhash_user=' . $user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - - $count_modules++; - - } - - $result = array_merge($result, $result_server); - } - - if ($connection) { - metaconsole_restore_db(); - } - } - } - if (($layoutData['image'] != null && $layoutData['image'] != 'none') || $layoutData['show_statistics'] == 1) { $img_style_title = strip_tags($label); if ($layoutData['type'] == STATIC_GRAPH) { if ($layoutData['id_agente_modulo'] != 0) { - if ($layoutData['id_metaconsole'] != 0) { //Metaconsole db connection $connection = db_get_row_filter ('tmetaconsole_setup', @@ -1780,83 +1713,84 @@ function visual_map_print_item($mode = "read", $layoutData, else if($layoutData['label_position']=='right'){ $imgpos = 'float:left'; } - $varsize = getimagesize($config['homedir'] . '/' . $img); - - - if($layoutData['show_statistics'] == 1){ - + + if($layoutData['show_statistics'] == 1) { if (get_parameter('action') == 'edit') { - if ($width == 0 || $height == 0) { - - echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:520px;height:80px;'.$imgpos.'">'; + echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:520px;height:80px;'.$imgpos.'">'; } else{ - echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">'; + echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">'; } - } else{ - - $agents_critical = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_CRITICAL), - array ('COUNT(*) as total'), 'AR', false); - - $agents_warning = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_WARNING), - array ('COUNT(*) as total'), 'AR', false); - - $agents_unknown = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_UNKNOWN), - array ('COUNT(*) as total'), 'AR', false); - - $agents_ok = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_OK), - array ('COUNT(*) as total'), 'AR', false); - - $total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total']; - - $stat_agent_ok = $agents_ok[0]['total']/$total_agents*100; - $stat_agent_wa = $agents_warning[0]['total']/$total_agents*100; - $stat_agent_cr = $agents_critical[0]['total']/$total_agents*100; - $stat_agent_un = $agents_unknown[0]['total']/$total_agents*100; - - if($width == 0 || $height == 0){ - $dyn_width = 520; - $dyn_height = 80; - } - else{ - $dyn_width = $width; - $dyn_height = $height; - } - - - echo '<table cellpadding="0" cellspacing="0" border="0" class="databox" style="width:'.$dyn_width.'px;height:'.$dyn_height.'px;text-align:center;'; - - if($layoutData['label_position'] == 'left'){ - echo "float:right;"; - } - elseif ($layoutData['label_position'] == 'right') { - echo "float:left;"; - } - - echo '">'; - - echo "<tr style='height:10%;'>"; - echo "<th style='text-align:center;background-color:#9d9ea0;color:black;font-weight:bold;'>" .groups_get_name($layoutData['id_group'],true) . "</th>"; - - echo "</tr>"; - echo "<tr style='background-color:whitesmoke;height:90%;'>"; - echo "<td>"; + $agents_critical = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_CRITICAL + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_warning = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_WARNING + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_unknown = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_UNKNOWN + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_ok = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_OK + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total']; + $stat_agent_ok = $agents_ok[0]['total']/$total_agents*100; + $stat_agent_wa = $agents_warning[0]['total']/$total_agents*100; + $stat_agent_cr = $agents_critical[0]['total']/$total_agents*100; + $stat_agent_un = $agents_unknown[0]['total']/$total_agents*100; + if($width == 0 || $height == 0){ + $dyn_width = 520; + $dyn_height = 80; + } else { + $dyn_width = $width; + $dyn_height = $height; + } + echo '<table cellpadding="0" cellspacing="0" border="0" class="databox" style="width:'.$dyn_width.'px;height:'.$dyn_height.'px;text-align:center;'; + if($layoutData['label_position'] == 'left'){ + echo "float:right;"; + } + elseif ($layoutData['label_position'] == 'right') { + echo "float:left;"; + } + + echo '">'; + echo "<tr style='height:10%;'>"; + echo "<th style='text-align:center;background-color:#9d9ea0;color:black;font-weight:bold;'>" .groups_get_name($layoutData['id_group'],true) . "</th>"; + echo "</tr>"; + echo "<tr style='background-color:whitesmoke;height:90%;'>"; + echo "<td>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#FC4444;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_cr, 2)) ."%</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Critical</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#f8db3f;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_wa, 2)) ."%</div>"; @@ -1865,68 +1799,38 @@ function visual_map_print_item($mode = "read", $layoutData, echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Normal</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#9d9ea0;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_un, 2)) ."%</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Unknown</div>"; - - echo "</td>"; - echo "</tr>"; - echo "</table>"; - - + echo "</td>"; + echo "</tr>"; + echo "</table>"; } - - } - else{ - + } else { + $options = array( + "class" => "image", + "id" => "image_" . $id, + "title" => $img_style_title, + "style" => $borderStyle.$imgpos + ); if ($width == 0 || $height == 0) { if($varsize[0] > 150 || $varsize[1] > 150){ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "width" => "70px", - "height" => "70px", - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); - } - else{ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); + $options['width'] = "70px"; + $options['height'] = "70px"; } } else{ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "width" => $width, - "height" => $height, - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); + $options['width'] = $width; + $options['height'] = $height; } - + echo html_print_image($img, true, $options, + false, false, false, $isExternalLink); } - } - - if($layoutData['label_position']=='down'){ - echo io_safe_output($text); - } - else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ + + if ($layoutData['label_position'] != 'up') { echo io_safe_output($text); } - - if (! defined ('METACONSOLE')) { - } - else { - metaconsole_restore_db(); - } - - - break; - + + if (is_metaconsole()) metaconsole_restore_db(); + break; case PERCENTILE_BAR: if (($layoutData['image'] == 'value') && ($value_text !== false)) { $unit_text = db_get_sql ('SELECT unit @@ -1963,6 +1867,7 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; + echo io_safe_output($text); break; case PERCENTILE_BUBBLE: @@ -2006,6 +1911,7 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; + echo io_safe_output($text); break; case CIRCULAR_PROGRESS_BAR: @@ -2049,6 +1955,7 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; + echo io_safe_output($text); break; case CIRCULAR_INTERIOR_PROGRESS_BAR: @@ -2093,6 +2000,7 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; + echo io_safe_output($text); break; case MODULE_GRAPH: @@ -2282,11 +2190,9 @@ function visual_map_print_item($mode = "read", $layoutData, if ($layoutData['parent_item'] != 0) { $parent = db_get_row_filter('tlayout_data', array('id' => $layoutData['parent_item'])); - + echo '<script type="text/javascript">'; - echo '$(document).ready (function() { - lines.push({"id": "' . $id . '" , "node_begin":"' . $layoutData['parent_item'] . '","node_end":"' . $id . '","color":"' . visual_map_get_color_line_status($parent) . '","thickness":"' . (empty($config["vc_line_thickness"]) ? 2 : $config["vc_line_thickness"]) . '"}); - });'; + echo 'lines.push({"id": "' . $id . '" , "node_begin":"' . $layoutData['parent_item'] . '","node_end":"' . $id . '","color":"' . visual_map_get_color_line_status($parent) . '","thickness":"' . (empty($config["vc_line_thickness"]) ? 2 : $config["vc_line_thickness"]) . '"});'; echo '</script>'; } } @@ -2306,19 +2212,35 @@ function get_if_module_is_image ($id_module) { } function get_bars_module_data ($id_module) { - $mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module)); + //This charts is only serialize graphs. + //In other string show image no data to show. - if (preg_match("/\r\n/", $mod_values)) { - $values = explode("\r\n", $mod_values); - } - elseif (preg_match("/\n/", $mod_values)) { - $values = explode("\n", $mod_values); + $mod_values = db_get_value_filter( + 'datos', + 'tagente_estado', + array( + 'id_agente_modulo' => $id_module + ) + ); + + $values = false; + //avoid showing the image type modules. WUX + if(strpos($mod_values, 'data:image/png;base64') !== 0){ + if (preg_match("/\r\n/", $mod_values)) { + $values = explode("\r\n", $mod_values); + } + elseif (preg_match("/\n/", $mod_values)) { + $values = explode("\n", $mod_values); + } } $values_to_return = array(); $index = 0; $color_index = 0; $total = 0; + + if(!$values) return false; + foreach ($values as $val) { $data = explode(",", $val); $values_to_return[$data[0]] = array('g' =>$data[1]); @@ -3323,9 +3245,7 @@ function visual_map_print_user_lines($layout_data, $proportion = null) { } echo '<script type="text/javascript">'; - echo '$(document).ready (function() { - user_lines.push(' . json_encode($line) . '); - });'; + echo 'user_lines.push(' . json_encode($line) . ');'; echo '</script>'; } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index f8db1a362f..d658a53b67 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -586,7 +586,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['show_on_top_row']['html'] = '<td align="left" style="">' . __('Always show on top') . '</td> <td align="left" style="">' . - html_print_checkbox('show_on_top', 1, '', true) . '</td>'; + html_print_checkbox('show_on_top', 1, '', true) .ui_print_help_tip (__("It allows the element to be superimposed to the rest of items of the visual console"), true) . '</td>'; $show_last_value = array('0' => __('Hide last value on boolean modules'), '1' => __('Enabled'), '2' => __('Disabled')); $form_items['show_last_value_row'] = array(); diff --git a/pandora_console/include/get_file.php b/pandora_console/include/get_file.php index 76629296b8..abc1539d5a 100644 --- a/pandora_console/include/get_file.php +++ b/pandora_console/include/get_file.php @@ -13,22 +13,23 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -if (! isset($_SESSION['id_usuario'])) { - session_start(); -} -require_once('functions.php'); -require_once('functions_filemanager.php'); + +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("config.php"); +require_once ('functions.php'); +require_once ('functions_filemanager.php'); + global $config; check_login (); $auth_method = db_get_value('value', 'tconfig', 'token', 'auth'); -if($auth_method != 'ad') +if($auth_method != 'ad' && $auth_method != 'ldap'){ require_once("auth/" . $auth_method . ".php"); - +} $styleError = "background:url(\"../images/err.png\") no-repeat scroll 0 0 transparent; padding:4px 1px 6px 30px; color:#CC0000;"; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 4c623c90da..e5c6d2f77a 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -141,7 +141,17 @@ function vbar_graph( setup_watermark($water_mark, $water_mark_file, $water_mark_url); if (empty($chart_data)) { - return '<img src="' . $no_data_image . '" />'; + return html_print_image ( + $no_data_image, + true, + array( + 'width' => $width, + 'height' => $height, + 'title' => __('No data to show') + ), + false, + true + ); } if($ttl == 2){ @@ -271,7 +281,17 @@ function hbar_graph($chart_data, $width, $height, setup_watermark($water_mark, $water_mark_file, $water_mark_url); if (empty($chart_data)) { - return '<img src="' . $no_data_image . '" />'; + return html_print_image ( + $no_data_image, + true, + array( + 'width' => $width, + 'height' => $height, + 'title' => __('No data to show') + ), + false, + true + ); } if($ttl == 2){ diff --git a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js index d5ad78cf05..781c1d1cc0 100644 --- a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js +++ b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js @@ -204,7 +204,7 @@ $form .prop('method', 'POST') - .prop('action', plot.getOptions().export.homeurl + '/include/graphs/export_data.php') + .prop('action', plot.getOptions().export.homeurl + 'include/graphs/export_data.php') .append($dataInput, $typeInput, $separatorInput, $excelInput) .hide() // Firefox made me write into the DOM for this :( @@ -394,7 +394,7 @@ $form .prop('method', 'POST') - .prop('action', plot.getOptions().export.homeurl + '/include/graphs/export_data.php') + .prop('action', plot.getOptions().export.homeurl + 'include/graphs/export_data.php') .append($dataInput, $typeInput, $separatorInput, $excelInput) .hide() // Firefox made me write into the DOM for this :( diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index e2b606f709..7067e1d560 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -670,7 +670,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, - font, font_size, separator, separator2, id_agent, full_legend, not_interactive) { + font, font_size, separator, separator2, id_agent, full_legend, not_interactive, show_date) { values = values.split(separator2); labels = labels.split(separator); @@ -728,6 +728,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul tickColor: '#fff' }, xaxes: [ { + show:show_date, tickFormatter: xFormatter, color: '', tickSize: intervaltick, @@ -1873,7 +1874,7 @@ function pandoraFlotArea( graph_id, values, legend, })); } - $('#menu_cancelzoom_' + graph_id).attr('src', homeurl + '/images/zoom_cross_grey.png'); + $('#menu_cancelzoom_' + graph_id).attr('src', homeurl + 'images/zoom_cross_grey.png'); max_draw['max'] = ranges.yaxis.to; max_draw['min'] = ranges.yaxis.from; @@ -2330,7 +2331,7 @@ function pandoraFlotArea( graph_id, values, legend, legend: { show: true } })); $('#menu_cancelzoom_' + graph_id) - .attr('src', homeurl + '/images/zoom_cross.disabled.png'); + .attr('src', homeurl + 'images/zoom_cross.disabled.png'); overview.clearSelection(); currentRanges = null; thresholded = false; diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index a3b9a6cb37..7524fc119e 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -691,7 +691,7 @@ function flot_slicesbar_graph ( $adapt_key = '', $stat_win = false, $id_agent = 0, $full_legend_date = array(), $not_interactive = 0, $ttl = 1, - $widgets = false) { + $widgets = false, $show = true) { global $config; @@ -706,13 +706,15 @@ function flot_slicesbar_graph ( 'fontpath' => $fontpath, 'round_corner' => $round_corner, 'homeurl' => $homeurl, - 'watermark' => $watermark = '', - 'adapt_key' => $adapt_key = '', - 'stat_win' => $stat_win = false, - 'id_agent' => $id_agent = 0, - 'full_legend_date' => $full_legend_date = array(), - 'not_interactive' => $not_interactive = 0, - 'ttl' => $ttl = 1 + 'watermark' => $watermark, + 'adapt_key' => $adapt_key, + 'stat_win' => $stat_win, + 'id_agent' => $id_agent, + 'full_legend_date' => $full_legend_date, + 'not_interactive' => $not_interactive, + 'ttl' => 1, + 'widgets' => $widgets, + 'show' => $show ); return generator_chart_to_pdf('slicebar', $params); @@ -839,7 +841,7 @@ function flot_slicesbar_graph ( // Javascript code $return .= "<script type='text/javascript'>"; $return .= "//<![CDATA[\n"; - $return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$labels','$legend','$acumulate_data',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive)"; + $return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$labels','$legend','$acumulate_data',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show')"; $return .= "\n//]]>"; $return .= "</script>"; diff --git a/pandora_console/include/javascript/OpenLayers/theme/default/style.css b/pandora_console/include/javascript/OpenLayers/theme/default/style.css index cd29d4dad2..6dca6061c9 100755 --- a/pandora_console/include/javascript/OpenLayers/theme/default/style.css +++ b/pandora_console/include/javascript/OpenLayers/theme/default/style.css @@ -3,6 +3,7 @@ div.olMap { padding: 0px!important; margin: 0px!important; cursor: default; + position: relative !important; } div.olMapViewport { diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 3a8f29d6c0..8871950f3e 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -2721,7 +2721,7 @@ function init_graph(parameter_object) { } window.scale_minimap = 4.2; window.translation = [0, 0]; - window.scale = (typeof (z_dash) != "undefined") ? z_dash : 0.5; + window.scale = z_dash || 0.5; window.node_radius = 40; if (typeof (parameter_object.node_radius) != "undefined") { window.node_radius = parameter_object.node_radius; @@ -3306,7 +3306,7 @@ function draw_elements_graph() { }) .attr("startOffset", function (d) { if (d.source.x < d.target.x) { - return ""; + return "0%"; } else { return "85%"; @@ -3356,7 +3356,7 @@ function draw_elements_graph() { return "85%"; } else { - return ""; + return "0%"; } }) .attr("text-anchor", function (d) { diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 459776c5b2..bb75e28667 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -651,7 +651,7 @@ function add_macro_field(macro, row_model_id) { $macro_field.attr('class', 'macro_field'); // Get the number of fields already printed - var fields = $('.macro_field').size(); + var fields = $('.macro_field').length; // If is the first, we insert it after model row if (fields == 0) { diff --git a/pandora_console/include/load_session.php b/pandora_console/include/load_session.php index 8144b410b2..b34c33b2bb 100644 --- a/pandora_console/include/load_session.php +++ b/pandora_console/include/load_session.php @@ -35,15 +35,15 @@ function pandora_session_read ($session_id) { function pandora_session_write ($session_id, $data) { $session_id = addslashes($session_id); - + $values = array(); $values['last_active'] = time(); - + if (!empty($data)) $values['data'] = addslashes($data); - + $session_exists = (bool) db_get_value('COUNT(id_session)', 'tsessions_php', 'id_session', $session_id); - + if (!$session_exists) { $values['id_session'] = $session_id; $retval_write = db_process_sql_insert('tsessions_php', $values); @@ -52,7 +52,7 @@ function pandora_session_write ($session_id, $data) { $retval_write = db_process_sql_update('tsessions_php', $values, array('id_session' => $session_id)); } - return ($retval_write !== false) ? true : false; + return $retval_write !== false; } function pandora_session_destroy ($session_id) { @@ -77,6 +77,8 @@ function pandora_session_gc ($max_lifetime = 300) { return $retval; } -$result_handler = session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc'); - +// FIXME: SAML should work with pandora session handlers +if (db_get_value('value', 'tconfig', 'token', 'auth') != "saml") { + $result_handler = session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc'); +} ?> diff --git a/pandora_console/include/styles/install.css b/pandora_console/include/styles/install.css index 6c558fdcba..18ccab6663 100644 --- a/pandora_console/include/styles/install.css +++ b/pandora_console/include/styles/install.css @@ -205,3 +205,67 @@ div.installation_step { color:white; } +:focus { + outline: 0; +} + +/* POPUP */ +.popup-lightbox{ + position: fixed; + z-index: 8888; + width: 100%; + height: 100%; + background-color: #000; + opacity: 0.6; + visibility: hidden; +} + +.popup{ + max-height: 450px; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + -webkit-transform: translate(-50%, -50%); + background-color: #FFF; + z-index: 9999; + display: none; +} + +.popup-title{ + background-color: #82b92e; + padding: 10px 20px; + color: #FFF; + font-size:12pt; + text-align: center; + font-family:Sans, Arial, sans; +} + +.popup-inner{ + max-height: 350px; + background: #FFF; +/* overflow-y: scroll;*/ + padding: 25px 35px; + font-size: 11pt; +} + +.popup-button-green{ + background-color: #82B92E; + border: 1px solid transparent; + color: blue; +} + +.popup-button-green span{ + color: #FFF !important; +} + +.popup-button-green:hover{ + background-color: transparent !important; + border: 1px solid #82B92E; + color: red !important; +} + +.popup-button-green:hover span{ + color: #82B92E !important; +} +/* POPUP -END */ diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 4f67602f62..c3eff053c1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1384,7 +1384,7 @@ table.databox { border: 0px none #E2E2E2; } -.databox>thead>tr>th, .databox>tbody>tr>th { +.databox>thead>tr>th, .databox>tbody>tr>th, .databox>thead>tr>th a { padding: 9px 7px; font-weight: normal; color: #fff; @@ -5038,4 +5038,16 @@ ul.ui-front li a.ui-menu-item-wrapper span{ ul.ui-front li a.ui-menu-item-wrapper:hover{ text-decoration: none !important; } + +input[type=submit].ui-button-dialog{ + margin: .5em 1em .5em 0 !important; + cursor: pointer !important; + background: white !important; + background-color: white !important; + color: #82b92e !important; + text-align: center !important; + border: 1px solid #82b92e !important; + height:30px !important; + width:90px !important; +} /* --- END - JQUERY-UI --- */ diff --git a/pandora_console/include/web2image.js b/pandora_console/include/web2image.js index 6c2edeb47c..f94c8420b3 100644 --- a/pandora_console/include/web2image.js +++ b/pandora_console/include/web2image.js @@ -4,8 +4,6 @@ if (system.args.length < 3 || system.args.length > 11) { phantom.exit(1); } -var webPage = require('webpage'); -var page = webPage.create(); var url = system.args[1]; var type_graph_pdf = system.args[2]; var url_params = system.args[3]; @@ -39,26 +37,32 @@ else{ "&session_id=" + session_id; } + + +var page = require('webpage').create(); + + page.viewportSize = { width: viewport_width, height: viewport_height }; + page.zoomFactor = 1; -page.open(url, 'POST', post_data, function start(status) { -}); - -page.onLoadFinished = function (status) { +page.onCallback = function (st){ if(!base_64){ page.render(output_filename, {format: 'png'}); - } - else{ + } else{ var base64 = page.renderBase64('png'); - //XXXX + // do not remove this console.output console.log(base64); } phantom.exit(); -} + +}; +page.open(url, 'POST', post_data, function (status) { +}); + diff --git a/pandora_console/index.php b/pandora_console/index.php index 101196ba21..776e0d8eb2 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -120,6 +120,7 @@ if (isset($config["error"])) { // If metaconsole activated, redirect to it if ($config['metaconsole'] == 1 && $config['enterprise_installed'] == 1) { header ("Location: " . $config['homeurl'] . "enterprise/meta"); + exit; //Always exit after sending location headers } if (file_exists (ENTERPRISE_DIR . "/include/functions_login.php")) { @@ -562,12 +563,13 @@ if (! isset ($config['id_user'])) { $query_params_redirect = $_GET; // Visual console do not want sec2 if($home_page == 'Visual console') unset($query_params_redirect["sec2"]); - $redirect_url = '?1=1'; + $redirect_url = '?logged=1'; foreach ($query_params_redirect as $key => $value) { if ($key == "login") continue; $redirect_url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); } header("Location: ".$config['homeurl']."index.php".$redirect_url); + exit; //Always exit after sending location headers } // Hash login process elseif (isset ($_GET["loginhash"])) { @@ -810,7 +812,7 @@ if (isset ($_GET["bye"])) { include ("general/logoff.php"); $iduser = $_SESSION["id_usuario"]; db_logoff ($iduser, $_SERVER['REMOTE_ADDR']); - // Unregister Session (compatible with 5.2 and 6.x, old code was deprecated + $_SESSION = array(); session_destroy(); header_remove("Set-Cookie"); diff --git a/pandora_console/install.php b/pandora_console/install.php old mode 100755 new mode 100644 index 5459cb7d3f..1a829ef068 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -66,12 +66,41 @@ document.getElementById('tr_dbgrant').style["display"] = "none"; } } + function popupShow(){ + document.getElementsByTagName('body')[0].style["margin"] = "0"; + document.getElementById('install_container').style["padding-top"] = "45px"; + document.getElementById('install_container').style["margin-top"] = "0"; + document.getElementById('add-lightbox').style["visibility"] = "visible"; + document.getElementById('open_popup').style["display"] = "block"; + document.getElementById('open_popup').style["visibility"] = "visible"; + } + function popupClose(){ + document.getElementById('add-lightbox').style["visibility"] = "hidden"; + document.getElementById('open_popup').style["display"] = "none"; + document.getElementById('open_popup').style["visibility"] = "hidden"; + } </script> <body> + <div id='add-lightbox' onclick='popupClose();' class='popup-lightbox'></div> + <div id='open_popup' class='popup' style='visibility:hidden;display: block;'> + <div class='popup-title'> + <span id='title_popup'>Warning</span> + <a href='#' onclick='popupClose();'><img src='./images/icono_cerrar.png' alt='close' title='Close' style='float:right;'/></a> + </div> + <div id='editor_section' class='popup-inner' style='padding: 20px 40px;'> + <?php + echo "<p><strong>Attention</strong>, you are going to <strong>overwrite the data</strong> of your current installation.</p><p>This means that if you do not have a backup <strong>you will irremissibly LOSE ALL THE STORED DATA</strong>, the configuration and everything relevant to your installation.</p><p><strong>Are you sure of what you are going to do?</strong></p>"; + echo "<div style='text-align:right;';>"; + echo "<a id='step4popup' href='install.php?step=4'><button type='submit' class='btn_install_next'><span class='btn_install_next_text'>Yes, I'm sure I want to delete everything</span></button></a>"; + echo "<a href='javascript:popupClose();'><button type='submit' class='btn_install_next popup-button-green'><span class='btn_install_next_text'>Cancel</span></button></a>"; + echo "</div>"; + ?> + </div> + </div> <div style='height: 10px'> <?php $version = '7.0NG.729'; -$build = '181121'; +$build = '181205'; $banner = "v$version Build $build"; error_reporting(0); @@ -343,7 +372,7 @@ function adjust_paths_for_freebsd($engine, $connection = false) { function install_step1() { global $banner; - + echo " <div id='install_container'> <div id='wizard'> @@ -608,7 +637,7 @@ function install_step3() { echo " <td valign=top>Drop Database if exists<br> - <input class='login' type='checkbox' name='drop' value=1> + <input class='login' type='checkbox' name='drop' id='drop' value=1> </td>"; echo "<td>Full path to HTTP publication directory<br> @@ -637,8 +666,23 @@ function install_step3() { if (!$error) { echo "<div style='text-align:right; width:100%;'>"; echo "<a id='step4' href='install.php?step=4'> - <button class='btn_install_next' type='submit'><span class='btn_install_next_text'>Next</span></button></a>"; + <button class='btn_install_next' type='submit' id='step4button'><span class='btn_install_next_text'>Next</span></button></a>"; echo "</div>"; + ?> + <script type="text/javascript"> + var checkDrop = document.getElementById('step4button').addEventListener("click", function(event){ + if(document.getElementById("drop").checked){ + popupShow(); + } + else{ + document.getElementsByName('step2_form')[0].submit(); + } + event.preventDefault(); + }); + var step3_form = document.getElementsByName('step2_form')[0]; + step3_form.addEventListener("submit", checkDrop, true); + </script> + <?php } echo "</div>"; diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index 67cd549c76..6bb416c74a 100755 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -1369,4 +1369,8 @@ DIV.nodata_container { } .legend_graph td.legendLabel { font-size: 12px !important; -} \ No newline at end of file +} + +.ui-popup-hidden { + display: none; +} diff --git a/pandora_console/mobile/include/system.class.php b/pandora_console/mobile/include/system.class.php index d2c45f0e6c..cb365f95f1 100644 --- a/pandora_console/mobile/include/system.class.php +++ b/pandora_console/mobile/include/system.class.php @@ -23,9 +23,7 @@ class System { $this->loadConfig(); $session_id = session_id(); DB::getInstance($this->getConfig('db_engine', 'mysql')); - if (empty($session_id)) { - session_start(); - } + if (session_status() === PHP_SESSION_NONE) session_start(); $this->session = $_SESSION; session_write_close(); @@ -71,7 +69,7 @@ class System { } public function setSessionBase($name, $value) { - session_start(); + if (session_status() === PHP_SESSION_NONE) session_start(); $_SESSION[$name] = $value; session_write_close(); } @@ -79,7 +77,7 @@ class System { public function setSession($name, $value) { $this->session[$name] = $value; - session_start(); + if (session_status() === PHP_SESSION_NONE) session_start(); $_SESSION = $this->session; session_write_close(); } @@ -94,7 +92,7 @@ class System { } public function sessionDestroy() { - session_start(); + if (session_status() === PHP_SESSION_NONE) session_start(); session_destroy(); } diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 368f00a25d..8b0a4f28a2 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -25,7 +25,13 @@ require_once("include/system.class.php"); require_once("include/db.class.php"); require_once("include/user.class.php"); -require_once('../include/config.php'); +/* Info: + * The classes above doesn't start any session before it's properly + * configured into the file below, but it's important the classes + * exist at the time the session is started for things like + * serializing objects stored into the session. + */ +require_once '../include/config.php'; require_once('operation/home.php'); require_once('operation/tactical.php'); @@ -79,7 +85,6 @@ $system = System::getInstance(); require_once($system->getConfig('homedir').'/include/constants.php'); $user = User::getInstance(); - $user->saveLogin(); $default_page = 'home'; diff --git a/pandora_console/operation/agentes/ehorus_client.php b/pandora_console/operation/agentes/ehorus_client.php index ebff0f78c6..ca0a10f194 100644 --- a/pandora_console/operation/agentes/ehorus_client.php +++ b/pandora_console/operation/agentes/ehorus_client.php @@ -13,12 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - -if (! isset($_SESSION['id_usuario'])) { - session_start(); -} - -// Global & session management +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once('../../include/config.php'); require_once($config['homedir'] . '/include/functions.php'); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index e6f5a0d289..751f4f481c 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -645,7 +645,7 @@ $data[0][0] .= __('Events (24h)') . '</th></tr>' . '<tr><td style="text-align:center;padding-left:20px;padding-right:20px;"><br />' . - graph_graphic_agentevents ($id_agente, 450, 40, SECONDS_1DAY, '', true, true) . + graph_graphic_agentevents ($id_agente, 100, 45, SECONDS_1DAY, '', true, true) . '<br /></td></tr>' . '</table>'; diff --git a/pandora_console/operation/agentes/export_csv.php b/pandora_console/operation/agentes/export_csv.php index 473f40aef7..16745def93 100644 --- a/pandora_console/operation/agentes/export_csv.php +++ b/pandora_console/operation/agentes/export_csv.php @@ -13,8 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start (); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); require_once ("../../include/functions.php"); require_once ("../../include/functions_db.php"); diff --git a/pandora_console/operation/agentes/exportdata.csv.php b/pandora_console/operation/agentes/exportdata.csv.php index df692040e9..39a72e5cdb 100644 --- a/pandora_console/operation/agentes/exportdata.csv.php +++ b/pandora_console/operation/agentes/exportdata.csv.php @@ -13,8 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start (); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); require_once ("../../include/functions_agents.php"); require_once ("../../include/functions_reporting.php"); diff --git a/pandora_console/operation/agentes/exportdata.excel.php b/pandora_console/operation/agentes/exportdata.excel.php index f289dc1405..b7ac7796d9 100644 --- a/pandora_console/operation/agentes/exportdata.excel.php +++ b/pandora_console/operation/agentes/exportdata.excel.php @@ -13,8 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start (); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); require_once ("../../include/functions_agents.php"); require_once ("../../include/functions_reporting.php"); diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index 4265bd7985..7346e90805 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -13,13 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - -if (! isset($_SESSION['id_usuario'])) { - session_start(); - session_write_close(); -} - -// Global & session management +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('../../include/config.php'); require_once ($config['homedir'] . '/include/auth/mysql.php'); require_once ($config['homedir'] . '/include/functions.php'); @@ -30,7 +25,7 @@ require_once ($config['homedir'] . '/include/functions_custom_graphs.php'); require_once ($config['homedir'] . '/include/functions_modules.php'); require_once ($config['homedir'] . '/include/functions_agents.php'); require_once ($config['homedir'] . '/include/functions_tags.php'); -enterprise_include_once('include/functions_agents.php'); +enterprise_include_once ('include/functions_agents.php'); check_login(); diff --git a/pandora_console/operation/agentes/realtime_win.php b/pandora_console/operation/agentes/realtime_win.php index d2644e6215..55a27c7c34 100644 --- a/pandora_console/operation/agentes/realtime_win.php +++ b/pandora_console/operation/agentes/realtime_win.php @@ -13,13 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - -if (! isset($_SESSION['id_usuario'])) { - session_start(); - //session_write_close(); -} - -// Global & session management +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('../../include/config.php'); require_once ($config['homedir'] . '/include/auth/mysql.php'); require_once ($config['homedir'] . '/include/functions.php'); diff --git a/pandora_console/operation/agentes/snapshot_view.php b/pandora_console/operation/agentes/snapshot_view.php index b66ab4e9ed..e386514aec 100644 --- a/pandora_console/operation/agentes/snapshot_view.php +++ b/pandora_console/operation/agentes/snapshot_view.php @@ -13,12 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - -if (! isset($_SESSION['id_usuario'])) { - session_start(); - //session_write_close(); -} - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('../../include/config.php'); require_once ($config['homedir'] . '/include/auth/mysql.php'); require_once ($config['homedir'] . '/include/functions.php'); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 17aa544503..adb210dd70 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -13,13 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - -if (! isset($_SESSION['id_usuario'])) { - session_start(); - //session_write_close(); -} - -// Global & session management +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('../../include/config.php'); require_once ($config['homedir'] . '/include/auth/mysql.php'); require_once ($config['homedir'] . '/include/functions.php'); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index cc35c8f147..efc5b53120 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -336,6 +336,16 @@ if (is_ajax ()) { $filter .= ' AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions; } + $sql_tags_join = ""; + $where_tags = ""; + if (tags_has_user_acl_tags($config['id_user'])) { + $where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR', + 'module_condition', 'AND', 'tagente_modulo', false, array(), true); + + $sql_tags_join = "INNER JOIN tagente ON tagente.id_agente = t1.id_agente + INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo"; + } + if (is_metaconsole()) { $result = array(); $nameModules = array(); @@ -396,9 +406,10 @@ if (is_ajax ()) { } //Get agent's modules - $sql = sprintf('SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre - FROM tagente_modulo t1 - WHERE %s + $sql = sprintf( + 'SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre + FROM tagente_modulo t1 %s + WHERE %s %s AND t1.delete_pending = 0 AND t1.id_agente IN (%s) AND ( @@ -407,7 +418,7 @@ if (is_ajax ()) { WHERE t2.delete_pending = 0 AND t1.nombre = t2.nombre AND t2.id_agente IN (%s)) = (%d)', - $filter, implode(',', $id_agents), + $sql_tags_join, $filter, $where_tags, implode(',', $id_agents), implode(',', $id_agents), count($id_agents)); $modules = db_get_all_rows_sql($sql); @@ -458,34 +469,27 @@ if (is_ajax ()) { } else { if($idAgents[0] < 0){ - if($selection_mode == 'common'){ + if($selection_mode == 'common') { $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'; $agent_total = db_get_value_sql($sql_agent_total); - $sql = "SELECT tam.nombre, tam.id_agente_modulo - FROM tagente_modulo tam - JOIN ( - SELECT COUNT(*) AS num_names, nombre - FROM tagente_modulo - WHERE disabled=0 - AND delete_pending=0 - GROUP BY nombre - ) AS tj - ON tj.num_names = $agent_total - AND tj.nombre = tam.nombre "; - } - else{ - $sql = 'SELECT nombre, id_agente_modulo - FROM tagente_modulo'; + $sql = sprintf ("SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 + JOIN (SELECT COUNT(*) AS num_names, nombre FROM tagente_modulo + WHERE disabled=0 AND delete_pending=0 GROUP BY nombre) AS tj + ON tj.num_names = $agent_total AND tj.nombre = t1.nombre %s %s", + $sql_tags_join, (empty($where_tags)) ? "" : " WHERE 1=1 $where_tags"); + } else { + $sql = sprintf('SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 %s %s', + $sql_tags_join, (empty($where_tags)) ? "" : " WHERE 1=1 $where_tags"); } } else { - $sql = 'SELECT DISTINCT nombre, t1.id_agente_modulo - FROM tagente_modulo t1, tagente_estado t2 - WHERE t1.id_agente_modulo = t2.id_agente_modulo AND - ' . $filter . ' - AND t1.delete_pending = 0 - AND t1.id_agente IN (' . implode(',', $idAgents) . ') - AND t2.datos NOT LIKE "%image%"'; + $sql = sprintf ( + 'SELECT DISTINCT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 + INNER JOIN tagente_estado t2 ON t1.id_agente_modulo = t2.id_agente_modulo + %s WHERE %s AND t1.delete_pending = 0 + AND t1.id_agente IN ('. implode(',', $idAgents) .') + %s %s', + $sql_tags_join, $filter, ' AND t2.datos NOT LIKE "%image%"', $where_tags); if ($selection_mode == 'common') { $sql .= ' AND ( diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 16f43397ba..92b7eecad8 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -78,10 +78,13 @@ if ($group_rep == 2) { $table->head[1] = __('Agent'); $table->head[5] = __('More detail'); - $url = html_print_sort_arrows( - array_merge($params, array('sort_field' => 'status')), - 'sort' - ); + //$url = html_print_sort_arrows( + // array_merge($params, array('sort_field' => 'status')), + // 'sort' + //); + + $params_sort_field_status = array_merge($params, array('sort_field' => 'status')); + $url = "index.php?" . http_build_query($params_sort_field_status, '', '&'); foreach ($result as $key => $res) { @@ -164,14 +167,6 @@ else { $table->align[$i] = 'left'; $i++; } - if ($fields == 'estado') { - $table->head[$i] = __('Status') . html_print_sort_arrows( - array_merge($params, array('sort_field' => 'status')), - 'sort' - ); - $table->align[$i] = 'left'; - $i++; - } if ($fields == 'id_evento') { $table->head[$i] = __('Event ID') . html_print_sort_arrows( array_merge($params, array('sort_field' => 'event_id')), @@ -341,6 +336,18 @@ else { $i++; } } + + if (in_array('estado', $show_fields)) { + $table->head[$i] = '<span style="white-space: nowrap;">'.__('Status') . html_print_sort_arrows( + array_merge($params, array('sort_field' => 'status')), + 'sort' + ).'</span>'; + $table->align[$i] = 'left'; + $table->style[$i] = 'white-space: nowrap !important; width: 1px !important;'; + $i++; + } + + if ($i != 0 && $allow_action) { $table->head[$i] = __('Action'); $table->align[$i] = 'left'; @@ -491,14 +498,6 @@ else { $table->cellclass[count($table->data)][$i] = $myclass; $i++; } - if ($fields == 'estado') { - $data[$i] = html_print_image ($img_st, true, - array ("class" => "image_status", - "title" => $title_st, - "id" => 'status_img_'.$event["id_evento"])); - $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; - $i++; - } if ($fields == 'id_evento') { $data[$i] = $event["id_evento"]; $table->cellclass[count($table->data)][$i] = $myclass; @@ -777,6 +776,15 @@ else { $i++; } } + + if (in_array('estado', $show_fields)) { + $data[$i] = html_print_image ($img_st, true, + array ("class" => "image_status", + "title" => $title_st, + "id" => 'status_img_'.$event["id_evento"])); + $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3; white-space: nowrap; width: 1px;'; + $i++; + } if ($i != 0 && $allow_action) { //Actions diff --git a/pandora_console/operation/events/events_marquee.php b/pandora_console/operation/events/events_marquee.php index e3b04e39da..12425fd3b6 100644 --- a/pandora_console/operation/events/events_marquee.php +++ b/pandora_console/operation/events/events_marquee.php @@ -13,18 +13,18 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start (); - error_reporting(1); // Local settings for marquee extension - $MAX_MARQUEE_EVENTS=10; $MARQUEE_INTERVAL=90; $MARQUEE_FONT_SIZE="32px"; $MARQUEE_SPEED=12; $output = ""; + +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once "../../include/config.php"; require_once "../../include/functions.php"; require_once "../../include/functions_db.php"; diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index 4b342b0d97..84c3e849e8 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -13,8 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -session_start(); - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); require_once ("../../include/auth/mysql.php"); require_once ("../../include/functions.php"); @@ -23,8 +23,6 @@ require_once ("../../include/functions_events.php"); require_once ("../../include/functions_agents.php"); require_once ('../../include/functions_groups.php'); -session_write_close (); - $config["id_user"] = $_SESSION["id_usuario"]; if (! check_acl ($config["id_user"], 0, "ER") && ! check_acl ($config["id_user"], 0, "EW") && ! check_acl ($config["id_user"], 0, "EM")) { diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index d8e3ce8cd3..a7fbce6667 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -13,14 +13,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Real start -session_start (); - -// Load global vars -if ((! file_exists("../../include/config.php")) || (! is_readable("../../include/config.php"))) { - exit; -} - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ('../../include/config.php'); require_once ('../../include/functions.php'); require_once ('../../include/functions_db.php'); diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 3389e77220..64fd688080 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -12,14 +12,13 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Real start - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); // Set root on homedir, as defined in setup chdir ($config["homedir"]); -session_start (); ob_start (); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"; echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n"; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index ab689385e7..2c33acdea6 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -491,7 +491,7 @@ $data[0] .= $table_ichanges; //time autorefresh $times = get_refresh_time_array(); -$data[1] = '<span style="width:40%;float:left;">'.__('Time autorefresh').'</span>'; +$data[1] = '<span style="width:40%;float:left;">'.__('Time autorefresh'). ui_print_help_tip(__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), true).'</span>'; $data[1] .= $jump . '<span style="width:20%;float:left;">'. html_print_select ($times, 'time_autorefresh', $user_info["time_autorefresh"], '', '', '', true,false,false).'</span>'; $table->rowclass[] = ''; diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index 396ddb2800..f5bd5697df 100755 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -13,14 +13,13 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Real start - +// Don't start a session before this import. +// The session is configured and started inside the config process. require_once ("../../include/config.php"); // Set root on homedir, as defined in setup chdir ($config["homedir"]); -session_start (); ob_start (); /* Enterprise support */ if (file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 877be02be3..145be59b50 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 7.0NG.729 -%define release 181121 +%define release 181205 # User and Group under which Apache is running %define httpd_name httpd @@ -29,7 +29,7 @@ Requires: %{httpd_name} >= 2.0.0 Requires: mod_php >= 5.2.0 Requires: php-gd, php-ldap, php-snmp, php-session, php-gettext Requires: php-mysqlnd, php-mbstring, php-zip, php-zlib, php-curl -Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc +Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc, php-pecl-zip Requires: graphviz Provides: %{name}-%{version} diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index b7941f08d2..ec6e768186 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.729 -%define release 181121 +%define release 181205 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 @@ -27,7 +27,8 @@ Prefix: /srv/www/htdocs BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 -Requires: apache2, apache2-mod_php5 +Requires: apache2 +Requires: (apache2-mod_php5 or apache2-mod_php7) Requires: php >= 4.3.0 Requires: php-gd, php-snmp, php-json, php-gettext Requires: php-mysqlnd, php-ldap, php-mbstring, php diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 9e5545219d..054204d85a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3371,5 +3371,8 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `id_custom_fields_data` varchar(600) default '', `id_status` varchar(600) default '', `module_search` varchar(600) default '', + `module_status` varchar(600) default '', + `recursion` int(1) unsigned default '0', + `group_search` int(10) unsigned default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9bca5cc191..53b7b79257 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 22), +('MR', 23), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '729'), +('current_package_enterprise', '730'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'), diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index a4ab83e706..9c5df40153 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.729-181121 +Version: 7.0NG.729-181205 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 5d28162df1..e40f00fd64 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="7.0NG.729-181121" +pandora_version="7.0NG.729-181205" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_exec b/pandora_server/bin/pandora_exec index 4ccee8a1f9..d6d5da1c8c 100755 --- a/pandora_server/bin/pandora_exec +++ b/pandora_server/bin/pandora_exec @@ -36,7 +36,7 @@ my @opts = @ARGV; my $timeout = shift(@opts); my $command; foreach my $arg (@opts) { - $command .= $^O ne 'MSWin32' ? quotemeta ($arg) . ' ' : '"' . $command . '" '; + $command .= $^O ne 'MSWin32' ? quotemeta ($arg) . ' ' : '"' . $arg . '" '; } chomp ($command); my $output = ''; diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 30423808c9..3d34777910 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.729"; -my $pandora_build = "181121"; +my $pandora_build = "181205"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -507,7 +507,7 @@ sub pandora_load_config { } # Collect items from config file and put in an array - if (! open (CFG, "< $archivo_cfg")) { + if (! open (CFG, "<:encoding(UTF-8)", $archivo_cfg)) { print "[ERROR] Error opening configuration file $archivo_cfg: $!.\n"; exit 1; } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 5f4a574832..be948e9415 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -111,6 +111,7 @@ use warnings; use DBI; use Encode; +use Encode::CN; use XML::Simple; use HTML::Entities; use Time::Local; @@ -4579,7 +4580,7 @@ Process groups statistics for statistics table ########################################################################## sub pandora_process_event_replication ($) { my $pa_config = shift; - + my $dbh_metaconsole; my %pa_config = %{$pa_config}; # Get the console DB connection @@ -4593,46 +4594,57 @@ sub pandora_process_event_replication ($) { # desactivated the event replication or the replication # interval is wrong: abort if($is_event_replication_enabled == 0) { + db_disconnect($dbh); return; } if($replication_interval <= 0) { - logger($pa_config, "Replication interval configuration is not a value greater than 0. Event replication thread will be aborted.", 1); + logger($pa_config, "The event replication interval must be greater than 0. Event replication aborted.", 1); + db_disconnect($dbh); return; } - # Get the metaconsole DB connection - my $dbh_metaconsole = enterprise_hook('get_metaconsole_dbh', [$pa_config, $dbh]); - - if($dbh_metaconsole eq '') { - logger($pa_config, "Metaconsole DB connection error. Event replication thread will be aborted.", 1); - return; - } - - # Get server id on metaconsole - my $metaconsole_server_id = enterprise_hook('get_metaconsole_setup_server_id', [$dbh_metaconsole, safe_input($pa_config->{'servername'})]); - - # If the server name is not found in metaconsole setup: abort - if($metaconsole_server_id == -1) { - logger($pa_config, "The server name is not configured in metaconsole. Event replication thread will be aborted.", 1); - return; - } - - my $replication_mode = enterprise_hook('get_event_replication_mode', [$dbh]); - - logger($pa_config, "Starting replication events process.", 1); + logger($pa_config, "Started event replication thread.", 1); while($THRRUN == 1) { - - # If we are not the master server sleep and check again. - if (pandora_is_master($pa_config) == 0) { - sleep ($pa_config->{'server_threshold'}); - next; - } - - # Check the queue each N seconds + eval {{ + local $SIG{__DIE__}; + + # Get the metaconsole DB connection + $dbh_metaconsole = enterprise_hook('get_metaconsole_dbh', [$pa_config, $dbh]); + $dbh_metaconsole = undef if $dbh_metaconsole eq ''; + if (!defined($dbh_metaconsole)) { + logger($pa_config, "Metaconsole DB connection error. Event replication postponed.", 5); + next; + } + + # Get server id on metaconsole + my $metaconsole_server_id = enterprise_hook('get_metaconsole_setup_server_id', [$dbh_metaconsole, safe_input($pa_config->{'servername'})]); + + # If the server name is not found in metaconsole setup: abort + if($metaconsole_server_id == -1) { + logger($pa_config, "The server name is not configured in metaconsole. Event replication postponed.", 5); + db_disconnect($dbh_metaconsole); + next; + } + + my $replication_mode = enterprise_hook('get_event_replication_mode', [$dbh]); + + while($THRRUN == 1) { + + # If we are not the master server sleep and check again. + if (pandora_is_master($pa_config) == 0) { + sleep ($pa_config->{'server_threshold'}); + next; + } + + # Check the queue each N seconds + enterprise_hook('pandora_replicate_copy_events',[$pa_config, $dbh, $dbh_metaconsole, $metaconsole_server_id, $replication_mode]); + sleep ($replication_interval); + } + }}; + db_disconnect($dbh_metaconsole) if defined($dbh_metaconsole); sleep ($replication_interval); - enterprise_hook('pandora_replicate_copy_events',[$pa_config, $dbh, $dbh_metaconsole, $metaconsole_server_id, $replication_mode]); } db_disconnect($dbh); diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index d022c931d1..dc0622c98b 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -131,9 +131,6 @@ sub db_connect ($$$$$$) { # Enable character semantics $dbh->{'mysql_enable_utf8'} = 1; - # Tell the server to return UTF-8 strings. - $dbh->do("SET NAMES 'utf8';") if ($^O eq 'MSWin32'); - return $dbh; } elsif ($rdbms eq 'postgresql') { diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 9a98da7069..67db70593a 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -32,7 +32,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.729"; -my $pandora_build = "181121"; +my $pandora_build = "181205"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 5e5f58c4a8..cec179c499 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -68,6 +68,7 @@ our @EXPORT = qw( PROVISIONINGSERVER MIGRATIONSERVER METACONSOLE_LICENSE + OFFLINE_LICENSE $DEVNULL $OS $OS_VERSION @@ -93,6 +94,7 @@ our @EXPORT = qw( sqlWrap is_numeric is_metaconsole + is_offline to_number clean_blank pandora_sendmail @@ -152,9 +154,12 @@ use constant MODULE_WARNING => 2; use constant MODULE_UNKNOWN => 3; use constant MODULE_NOTINIT => 4; -# Value for a metaconsole license type +# Mask for a metaconsole license type use constant METACONSOLE_LICENSE => 0x01; +# Mask for an offline license type +use constant OFFLINE_LICENSE => 0x02; + # Alert modes use constant RECOVERED_ALERT => 0; use constant FIRED_ALERT => 1; @@ -170,6 +175,7 @@ if ($OS eq 'linux') { } elsif ($OS =~ /win/i) { $OS = "windows"; $OS_VERSION = `ver`; + $OS_VERSION =~ s/[^[:ascii:]]//g; $DEVNULL = '/Nul'; } elsif ($OS eq 'freebsd') { $OS_VERSION = `uname -r`; @@ -589,7 +595,7 @@ sub logger ($$;$) { open (FILE, ">> $file") or die "[FATAL] Could not open logfile '$file'"; # Get an exclusive lock on the file (LOCK_EX) flock (FILE, 2); - print FILE strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " " . $pa_config->{'servername'} . " [V". $level ."] " . $message . "\n"; + print FILE strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " " . (defined($pa_config->{'servername'}) ? $pa_config->{'servername'} : '') . " [V". $level ."] " . $message . "\n"; close (FILE); } } @@ -1639,7 +1645,7 @@ sub is_metaconsole ($) { my ($pa_config) = @_; if (defined($pa_config->{"license_type"}) && - $pa_config->{"license_type"} == METACONSOLE_LICENSE && + ($pa_config->{"license_type"} & METACONSOLE_LICENSE) && $pa_config->{"node_metaconsole"} == 0) { return 1; } @@ -1647,6 +1653,20 @@ sub is_metaconsole ($) { return 0; } +############################################################################### +# Returns 1 if a valid offline license is configured, 0 otherwise. +############################################################################### +sub is_offline ($) { + my ($pa_config) = @_; + + if (defined($pa_config->{"license_type"}) && + ($pa_config->{"license_type"} & OFFLINE_LICENSE)) { + return 1; + } + + return 0; +} + ############################################################################### # Check if a given variable contents a number ############################################################################### diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 290a90f1a5..c29caad2c2 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 7.0NG.729 -%define release 181121 +%define release 181205 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c0b3a82f13..252aad5895 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.729 -%define release 181121 +%define release 181205 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 7cbab42c65..3b7041493d 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181121" +PI_BUILD="181205" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 843b90bbf6..406a5702cb 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.729 PS181121"; +my $version = "7.0NG.729 PS181205"; # Pandora server configuration my %conf; @@ -1042,8 +1042,20 @@ else { # Connect to the DB my $dbh = db_connect ($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'}); -my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, - $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef; +my $history_dbh = undef; +is_metaconsole(\%conf); +if ($conf{'_history_db_enabled'} eq '1') { + eval { + $history_dbh = db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, $conf{'_history_db_pass'}); + }; + if ($@) { + if (is_offline(\%conf)) { + log_message ('!', "Cannot connect to the history database. Skipping."); + } else { + die ("$@\n"); + } + } +} # Get a lock my $lock = db_get_lock ($dbh, 'pandora_db'); @@ -1055,13 +1067,13 @@ if ($lock == 0 && $conf{'_force'} == 0) { # Main pandoradb_main(\%conf, $dbh, $history_dbh); -# Cleanup and exit -db_disconnect ($history_dbh) if defined ($history_dbh); -db_disconnect ($dbh); - # Release the lock if ($lock == 1) { db_release_lock ($dbh, 'pandora_db'); } -exit 0; \ No newline at end of file +# Cleanup and exit +db_disconnect ($history_dbh) if defined ($history_dbh); +db_disconnect ($dbh); + +exit 0; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index a3d53df2fe..1c226ad44e 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.729 PS181121"; +my $version = "7.0NG.729 PS181205"; # save program name for logging my $progname = basename($0); diff --git a/pandora_server/util/pwrd/config.json b/pandora_server/util/pwrd/config.json new file mode 100644 index 0000000000..a93b44f7b7 --- /dev/null +++ b/pandora_server/util/pwrd/config.json @@ -0,0 +1,21 @@ +{ + "capabilities": [ + { + "browserName": "*firefox", + "maxInstances": 1, + "seleniumProtocol": "Selenium" + }, + { + "browserName": "firefox", + "maxInstances": 1, + "seleniumProtocol": "WebDriver" + } + ], + "configuration": { + "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", + "maxSession": 1, + "port": 5555, + "register": true, + "registerCycle": 5000 + } +} \ No newline at end of file diff --git a/pandora_server/util/pwrd/extras/crontab_entries_sample b/pandora_server/util/pwrd/extras/crontab_entries_sample new file mode 100644 index 0000000000..8dc9018ef5 --- /dev/null +++ b/pandora_server/util/pwrd/extras/crontab_entries_sample @@ -0,0 +1,20 @@ +# Sample PWRD crontab control tweaks + +# Do not allow firefox running for more than 1h +0 * * * * root /opt/pwrd_maintenance.sh -k + +# Force node-start +*/5 * * * * root /opt/pwrd_maintenance.sh -s + +# Reset firefox version if does not match required 47.0.1 +* * * * * root /opt/pwrd_maintenance.sh -f + +# Restart node if java process is not found +* * * * * root /opt/pwrd_maintenance.sh -r + +# Restart node if no activity since last check +*/5 * * * * root /opt/pwrd_maintenance.sh -c1 + +# Restart node if connection have been lost to hub +*/5 * * * * root /opt/pwrd_maintenance.sh -c2 + diff --git a/pandora_server/util/pwrd/extras/pwrd_maintenance.sh b/pandora_server/util/pwrd/extras/pwrd_maintenance.sh new file mode 100755 index 0000000000..cc71eefb9f --- /dev/null +++ b/pandora_server/util/pwrd/extras/pwrd_maintenance.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# Sample PWRD maintenance script +# ********************************************************************** + +# ********************************************************************** +# Settings +hub_ip="192.168.1.10" +hub_port="4444" + +# Customize PWR global installation directory +PWR_FIREFOX_INSTALLDIR="/opt" + +# ********************************************************************** + +if [ "$1" == "-k" ]; then + killall --older-than 1h firefox >/dev/null 2>&1 + +elif [ "$1" == "-s" ]; then + /etc/init.d/pwrd start-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 + +elif [ "$1" == "-f" ]; then + if [ "`firefox --version`" != "Mozilla Firefox 47.0.1" ]; then + $PWR_FIREFOX_INSTALLDIR/restore_firefox.sh >/dev/null 2>&1 + echo `date +"%c"` Firefox restored > /tmp/restore_firefox.log + [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 + [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 + fi + +elif [ "$1" == "-r" ]; then + if [ ` ps aux | grep "java -jar" | grep -v grep | wc -l` -lt 1 ]; then + [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 + [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 + echo `date +"%c"` PWRD restarted, java process not found > /tmp/pwrd_restart_detected.log + fi + +elif [ "$1" == "-c1" ]; then + if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd ".*" | wc -l) -eq 0 ]; then + [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 + [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 + echo $(date +"%c") PWRD restarted, no output detected in log > /tmp/pwrd_restart_detected.log + fi + +elif [ "$1" == "-c2" ]; then + if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd_err_conn "refused" | grep "$hub_ip:$hub_port [/$hub_ip] failed:" | wc -l) -gt 0 ]; then + /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 + echo $(date +"%c") PWRD restarted, lost connection with hub > /tmp/pwrd_restart_detected.log + fi +fi + + + diff --git a/pandora_server/util/pwrd/extras/restore_firefox.sh b/pandora_server/util/pwrd/extras/restore_firefox.sh new file mode 100755 index 0000000000..245a7dde19 --- /dev/null +++ b/pandora_server/util/pwrd/extras/restore_firefox.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Script to restore firefox to tar +# +# ********************************************************************** + +# Customize PWR global installation directory +PWR_FIREFOX_INSTALLDIR="/opt" + +cd $PWR_FIREFOX_INSTALLDIR + +if [ -f firefox-47.0.1.tar ]; then + rm -rf firefox-47 >/dev/null 2>&1 + mv firefox firefox_ >/dev/null 2>&1 + tar xvf firefox-47.0.1.tar >/dev/null 2>&1 + mv firefox firefox-47 >/dev/null 2>&1 + mv firefox_ firefox >/dev/null 2>&1 +else + echo "firefox-47.0.1.tar not found, please leave a copy at $PWR_FIREFOX_INSTALLDIR" +fi diff --git a/pandora_server/util/pwrd/firefox-43.0.tar b/pandora_server/util/pwrd/firefox-43.0.tar deleted file mode 100644 index 39fb813ea0..0000000000 Binary files a/pandora_server/util/pwrd/firefox-43.0.tar and /dev/null differ diff --git a/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id b/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id new file mode 100644 index 0000000000..03f39ef914 --- /dev/null +++ b/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id @@ -0,0 +1 @@ +4881ba55982d75040775bafdffcdf57b2cd7ea13 \ No newline at end of file diff --git a/pandora_server/util/pwrd/install_pwrd.sh b/pandora_server/util/pwrd/install_pwrd.sh old mode 100644 new mode 100755 index 2de6b11e3d..e36d87b640 --- a/pandora_server/util/pwrd/install_pwrd.sh +++ b/pandora_server/util/pwrd/install_pwrd.sh @@ -1,7 +1,6 @@ #!/bin/bash -if [ "$1" == "" ] || [ "$1" != "--install" ]; then - cat<<_HELP +HELP=`cat<<_HELP ********************** PWR Server installer ********************** @@ -9,44 +8,91 @@ if [ "$1" == "" ] || [ "$1" != "--install" ]; then To install the Pandora web robot daemon (pwrd) Please launch this script as root: -$0 --install +$0 --install [[user] [directory]] _HELP +` + +if [ "$1" == "" ] || [ "$1" != "--install" ]; then + echo "$HELP" exit 0 fi -if [ "`rpm -qa | grep xorg-x11-server-Xvfb | wc -l`" == "0" ]; then - echo "Package xorg-x11-server-Xvfb is required" - exit 0 +if [ "`which rpm`" ]; then + if [ "`rpm -qa | grep xorg-x11-server-Xvfb | wc -l`" == "0" ]; then + echo "Package xorg-x11-server-Xvfb is required" + exit 0 + fi +else + echo "Xvfb is required, please confirm is installed in your system" +fi + +# default user is running user +GLOBAL_INST_USER=`whoami` + +if [ "$2" != "" ]; then + if [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$2" | wc -l` -gt 0 ]; then + GLOBAL_INST_USER=$2 + elif [ -d "$2" ]; then + GLOBAL_INST_DIR=$2 + else + echo "Cannot use \"$2\" as user nor directory" + echo "$HELP" + exit 0 + fi +fi + +if [ "$3" != "" ]; then + if [ -d "$3" ]; then + GLOBAL_INST_DIR=$3 + elif [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$3" | wc -l` -gt 0 ]; then + GLOBAL_INST_USER=$3 + else + echo "Cannot use \"$3\" as directory nor user" + echo "$HELP" + exit 0 + fi fi chmod +x pwrd -PWR_SERVER_DEST=/usr/lib/pwr -PWR_SERVER_RSC=/etc/pwr/tmp -PWR_SERVER_LOG=/var/log/pwr -PWR_FIREFOX_INSTALLDIR=/opt +PWR_SERVER_DEST=$GLOBAL_INST_DIR/usr/lib/pwr +PWR_SERVER_RSC=$GLOBAL_INST_DIR/etc/pwr/tmp +PWR_SERVER_LOG=$GLOBAL_INST_DIR/var/log/pwr +PWR_FIREFOX_INSTALLDIR=$GLOBAL_INST_DIR/opt -mkdir -p $PWR_SERVER_DEST -mkdir -p $PWR_SERVER_LOG -mkdir -p $PWR_SERVER_RSC -mkdir -p $PWR_FIREFOX_INSTALLDIR +PWR_FIREFOX_INSTALLDIR_ESCAPED=`echo $PWR_FIREFOX_INSTALLDIR | sed 's/\\//\\\\\//g'` +GLOBAL_INST_DIR_ESCAPED=`echo $GLOBAL_INST_DIR | sed 's/\\//\\\\\//g'` +[ -d $PWR_SERVER_DEST ] || mkdir -p $PWR_SERVER_DEST +[ -d $PWR_SERVER_LOG ] || mkdir -p $PWR_SERVER_LOG +[ -d $PWR_SERVER_RSC ] || mkdir -p $PWR_SERVER_RSC +[ -d $PWR_FIREFOX_INSTALLDIR ] || mkdir -p $PWR_FIREFOX_INSTALLDIR +[ -d $GLOBAL_INST_DIR/etc/init.d ] || mkdir -p $GLOBAL_INST_DIR/etc/init.d -tar xvf firefox-43.0.tar >/dev/null -mv firefox $PWR_FIREFOX_INSTALLDIR/ +tar xvf firefox-47.0.1.tar >/dev/null +mv firefox $PWR_FIREFOX_INSTALLDIR/firefox-47 +ln -s $PWR_FIREFOX_INSTALLDIR/firefox-47/firefox $PWR_FIREFOX_INSTALLDIR/firefox tar xvzf firefox_profile.tar.gz >/dev/null -chown -R `whoami`. firefox_profile -mv firefox_profile $PWR_FIREFOX_INSTALLDIR +if [ $? -ne 0 ]; then + echo "Failed to deploy firefox profile, please retry installation" + exit 1 +fi +chown -R "$GLOBAL_INST_USER". firefox_profile +[ ! -d "$PWR_FIREFOX_INSTALLDIR/firefox_profile" ] && mv firefox_profile $PWR_FIREFOX_INSTALLDIR -ln -s $PWR_FIREFOX_INSTALLDIR/firefox/firefox /usr/bin/firefox +[ -d "$PWR_FIREFOX_INSTALLDIR/selenium" ] || mkdir -p $PWR_FIREFOX_INSTALLDIR/selenium + +cp config.json $PWR_FIREFOX_INSTALLDIR/selenium/ + +ln -s $PWR_FIREFOX_INSTALLDIR/firefox /usr/bin/firefox # Generate logrotate configuration - -cat > /etc/logrotate.d/pwrd <<EO_LROTATE +echo <<EO_LROTATE > /etc/logrotate.d/pwrd /var/log/pwr/pwr_std.log +/var/log/pwr/xvfb.log /var/log/pwr/pwr_error.log { weekly missingok @@ -60,10 +106,35 @@ cat > /etc/logrotate.d/pwrd <<EO_LROTATE EO_LROTATE +cp ./extras/restore_firefox.sh $PWR_FIREFOX_INSTALLDIR/ +cp ./extras/pwrd_maintenance.sh $PWR_FIREFOX_INSTALLDIR/ cp ./selenium-server-standalone-2.53.1.jar $PWR_SERVER_DEST/ cp ./pwrd /etc/init.d/pwrd +cp ./pwrd $GLOBAL_INST_DIR/etc/init.d/pwrd chmod +x /etc/init.d/pwrd +# Update pwrd daemon +if [ "$GLOBAL_INST_DIR" != "" ]; then + echo "Adjusting pwrd global directory to: $GLOBAL_INST_DIR" + sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" /etc/init.d/pwrd + sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd + echo "Adjusting pwrd_maintenance global directory to: $PWR_FIREFOX_INSTALLDIR" + sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/pwrd_maintenance.sh + echo "Adjusting restore_firefox global directory to: $PWR_FIREFOX_INSTALLDIR" + sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/restore_firefox.sh +fi + +if [ "$GLOBAL_INST_USER" != "" ]; then + echo "Adjusting pwrd global user to: $GLOBAL_INST_USER" + sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" /etc/init.d/pwrd + sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd +fi + + +[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_DEST +[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_LOG +[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_RSC + cat <<EOF ********************* PWR Server deployed @@ -71,10 +142,9 @@ cat <<EOF Succesfully installed! -Please start the service with: +Now you can start the service with: /etc/init.d/pwrd start EOF - diff --git a/pandora_server/util/pwrd/pwrd b/pandora_server/util/pwrd/pwrd index 08573f83aa..752689355f 100644 --- a/pandora_server/util/pwrd/pwrd +++ b/pandora_server/util/pwrd/pwrd @@ -1,9 +1,25 @@ #!/bin/bash -# pwr - this script starts and stops the pwr grid + +# ********************************************************************** +# Pandora FMS PWR Server Daemon +# (c) 2008-2018 Artica ST # -# chkconfig: - 85 1# description: PWRD Grid is a distributed testing platform for browser-based automation. +# Please see http://www.pandorafms.org +# ********************************************************************** + +### BEGIN INIT INFO +# Provides: pwrd +# Required-Start: $network +# Required-Stop: $network +# Default-Start: 2 3 5 +# Default-Stop: 0 1 6 +# Short-Description: Startup script daemon for PWR server +# Description: Startup script daemon for PWR server (linux) +### END INIT INFO + +# chkconfig: - 85 1 +# description: PWRD Grid is a distributed platform for browser-based automation. # processname: pwr -# pidfile: $base_dir/pwr.pid # Source function library. @@ -12,21 +28,55 @@ if [ -e /etc/rc.d/init.d/functions ]; then fi -pwr_dir=/usr/lib/pwr -log_dir=/var/log/pwr -std_log=$log_dir/pwr_std.log -base_dir=/etc/pwr/tmp -java=/usr/bin/java -pwr="$pwr_dir/selenium-server-standalone-2.53.1.jar" -# Following parameters will control node capabilities: -browser browserName=firefox,maxInstances=1,platform=LINUX -PWROPTS=" -firefoxProfileTemplate /opt/firefox_profile" -PWR_HUB_OPTS="" -user=root -xvfb_pid_file=$base_dir/xvfb.pid +# ********************************************************************** +# Configuration options +# Example node capabilities: -browser browserName=firefox,maxInstances=1,platform=LINUX + +# Customize Java binary path +JAVA=/usr/bin/java + +# Customize PWR global installation directory +PWR_GLOBAL_DIR="" + +# Customize PWR running user +USER="root" + +# Customize PWR application files directory +PWR_INST_DIR="$PWR_GLOBAL_DIR/opt" + +# Customize port for PWR +PWR_PORT=4444 +PWR_HUB_PORT=4444 +PWR_NODE_PORT=5555 + +# Extra options for PWR +PWR_OPTS=" -firefoxProfileTemplate $PWR_INST_DIR/firefox_profile " +PWR_NODE_OPTS=" -nodeConfig $PWR_INST_DIR/selenium/config.json " +PWR_HUB_OPTS="" + + +# ********************************************************************** +# Default paths + +PWR_DIR="$PWR_GLOBAL_DIR/usr/lib/pwr" +LOG_DIR="$PWR_GLOBAL_DIR/var/log/pwr" +STD_LOG="$LOG_DIR/pwr_std.log" +BASE_DIR="$PWR_GLOBAL_DIR/etc/pwr/tmp" +PWR="$PWR_DIR/selenium-server-standalone-2.53.1.jar" +XVFB_PID_FILE="$BASE_DIR/xvfb.pid" + + + +# ********************************************************************** +# Variables -# Variable host=`ip a show $(route -n | awk '/^0\.0\.0\.0/ {print $NF}') | grep "inet " | awk '{print $2}' | cut -f1 -d'/' | head -1` + + +# ********************************************************************** +# Functions + # Start Xvfb, required for firefox in server without X function start_xvfb() { `which Xvfb >/dev/null 2>&1` @@ -37,45 +87,48 @@ function start_xvfb() { echo 1 fi else - Xvfb :99 -ac > /dev/null 2>&1 & + Xvfb :99 -screen 0 1400x768x24 -ac +extension RANDR > $LOG_DIR/xvfb.log 2>&1 & echo $! > $XVFB_PID_FILE export DISPLAY=:99 - ps -eo pid,cmd | grep Xvfb | grep -v grep | awk {'print $1 '} > $xvfb_pid_file echo 0 fi - } # Stop Xvfb function stop_xvfb() { - if test -f $xvfb_pid_file ; then + echo + if test -f $XVFB_PID_FILE ; then # Check if there's more instances of pwrd running i.e. standalone + node - if [ ! -e "$base_dir/pwrd_node.pid" ] && [ ! -e "$base_dir/pwrd.pid" ]; then - echo -n "Stopping Xvfb..." - PID=$(cat $xvfb_pid_file) - if [ `kill -9 $PID 2>&1 | grep "No such process" | wc -l` == "1" ]; then + if [ ! -e "$BASE_DIR/pwrd_node.pid" ] && [ ! -e "$BASE_DIR/pwrd.pid" ]; then + if [ ! -e /etc/rc.d/init.d/functions ]; then + echo -n "Stopping Xvfb..." + fi + PID=$(cat $XVFB_PID_FILE) + if [ "$PID" != "" ] && [ `kill -9 $PID 2>&1 | grep "No such process" | wc -l` == "1" ]; then # PID file exists but no process - test -f $xvfb_pid_file && rm -f $xvfb_pid_file + [ -f $XVFB_PID_FILE ] && rm -f $XVFB_PID_FILE if [ -e /etc/rc.d/init.d/functions ]; then success fi return 0 fi else - echo "(1) pwrd process left. Skipping Xvfb" + [ -e $BASE_DIR/pwrd_node.pid ] && echo -n `cat $BASE_DIR/pwrd_node.pid` + [ -e $BASE_DIR/pwrd.pid ] && echo -n `cat $BASE_DIR/pwrd.pid` + echo -e "\nThere're pwrd processes left. Skipping Xvfb" fi fi } -################################################################################ + +######################################################################## # START -################################################################################ +######################################################################## # Start Selenium Standalone server function start() { - if test -f $pid_file - then + if test -f $pid_file; then PID=`cat $pid_file` - if ps --pid $PID >/dev/null; then + if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then echo "PWRD is already running: $PID" exit 2 else @@ -91,11 +144,12 @@ function start() { return 1 fi - echo -n "Starting PWRD..." + if [ ! -e /etc/rc.d/init.d/functions ]; then + echo -n "Starting PWRD..." + fi export DISPLAY=:99 - su $user -c "$java -jar $pwr -host $host $PWROPTS > $std_log 2>&1 &" - + PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_PORT $PWR_OPTS > $STD_LOG 2>&1 & echo \$!") if [ $? == "0" ]; then if [ -e /etc/rc.d/init.d/functions ]; then success @@ -109,28 +163,29 @@ function start() { fi # Store PID - ps -eo pid,cmd | grep $pwr | grep -v "node" | grep -v "hub" | grep -v grep | awk {'print $1 '} > $pid_file + echo -n $PID > $pid_file } # Start Selenium GRID server: HUB component function start-hub() { - if test -f $pid_file - then + if test -f $pid_file; then PID=`cat $pid_file` - if ps --pid $PID >/dev/null; then + if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then echo "PWRD is already running: $PID" exit 2 else echo "Removing stale pid file: $pid_file" fi fi - echo -n "Starting PWRD..." + + if [ ! -e /etc/rc.d/init.d/functions ]; then + echo -n "Starting PWRD..." + fi # No Xvfb needed in hub mode - su $user -c "$java -jar $pwr -host $host -role hub $PWR_HUB_OPTS > $std_log 2>&1 &" - + PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_HUB_PORT -role hub $PWR_HUB_OPTS > $STD_LOG 2>&1 & echo \$!") if [ $? == "0" ]; then if [ -e /etc/rc.d/init.d/functions ]; then success @@ -144,15 +199,17 @@ function start-hub() { fi # Store PID - ps -eo pid,cmd | grep $pwr | grep "hub" | grep -v grep | awk {'print $1 '} > $pid_file + echo -n $PID > $pid_file + + echo + echo -e "Add nodes to HUB executing:\n $0 start-node http://$host:$PWR_HUB_PORT/grid/register" } # Start Selenium GRID server: Node Connect to hub function start-node() { - if test -f $pid_file - then + if test -f $pid_file ; then PID=`cat $pid_file` - if ps --pid $PID >/dev/null; then + if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then echo "PWRD is already running: $PID" exit 2 else @@ -168,11 +225,12 @@ function start-node() { return 1 fi - echo -n "Starting PWRD..." + if [ ! -e /etc/rc.d/init.d/functions ]; then + echo -n "Starting PWRD..." + fi export DISPLAY=:99 - su $user -c "$java -jar $pwr -host $host -role node -hub $1 $PWROPTS > $std_log 2>&1 &" - + PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_NODE_PORT -role node -hub $1 $PWR_OPTS > $STD_LOG 2>&1 & echo \$!") if [ $? == "0" ]; then if [ -e /etc/rc.d/init.d/functions ]; then success @@ -186,34 +244,39 @@ function start-node() { fi # Store PID - ps -C java -eo pid,cmd | grep $pwr | grep "node" | grep -v grep | awk {'print $1 '} > $pid_file + echo -n $PID > $pid_file } -################################################################################ + +######################################################################## # STOP -################################################################################ +######################################################################## # Stop Selenium Standalone server function stop() { if test -f $pid_file ; then echo -n "Stopping PWRD..." PID=$(cat $pid_file) - su $user -c "kill -3 $PID" - kill -9 $PID >/dev/null 2>&1 + [ "$PID" == "" ] && PID=`ps aux | grep "$JAVA -jar $PWR" | grep -v grep | awk '{print $2}'` + [ "$PID" != "" ] && ps --pid $PID >/dev/null && su $USER -c "kill -3 $PID" + [ "$PID" != "" ] && ps --pid $PID >/dev/null && kill -9 $PID >/dev/null 2>&1 if [ $? -eq 0 ]; then - sleep 5 - test -f $pid_file && rm -f $pid_file + sleep 2 if [ -e /etc/rc.d/init.d/functions ]; then success fi + test -f $pid_file && rm -f $pid_file + + stop_xvfb else - echo "PWRD could not be stopped..." if [ -e /etc/rc.d/init.d/functions ]; then failure + else + echo "Failed" fi - echo "Failed" fi - stop_xvfb + # Clean pid file + test -f $pid_file && rm -f $pid_file else echo "PWRD is not running." stop_xvfb @@ -224,84 +287,94 @@ function stop() { echo } -################################################################################ + +######################################################################## # STATUS -################################################################################ +######################################################################## # Status of Selenium Standalone server function status() { + mode=$1 if test -f $pid_file ; then + echo "checking: $pid_file" PID=`cat $pid_file` - if ps --pid $PID >/dev/null ; then - echo "PWRD is running: $PID" - if test -f $xvfb_pid_file ; then - PID=`cat $xvfb_pid_file` - if test -f $xvfb_pid_file ; then + if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then + echo "PWRD$mode is running: $PID" + if test -f $XVFB_PID_FILE ; then + PID=`cat $XVFB_PID_FILE` + if test -f $XVFB_PID_FILE ; then echo "Xvfb is running: $PID" fi fi else - echo "PWRD isn't running..." + echo "PWRD$mode isn't running..." fi else - echo "PWRD isn't running..." + echo "PWRD$mode isn't running..." fi } - + + + +######################################################################## +# MAIN +######################################################################## + +if [ ! -x "$JAVA" ]; then + echo "Please verify $JAVA is a valid java" 2>&1 + exit 1 +fi + case "$1" in start) # Standalone - pid_file=$base_dir/pwrd.pid + pid_file=$BASE_DIR/pwrd.pid start ;; start-hub) # hub - pid_file=$base_dir/pwrd_hub.pid + pid_file=$BASE_DIR/pwrd_hub.pid start-hub ;; start-node) # node - pid_file=$base_dir/pwrd_node.pid + pid_file=$BASE_DIR/pwrd_node.pid start-node $2 ;; stop) # standalone - pid_file=$base_dir/pwrd.pid + pid_file=$BASE_DIR/pwrd.pid stop ;; stop-hub) # hub - pid_file=$base_dir/pwrd_hub.pid + pid_file=$BASE_DIR/pwrd_hub.pid stop ;; stop-node) # node - pid_file=$base_dir/pwrd_node.pid + pid_file=$BASE_DIR/pwrd_node.pid stop ;; restart) # standalone - pid_file=$base_dir/pwrd.pid + pid_file=$BASE_DIR/pwrd.pid stop start ;; restart-hub) # hub - pid_file=$base_dir/pwrd_hub.pid + pid_file=$BASE_DIR/pwrd_hub.pid stop start-hub ;; restart-node) # node - pid_file=$base_dir/pwrd_node.pid + pid_file=$BASE_DIR/pwrd_node.pid stop start-node $2 ;; status) - pid_file=$base_dir/pwrd.pid - status - ;; - status-hub) # hub - pid_file=$base_dir/pwrd_hub.pid - status - ;; - status-node) # node - pid_file=$base_dir/pwrd_node.pid - status + pid_file=$BASE_DIR/pwrd.pid + status "" + pid_file=$BASE_DIR/pwrd_hub.pid + status " HUB" + pid_file=$BASE_DIR/pwrd_node.pid + status " Node" ;; *) - echo "Usage: $SELF start*|stop*|restart*|status*" + echo "Usage: $SELF start*|stop*|restart*|status" echo " start* (standalone, hub or node)" echo " start" echo " start-hub" @@ -314,12 +387,6 @@ case "$1" in echo " restart" echo " restart-hub" echo " restart-node http://hub:4444/grid/register" - echo " status* (standalone, hub or node)" - echo " status" - echo " status-hub" - echo " status-node" exit 9 ;; esac - -echo FIN [$1] diff --git a/tests/enterprise_base/Dockerfile b/tests/enterprise_base/Dockerfile index 8b0533d25c..1d7d10466e 100644 --- a/tests/enterprise_base/Dockerfile +++ b/tests/enterprise_base/Dockerfile @@ -2,7 +2,7 @@ FROM pandorafms/pandorafms-base MAINTAINER Pandora FMS Team <info@pandorafms.com> # Pandora FMS Server dependencies -RUN yum install -y fping perl-Test-WWW-Selenium perl-Crypt-Blowfish perl-Crypt-ECB perl-Net-OpenSSH +RUN yum install -y fping perl-Test-WWW-Selenium perl-Crypt-Blowfish perl-Crypt-ECB perl-Crypt-Rijndael perl-Net-OpenSSH RUN ln -s /usr/bin/braa /usr/local/bin/braa