diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 0533fe3cc4..b3b665370c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.735-190610 +Version: 7.0NG.735-190612 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 c58e8dddfb..4068a3039c 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.735-190610" +pandora_version="7.0NG.735-190612" 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 75bc63d62c..4ed107c604 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.735'; -use constant AGENT_BUILD => '190610'; +use constant AGENT_BUILD => '190612'; # 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 851dbce14b..f09e281cfc 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.735 -%define release 190610 +%define release 190612 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 639ad34897..c5f3b47600 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.735 -%define release 190610 +%define release 190612 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 78f054e1c6..27ca5cb3c0 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.735" -PI_BUILD="190610" +PI_BUILD="190612" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/grep_log b/pandora_agents/unix/plugins/grep_log index 2e17210a51..76661c5230 100755 --- a/pandora_agents/unix/plugins/grep_log +++ b/pandora_agents/unix/plugins/grep_log @@ -6,17 +6,17 @@ # # grep_log Perl script to search log files for a matching pattern. The last # searched position is saved in an index file so that consecutive -# runs do not return the same results. The log file inode number is +# runs do not return the same results. The log file inode number is # also saved to detect log rotation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -# +# # 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. +# GNU General Public License for more details. # ############################################################################### use strict; @@ -30,7 +30,7 @@ my $Output = 'module'; my $Verbose = 0; # Index file storage directory, with a trailing '/' -my $Idx_dir=($^O =~ /win/i)?'.\\':'/tmp/'; +my $Idx_dir=($^O =~ /win/i)?"$ENV{'TMP'}\\":"/tmp/"; # Log file my $Log_file = ''; @@ -64,7 +64,7 @@ if ( (defined ($ENV{GREP_LOG_TMP})) && (-d $ENV{GREP_LOG_TMP}) ) { } ######################################################################################## -# Erase blank spaces before and after the string +# Erase blank spaces before and after the string ######################################################################################## sub trim($){ my $string = shift; @@ -226,7 +226,7 @@ sub parse_log (;$$) { open(LOGFILE, $Log_file) || error_msg("Error opening file $Log_file: " . $!); - # Go to starting position. + # Go to starting position. seek(LOGFILE, $Idx_pos, 0); # Parse log file @@ -318,7 +318,7 @@ sub print_log ($) { print_summary() if ($summary_flag == 1); return; } - + # Log module if ($Output eq 'log_module') { my $output = "\n"; diff --git a/pandora_agents/win32/bin/util/grep_log.exe b/pandora_agents/win32/bin/util/grep_log.exe index a21e080805..4e4029fb60 100644 Binary files a/pandora_agents/win32/bin/util/grep_log.exe and b/pandora_agents/win32/bin/util/grep_log.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index be257849d3..bbb5ef688d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190610} +{190612} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 42fdfc2d60..5629c17eb2 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.735(Build 190610)") +#define PANDORA_VERSION ("7.0NG.735(Build 190612)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 248f569dc1..934b27fdd6 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.735(Build 190610))" + VALUE "ProductVersion", "(7.0NG.735(Build 190612))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 82f2c63b7c..1fa6b0606e 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.735-190610 +Version: 7.0NG.735-190612 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index b47d90768f..c9422dc4c7 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.735-190610" +pandora_version="7.0NG.735-190612" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index c5420c26bd..f3b11177d1 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -139,8 +139,9 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = get_logs_size($path); - if ($size_server_log <= 1048576) { + $size_server_log = number_format(get_logs_size($path)); + $size_server_log = (0 + str_replace(',', '', $size_server_log)); + if ($size_server_log <= 10485760) { $status_server_log = "Normal Status   You have less than 10 MB of logs"; } else { $status_server_log = "Warning Status   You have more than 10 MB of logs"; diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 0e632380ce..8277463e18 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -357,8 +357,8 @@ function addConnectionMap() { for (var index in connectionMaps) { if (isInt(index)) { if (connectionMaps[index] == idConnectionMap) { - alert(" "' + connectionMapName + '" "); - + alert(" " + connectionMapName + " "); + return; } } diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 44e616977d..e9d8b49176 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -45,6 +45,9 @@ .parent() .addClass('checkselected'); $(".check_delete").prop("checked", true); + $('.check_delete').each(function(){ + $('#hidden-id_report_'+$(this).val()).prop("disabled", false); + }); } else{ $('[id^=checkbox-massive_report_check]') diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 9baacdcdc2..21d3d11085 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -299,6 +299,7 @@ if (check_login()) { 'status' => "
".$image_status.'
', 'id_agent' => $values['id_tagente'], 'id_server' => $values['id_tmetaconsole_setup'], + 'status_value' => $values['status'], ]; } diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index b9a5ede1e5..5ef2fed828 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -1472,7 +1472,10 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - if (stripos($ldap_host, 'ldap') !== false) { + if (stripos($ldap_host, 'ldap://') !== false + || stripos($ldap_host, 'ldaps://') !== false + || stripos($ldap_host, 'ldapi://') !== false + ) { $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; } else { $ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2d0b52acfe..6cade00145 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190610'; +$build_version = 'PC190612'; $pandora_version = 'v7.0NG.735'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 488d6a28cd..87d0601a4f 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2167,9 +2167,9 @@ function config_process_config() if (!isset($config['ad_adv_perms'])) { config_update_value('ad_adv_perms', ''); } else { + $temp_ad_adv_perms = []; if (!json_decode(io_safe_output($config['ad_adv_perms']))) { - $temp_ad_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ad_adv_perms'] != '') { + if ($config['ad_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ad_adv_perms'])); foreach ($perms as $ad_adv_perm) { if (preg_match('/[\[\]]/', $ad_adv_perm)) { @@ -2232,22 +2232,26 @@ function config_process_config() if (!empty($new_ad_adv_perms)) { $temp_ad_adv_perms = json_encode($new_ad_adv_perms); } + } else { + $temp_ad_adv_perms = ''; } - - config_update_value('ad_adv_perms', $temp_ad_adv_perms); + } else { + $temp_ad_adv_perms = $config['ad_adv_perms']; } + + config_update_value('ad_adv_perms', $temp_ad_adv_perms); } if (!isset($config['ldap_adv_perms'])) { config_update_value('ldap_adv_perms', ''); } else { + $temp_ldap_adv_perms = []; if (!json_decode(io_safe_output($config['ldap_adv_perms']))) { - $temp_ldap_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ldap_adv_perms'] != '') { + if ($config['ldap_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ldap_adv_perms'])); - foreach ($perms as $ad_adv_perm) { - if (preg_match('/[\[\]]/', $ad_adv_perm)) { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + foreach ($perms as $ldap_adv_perm) { + if (preg_match('/[\[\]]/', $ldap_adv_perm)) { + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = str_replace(['[', ']'], '', $all_data[2]); @@ -2277,7 +2281,7 @@ function config_process_config() 'groups_ldap' => $groups_ldap, ]; } else { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = $all_data[2]; @@ -2306,10 +2310,14 @@ function config_process_config() if (!empty($new_ldap_adv_perms)) { $temp_ldap_adv_perms = json_encode($new_ldap_adv_perms); } + } else { + $temp_ldap_adv_perms = ''; } - - config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); + } else { + $temp_ldap_adv_perms = $config['ldap_adv_perms']; } + + config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); } if (!isset($config['rpandora_server'])) { diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 9570098766..d1f661e874 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -188,10 +188,16 @@ function get_custom_fields_data($custom_field_name) } $array_result = []; - if (isset($result_meta) && is_array($result_meta)) { + if (isset($result_meta) === true + && is_array($result_meta) === true + ) { foreach ($result_meta as $result) { - foreach ($result as $k => $v) { - $array_result[$v['description']] = $v['description']; + if (isset($result) === true + && is_array($result) === true + ) { + foreach ($result as $k => $v) { + $array_result[$v['description']] = $v['description']; + } } } } @@ -385,9 +391,13 @@ function agent_counters_custom_fields($filters) // Filter custom data. $custom_data_and = ''; - if (!in_array(-1, $filters['id_custom_fields_data'])) { - $custom_data_array = implode("', '", $filters['id_custom_fields_data']); - $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + if (isset($filters['id_custom_fields_data']) === true + && is_array($filters['id_custom_fields_data']) === true + ) { + if (!in_array(-1, $filters['id_custom_fields_data'])) { + $custom_data_array = implode("', '", $filters['id_custom_fields_data']); + $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + } } // Filter custom name. @@ -693,3 +703,123 @@ function print_counters_cfv( $html_result .= ''; return $html_result; } + + +/** + * Function for export a csv file from Custom Fields View + * + * @param array $filters Status counters for agents and modules. + * @param array $id_status Agent status. + * @param array $module_status Module status. + * + * @return array Returns the data that will be saved in the csv file + */ +function export_custom_fields_csv($filters, $id_status, $module_status) +{ + $data = agent_counters_custom_fields($filters); + $indexed_descriptions = $data['indexed_descriptions']; + + // Table temporary for save array in table + // by order and search custom_field data. + $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( + id_server int(10), + id_agent int(10), + name_custom_fields varchar(2048), + critical_count int, + warning_count int, + unknown_count int, + notinit_count int, + normal_count int, + total_count int, + `status` int(2), + KEY `data_index_temp_1` (`id_server`, `id_agent`) + )'; + db_process_sql($table_temporary); + + // Insert values array in table temporary. + $values_insert = []; + foreach ($indexed_descriptions as $key => $value) { + $values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + } + + $values_insert_implode = implode(',', $values_insert); + $query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode; + db_process_sql($query_insert); + + // Search for status module. + $status_agent_search = ''; + if (isset($id_status) === true && is_array($id_status) === true) { + if (in_array(-1, $id_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $id_status) === false) { + $status_agent_search = ' AND temp.status IN ('.implode(',', $id_status).')'; + } else { + // Not normal statuses. + $status_agent_search = ' AND temp.status IN (1,2,3,4,5)'; + } + } + } + + // Search for status module. + $status_module_search = ''; + if (isset($module_status) === true && is_array($module_status) === true) { + if (in_array(-1, $module_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status) === false) { + if (count($module_status) > 0) { + $status_module_search = ' AND ( '; + foreach ($module_status as $key => $value) { + $status_module_search .= ($key != 0) ? ' OR (' : ' ('; + switch ($value) { + default: + case AGENT_STATUS_NORMAL: + $status_module_search .= ' temp.normal_count > 0) '; + break; + case AGENT_STATUS_CRITICAL: + $status_module_search .= ' temp.critical_count > 0) '; + break; + + case AGENT_STATUS_WARNING: + $status_module_search .= ' temp.warning_count > 0) '; + break; + + case AGENT_STATUS_UNKNOWN: + $status_module_search .= ' temp.unknown_count > 0) '; + break; + + case AGENT_STATUS_NOT_INIT: + $status_module_search .= ' temp.notinit_count > 0) '; + break; + } + } + + $status_module_search .= ' ) '; + } + } else { + // Not normal. + $status_module_search = ' AND ( temp.critical_count > 0 OR temp.warning_count > 0 OR temp.unknown_count > 0 AND temp.notinit_count > 0 )'; + } + } + } + + // Query all fields result. + $query = sprintf( + 'SELECT + temp.name_custom_fields, + tma.alias, + tma.direccion, + tma.server_name, + temp.status + FROM tmetaconsole_agent tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_tagente + AND temp.id_server = tma.id_tmetaconsole_setup + WHERE tma.disabled = 0 + %s + %s + ', + $status_agent_search, + $status_module_search + ); + + $result = db_get_all_rows_sql($query); + return $result; +} diff --git a/pandora_console/include/javascript/buttons.html5.min.js b/pandora_console/include/javascript/buttons.html5.min.js new file mode 100644 index 0000000000..deee7fee68 --- /dev/null +++ b/pandora_console/include/javascript/buttons.html5.min.js @@ -0,0 +1,35 @@ +/*! + HTML5 export buttons for Buttons and DataTables. + 2016 SpryMedia Ltd - datatables.net/license + + FileSaver.js (1.3.3) - MIT license + Copyright © 2016 Eli Grey - http://eligrey.com +*/ +(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(g){return f(g,window,document)}):"object"===typeof exports?module.exports=function(g,p,z,t){g||(g=window);p&&p.fn.dataTable||(p=require("datatables.net")(g,p).$);p.fn.dataTable.Buttons||require("datatables.net-buttons")(g,p);return f(p,g,g.document,z,t)}:f(jQuery,window,document)})(function(f,g,p,z,t,w){function A(a){for(var b="";0<=a;)b=String.fromCharCode(a%26+65)+b,a=Math.floor(a/ +26)-1;return b}function E(a,b){y===w&&(y=-1===C.serializeToString(f.parseXML(F["xl/worksheets/sheet1.xml"])).indexOf("xmlns:r"));f.each(b,function(b,c){if(f.isPlainObject(c))b=a.folder(b),E(b,c);else{if(y){var d=c.childNodes[0],e,h=[];for(e=d.attributes.length-1;0<=e;e--){var m=d.attributes[e].nodeName;var k=d.attributes[e].nodeValue;-1!==m.indexOf(":")&&(h.push({name:m,value:k}),d.removeAttribute(m))}e=0;for(m=h.length;e'+c),c=c.replace(/_dt_b_namespace_token_/g,":"),c=c.replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""));c=c.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");a.file(b,c)}})}function r(a,b,d){var c=a.createElement(b);d&&(d.attr&&f(c).attr(d.attr),d.children&&f.each(d.children,function(a,b){c.appendChild(b)}),null!==d.text&&d.text!==w&&c.appendChild(a.createTextNode(d.text))); +return c}function L(a,b){var d=a.header[b].length;a.footer&&a.footer[b].length>d&&(d=a.footer[b].length);for(var c=0,f=a.body.length;cd&&(d=e);if(401*a[1]?!0:!1};try{var C=new XMLSerializer,y}catch(a){}var F={"_rels/.rels":'', +"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'', +"xl/workbook.xml":'', +"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''}, +K=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(a){return a/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(a){return a/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63}, +{match:/^\-?[\d,]+\.\d{2}$/,style:64}];v.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(a){return a.i18n("buttons.copy","Copy")},action:function(a,b,d,c){this.processing(!0);var g=this;a=I(b,c);var e=b.buttons.exportInfo(c),h=H(c),m=a.str;d=f("
").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0});e.title&&(m=e.title+h+h+m);e.messageTop&&(m=e.messageTop+h+h+m);e.messageBottom&&(m=m+h+h+e.messageBottom);c.customize&&(m=c.customize(m,c,b));c=f("