diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index ddd948ef0e..08a656c69f 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230314 +Version: 7.0NG.769-230315 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 3329802701..5218fc92cc 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.769-230314" +pandora_version="7.0NG.769-230315" 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 75a25abaea..07f62b6c54 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1023,7 +1023,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.769'; -use constant AGENT_BUILD => '230314'; +use constant AGENT_BUILD => '230315'; # 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 8a89129bc5..e41ed8c290 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230314 +%define release 230315 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 5247de551a..ca32dc789f 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230314 +%define release 230315 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 7fc777070e..8107c738db 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230314" +PI_BUILD="230315" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/autodiscover b/pandora_agents/unix/plugins/autodiscover index 03b2c3d76d..01b9bd3d96 100644 --- a/pandora_agents/unix/plugins/autodiscover +++ b/pandora_agents/unix/plugins/autodiscover @@ -6,21 +6,22 @@ # # (c) A. Kevin Rojas # +# Edited in 2023 by Alejandro Sánchez +# # TO DO LIST: # - Enable child services detection (Windows) # - Make CPU/Memory usage available for child services (Windows) # ################################################### - try: from sys import argv from sys import stderr from sys import exit + import psutil from subprocess import Popen from subprocess import PIPE from subprocess import DEVNULL from subprocess import getstatusoutput - import psutil except ModuleNotFoundError as err: print("{} error: {}. Exiting...".format(argv[0], err), file=stderr) exit(1) @@ -28,99 +29,100 @@ except ModuleNotFoundError as err: module_list = [] VERSION = "1.2" +def win_service(servicelist, option=False, memcpu=False): -######################################################################################### -# Powershell class -######################################################################################### -class PSCheck: - @staticmethod - def check_service(servicename, option=False, memcpu=False): - """Check services with powershell by parsing their DisplayName. Returns a dict\ - list with the name of the service and a boolean with its status.\n - Requires service name (case insensitive).""" - pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'", - "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = pscall.communicate() - result = str(result[0]).strip().split("\n") - procname = '' - if result != '': - output = [] - for element in result: - if element != '': - # Get process name - procname = PSCheck.get_serviceprocess(element) - # Get process status - parstatus = PSCheck.getstatus(element) - if memcpu and parstatus == 1: - usage = get_memcpu(str(procname), str(element)) - output += usage - # Generate module with name and status - parent = service_module(str(element), parstatus) - output += parent - if option: - children = PSCheck.getchildren(element, memcpu) - if isinstance(children, list) and len(children) > 1: - for child in children: - output += child - else: - output += children - else: - next - - if output and element and procname: - return ({"name" : element, "process" : procname, "modules": output}) + modules_default = [] + modules_percentage=[] + ## take all services + services=psutil.win_service_iter() + for service in services: + if service.name() in servicelist: + serv=service.as_dict() + if serv['status']=='running': + value=1 else: - return (None) + value=0 - @staticmethod - def getchildren(servicename, memcpu=False): - """Gets Dependent services of a given Windows service""" - pschild = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' -DS", "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - children = pschild.communicate()[0].strip() - kids = [] - for child in (children.split("\n") if children != "" else []): - status = PSCheck.getstatus(child) - kids += service_module(str(child), status, "Service " + str(servicename) + " - Status") - if status: - if memcpu: - kidsusage = get_memcpu(str(child)) - for usage in kidsusage: - kids += usage + ## create module for each service + parent = build_module("Service " + str(serv['name']) + " - Status", value,"generic_proc") + modules_default +=parent + + # memory and cpu percentage + if memcpu: + ## process + srv_pid = service.pid() + process = psutil.Process(srv_pid) + proc_name = process.name() + ##cpu + value_cpu=process.cpu_percent(interval=0.5) + parent = build_module("Service " + str(proc_name) + " - CPU usage", value_cpu,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + ##mem + value_mem=process.memory_percent() + parent = build_module("Service " + str(proc_name) + " - Memory usage", value_mem,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + + + for module in modules_default: + print_module(module, 1) + if memcpu: + for module in modules_percentage: + print_module(module, 1) + +def lnx_service(services_list, memcpu=False): + """Creates modules for Linux servers""" + modules = [] + sysctl = getstatusoutput("command -v systemctl")[0] + servic = getstatusoutput("command -v service")[0] + for srvc in services_list: + status = None + if sysctl == 0: + ### Systemd available + syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, + stdin=DEVNULL, universal_newlines=True) + result = syscall.communicate() + srvstatus = result[0].strip().lower().split("\n") + if srvstatus[0] == "loadstate=not-found": + next + else: + if srvstatus[1] == "activestate=active": + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif srvstatus[1] == "activestate=inactive": + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 + elif sysctl != 0 and servic == 0: + ### Systemd not available, switch to service command + syscall = Popen(["service", srvc, "status"], stdout=PIPE, + stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) + result = syscall.communicate()[0].lower() + if "is running" in result: + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif "is stopped" in result: + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 else: next - return kids - - @staticmethod - def getstatus(servicename): - """Gets the status of a given Windows service""" - running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' |", "Select-Object", "-ExpandProperty", "Status"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - status = running.communicate()[0].strip() - return int(status == "Running") - - @staticmethod - def get_serviceprocess(servicename): - """Gets name of the process of the service""" - service = psutil.win_service_get(servicename) - srv_pid = service.pid() - process = psutil.Process(srv_pid) - proc_name = process.name() - return proc_name + else: + print("No systemd or service commands available. Exiting...", file=stderr) + exit() + if status: + module_list.append(srvc) + if memcpu: + modules += get_memcpu(srvc, None) + + for m in modules: + print_module(m, 1) -######################################################################################### -# Services creation -######################################################################################### - -def service_module(name, value, parent=None): +def build_module(name, value, module_type, parent=None): #print ("service_module BEGIN "+str(now(0,1))) module = [{ - "name" : "Service "+ name + " - Status", - "type" : "generic_proc", + "name" : name , + "type" : module_type, "value" : value, "module_parent" : parent, }] @@ -167,74 +169,6 @@ def proc_percentbyname(procname): ############# 03/03/2020 next #print ("proc_percentbyname END "+str(now(0,1))) return [sum(memory),sum(cpu)] - -def win_service(servicelist, option=False, memcpu=False): - """Creates modules for Windows servers.""" - modules = [] - for srvc in servicelist: - if srvc and len(srvc) > 2: - output = PSCheck.check_service(srvc, option, memcpu) - if output is not None and output["modules"]: - modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"] - module_list.append(srvc) - #winprocess = output["name"] - #if memcpu == True: - # modules += get_memcpu(winprocess) ## Only available for parent service ATM. - else: - next - else: - next - for module in modules: - print_module(module, 1) - - -def lnx_service(services_list, memcpu=False): - """Creates modules for Linux servers""" - modules = [] - sysctl = getstatusoutput("command -v systemctl")[0] - servic = getstatusoutput("command -v service")[0] - for srvc in services_list: - status = None - if sysctl == 0: - ### Systemd available - syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, - stdin=DEVNULL, universal_newlines=True) - result = syscall.communicate() - srvstatus = result[0].strip().lower().split("\n") - if srvstatus[0] == "loadstate=not-found": - next - else: - if srvstatus[1] == "activestate=active": - modules += service_module(srvc, 1) - status = 1 - elif srvstatus[1] == "activestate=inactive": - modules += service_module(srvc, 0) - status = 0 - elif sysctl != 0 and servic == 0: - ### Systemd not available, switch to service command - syscall = Popen(["service", srvc, "status"], stdout=PIPE, - stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = syscall.communicate()[0].lower() - if "is running" in result: - modules += service_module(srvc, 1) - status = 1 - elif "is stopped" in result: - modules += service_module(srvc, 0) - status = 0 - else: - next - else: - print("No systemd or service commands available. Exiting...", file=stderr) - exit() - if status: - module_list.append(srvc) - if memcpu: - modules += get_memcpu(srvc, None) - - for m in modules: - print_module(m, 1) - - ######################################################################################### # print_module function ######################################################################################### @@ -356,6 +290,7 @@ def main(): service_list = ["MySQL", "postgresql", "pgsql", "oracle", "MSSQL", "IISADMIN", "apache", "nginx", "W3svc", "NTDS", "Netlogon", "DNS", "MSExchangeADTopology", "MSExchangeServiceHost", "MSExchangeSA", "MSExchangeTransport"] + discover(OS, service_list) elif psutil.LINUX: OS = "Linux" diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index a95f663722..86c9cf1820 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230314} +{230315} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3413fd206b..6120e75fe4 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.769 Build 230314") +#define PANDORA_VERSION ("7.0NG.769 Build 230315") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ae3086b8c7..cc42f22709 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.769(Build 230314))" + VALUE "ProductVersion", "(7.0NG.769(Build 230315))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bd28cdb7c9..aa3dd4d6cc 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230314 +Version: 7.0NG.769-230315 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 def9fd150e..d51774a6b6 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.769-230314" +pandora_version="7.0NG.769-230315" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql index 9a96b37aff..6632e39f2b 100644 --- a/pandora_console/extras/mr/62.sql +++ b/pandora_console/extras/mr/62.sql @@ -157,4 +157,13 @@ INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`, `filename`, `path`) VALUES ALTER TABLE `tusuario` ADD COLUMN `show_tips_startup` TINYINT UNSIGNED NOT NULL DEFAULT 1; +CREATE TABLE IF NOT EXISTS `tfavmenu_user` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(255) NOT NULL, + `id_element` TEXT, + `url` TEXT NOT NULL, + `label` VARCHAR(255) NOT NULL, + `section` VARCHAR(255) NOT NULL, +PRIMARY KEY (`id`)); + COMMIT; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index f559b4e3eb..385f4a5a8c 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -827,6 +827,12 @@ if ($id_agente) { 'link' => '', 'label' => $tab_name, ], + ], + [ + 'id_element' => $id_agente, + 'url' => 'godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente, + 'label' => agents_get_alias($id_agente), + 'section' => 'Agents', ] ); } diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 2cceb5fa34..0231245274 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -444,7 +444,8 @@ $tableBasicThresholds->data = []; $tableBasicThresholds->rowclass['caption_warning_threshold'] = 'field_half_width pdd_t_10px'; $tableBasicThresholds->rowclass['warning_threshold'] = 'field_half_width'; $tableBasicThresholds->data['caption_warning_threshold'][0] .= __('Warning threshold').' '; -if ($edit_module === false && (isset($stringTypeModule) === false || $stringTypeModule === false)) { + +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { $tableBasicThresholds->data['caption_warning_threshold'][0] .= '('.__('Min / Max').')'; $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( 'min_warning', @@ -482,7 +483,7 @@ if ($edit_module === false && (isset($stringTypeModule) === false || $stringType ); } -if ($edit_module === false && isset($stringTypeModule) === true && $stringTypeModule === true) { +if (isset($stringTypeModule) === true && $stringTypeModule === true) { $basicThresholdsIntervalWarning = []; $basicThresholdsIntervalWarning[] = ''.__('Inverse interval').''; $basicThresholdsIntervalWarning[] = html_print_checkbox_switch( @@ -531,7 +532,7 @@ $tableBasicThresholds->data['switch_warning_threshold'][0] .= html_print_div( $tableBasicThresholds->rowclass['caption_critical_threshold'] = 'field_half_width pdd_t_10px'; $tableBasicThresholds->rowclass['critical_threshold'] = 'field_half_width'; $tableBasicThresholds->data['caption_critical_threshold'][0] .= __('Critical threshold').' '; -if ($edit_module === false && (isset($stringTypeModule) === false || $stringTypeModule === false)) { +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { $tableBasicThresholds->data['caption_critical_threshold'][0] .= '('.__('Min / Max').')'; $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( 'min_critical', @@ -569,7 +570,7 @@ if ($edit_module === false && (isset($stringTypeModule) === false || $stringType ); } -if ($edit_module === false && isset($stringTypeModule) === true && $stringTypeModule === true) { +if (isset($stringTypeModule) === true && $stringTypeModule === true) { $basicThresholdsIntervalCritical = []; $basicThresholdsIntervalCritical[] = ''.__('Inverse interval').''; $basicThresholdsIntervalCritical[] = html_print_checkbox_switch( @@ -1906,77 +1907,50 @@ $(document).ready (function () { $('.switch_radio_button label').on('click', function(){ var thisLabel = $(this).attr('for'); - $('#'+thisLabel).attr('checked', 'checked'); - $('#'+thisLabel).siblings().attr('checked', false); + $('#'+thisLabel).prop('checked', true); + $('#'+thisLabel).siblings().prop('checked', false); - if ($('#radius-warning_inverse').prop('checked') === true) { - //$('#percentage_warning').hide(); - $("#svg_dinamic").show(); - } - - if ($('#radius-critical_inverse').prop('checked') === true) { - //$('#percentage_critical').hide(); + if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { + $("#svg_dinamic").hide(); + } else { + paint_graph_values(); $("#svg_dinamic").show(); } if ($('#radius-percentage_warning').prop('checked') === true) { - //$('#warning_inverse').hide(); - $("#svg_dinamic").hide(); + $('#radius-warning_inverse').hide(); + $('#label-radius-warning_inverse').hide(); } + if ($('#radius-warning_inverse').prop('checked') === true) { + $('#radius-percentage_warning').hide(); + $('#label-radius-percentage_warning').hide(); + } + + if ($('#radius-normal_warning').prop('checked') === true) { + $('#radius-warning_inverse').show(); + $('#label-radius-warning_inverse').show(); + $('#radius-percentage_warning').show(); + $('#label-radius-percentage_warning').show(); + } + + if ($('#radius-percentage_critical').prop('checked') === true) { - //$('#critical_inverse').hide(); - $("#svg_dinamic").hide(); + $('#radius-critical_inverse').hide(); + $('#label-radius-critical_inverse').hide(); } - $('#radius-warning_inverse').change (function() { - paint_graph_values(); - if ($('#radius-warning_inverse').prop('checked') === true){ - $('#radius-percentage_warning').prop('checked', false); - $('#percentage_warning').attr('onClick', 'return false;'); - $('#percentage_warning>em').addClass('color_666'); - } else { - $('#percentage_warning').removeAttr('onClick'); - $('#percentage_warning>em').removeClass('color_666'); - } - }); + if ($('#radius-critical_inverse').prop('checked') === true) { + $('#radius-percentage_critical').hide(); + $('#label-radius-percentage_critical').hide(); + } - $('#radius-critical_inverse').change (function() { - paint_graph_values(); - - if ($('#radius-critical_inverse').prop('checked') === true){ - $('#radius-percentage_critical').prop('checked', false); - $('#percentage_critical').attr('onClick', 'return false;'); - $('#percentage_critical>em').addClass('color_666'); - } else { - $('#percentage_critical').removeAttr('onClick'); - $('#percentage_critical>em').removeClass('color_666'); - } - }); - - $('#radius-percentage_warning').change (function() { - paint_graph_values(); - if ($('#radius-percentage_warning').prop('checked') === true){ - $('#radius-warning_inverse').prop('checked', false); - $('#warning_inverse').attr('onClick', 'return false;'); - $('#warning_inverse>em').addClass('color_666'); - } else { - $('#warning_inverse').removeAttr('onClick'); - $('#warning_inverse>em').removeClass('color_666'); - } - }); - - $('#radius-percentage_critical').change (function() { - paint_graph_values(); - if ($('#radius-percentage_critical').prop('checked') === true){ - $('#radius-critical_inverse').prop('checked', false); - $('#critical_inverse').attr('onClick', 'return false;'); - $('#critical_inverse>em').addClass('color_666'); - } else { - $('#critical_inverse').removeAttr('onClick'); - $('#critical_inverse>em').removeClass('color_666'); - } - }); + if ($('#radius-normal_critical').prop('checked') === true) { + $('#radius-critical_inverse').show(); + $('#label-radius-critical_inverse').show(); + $('#radius-percentage_critical').show(); + $('#label-radius-percentage_critical').show(); + } }); @@ -2235,91 +2209,66 @@ function validate_post_process() { } } -//function paint graph +//function paint graph. function paint_graph_values(){ - //Parse integrer var min_w = parseFloat($('#text-min_warning').val()); - if(min_w == '0.00'){ min_w = 0; } - var max_w = parseFloat($('#text-max_warning').val()); - if(max_w == '0.00'){ max_w = 0; } - var min_c = parseFloat($('#text-min_critical').val()); - if(min_c =='0.00'){ min_c = 0; } - var max_c = parseFloat($('#text-max_critical').val()); - if(max_c =='0.00'){ max_c = 0; } - var inverse_w = $('input:radio[name=warning_inverse]:checked').val(); - if(!inverse_w){ inverse_w = 0; } - var inverse_c = $('input:radio[name=critical_inverse]:checked').val(); - if(!inverse_c){ inverse_c = 0; } + if(min_w == '0.00' || isNaN(min_w)){ min_w = 0; } - //inicialiced error + var max_w = parseFloat($('#text-max_warning').val()); + if(max_w == '0.00' || isNaN(max_w)){ max_w = 0; } + + var min_c = parseFloat($('#text-min_critical').val()); + if(min_c =='0.00' || isNaN(min_c)){ min_c = 0; } + + var max_c = parseFloat($('#text-max_critical').val()); + if(max_c =='0.00' || isNaN(max_c)){ max_c = 0; } + + var inverse_w = $('input:radio[value=warning_inverse]:checked').val(); + if(!inverse_w){ inverse_w = 0; } + + var inverse_c = $('input:radio[value=critical_inverse]:checked').val(); + if(!inverse_c){ inverse_c = 0; } + + //inicialiced error. var error_w = 0; var error_c = 0; - //messages legend + + //messages legend. var legend_normal = ''; var legend_warning = ''; var legend_critical = ''; - //messages error + + //messages error. var message_error_warning = ''; var message_error_critical = ''; var message_error_percentage = ''; - - - //Percentage selector - var percentage_w = $('#checkbox-percentage_warning').prop('checked'); - var percentage_c = $('#checkbox-percentage_critical').prop('checked'); - - if(percentage_w == true || percentage_c == true) { - d3.select("#svg_dinamic rect").remove(); - //create svg - var svg = d3.select("#svg_dinamic"); - svg.selectAll("g").remove(); - if (percentage_w === true) { - if(max_w < 0 || min_w < 0) { - paint_graph_status(0,0,0,0,0,0,1,0,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage); - } else { - $("#text-max_warning").removeClass("input_error"); - $("#text-min_warning").removeClass("input_error"); - } - - } - - if(percentage_c === true) { - if(max_c < 0 || min_c < 0) { - paint_graph_status(0,0,0,0,0,0,0,1,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage); - } else { - $("#text-min-critical").removeClass("input_error"); - $("#text-max_critical").removeClass("input_error"); - - } - } - - return; - - } else { - $('#svg_dinamic').show(); - } //if haven't error if(max_w == 0 || max_w > min_w){ if(max_c == 0 || max_c > min_c){ - paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, - inverse_c, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical); + paint_graph_status( + min_w, max_w, min_c, max_c, inverse_w, + inverse_c, error_w, error_c, + legend_normal, legend_warning, legend_critical, + message_error_warning, message_error_critical + ); } else { error_c = 1; - paint_graph_status(0,0,0,0,0,0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical); + paint_graph_status( + 0,0,0,0,0,0, error_w, error_c, + legend_normal, legend_warning, legend_critical, + message_error_warning, message_error_critical + ); } } else { error_w = 1; - paint_graph_status(0,0,0,0,0,0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical); + paint_graph_status( + 0,0,0,0,0,0, error_w, error_c, + legend_normal, legend_warning, legend_critical, + message_error_warning, message_error_critical + ); } } -/* End of relationship javascript */ /* ]]> */ diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 9a2c9df9f6..2bbbb18077 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -59,6 +59,14 @@ if ($delete) { } if ($result !== false) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_filter, + 'section' => 'Events', + 'id_user' => $config['id_user'], + ] + ); $result = true; } else { $result = false; diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 95785a0edd..6e604c7e1a 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -714,6 +714,14 @@ if ($is_management_allowed === true ); if ($result && (!$usedGroup['return'])) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_group, + 'section' => 'Tactic_group', + 'id_user' => $config['id_user'], + ] + ); ui_print_success_message(__('Group successfully deleted')); } else { ui_print_error_message( diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 037af05723..d7984c3212 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -74,6 +74,12 @@ if (is_metaconsole() === false) { 'link' => '', 'label' => __('Tactic group'), ], + ], + [ + 'id_element' => $id_group, + 'url' => 'gagent&sec2=godmode/groups/tactical&id_group='.$id_group, + 'label' => groups_get_name($id_group), + 'section' => 'Tactic_group', ] ); } diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index b267b40254..1d2bdd48ad 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -1,16 +1,31 @@ 'index.php?sec=main', - 'text' => __('Main'), + 'link' => '', + 'label' => __('Netflow'), ], - [ - 'link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', - 'text' => __('Netflow filters'), - ], - ]; + ], +); - ui_meta_print_page_header($nav_bar); - - ui_meta_print_header(__('Netflow filters')); +$is_windows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +if ($is_windows === true) { + ui_print_error_message(__('Not supported in Windows systems')); } $delete = (bool) get_parameter('delete'); @@ -190,30 +195,37 @@ foreach ($filters as $filter) { if (check_acl_restricted_all($config['id_user'], $filter['id_group'], 'AW')) { $table->cellclass[][3] = 'table_action_buttons'; - $data[3] = "".html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'invert_filter']).''; + $data[3] = ''; + $data[3] .= html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'main_menu_icon invert_filter']); + $data[3] .= ''; } array_push($table->data, $data); } -if (isset($data)) { - echo "
"; +$buttons = html_print_submit_button( + __('Create filter'), + 'crt', + false, + ['icon' => 'wand'], + true +); + +// hd($filters); +if (empty($filters) === false) { + echo ''; html_print_input_hidden('multiple_delete', 1); html_print_table($table); - echo "
"; - - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo '
'; echo '
'; + $buttons .= html_print_submit_button(__('Delete'), 'delete_btn', false, ['icon' => 'delete', 'mode' => 'secondary', 'form' => 'multiple_delete'], true); } else { ui_print_info_message(['no_close' => true, 'message' => __('There are no defined filters') ]); } echo '
'; -echo "
"; -html_print_submit_button(__('Create filter'), 'crt', false, 'class="sub wand"'); -echo '
'; +html_print_action_buttons( + $buttons +); echo '
'; ?> @@ -221,27 +233,14 @@ echo ''; diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 898c3becda..85d4ecb6c4 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -189,6 +189,14 @@ if ($delete_layout || $copy_layout) { 'tlayout', ['id' => $id_layout] ); + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_layout, + 'section' => 'Visual_Console', + 'id_user' => $config['id_user'], + ] + ); $auditMessage = ((bool) $result === true) ? 'Delete visual console' : 'Fail try to delete visual console'; db_pandora_audit( diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 15f9e391c3..6b5dda8159 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -875,7 +875,7 @@ if (defined('METACONSOLE')) { ], true ); - $form .= html_print_input_hidden('action', 'filter', true); + $form .= html_print_input_hidden('action', 'sort_items', true); $form .= ''; ui_toggle($form, __('Sort items'), '', '', false); diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php index 702a4e670b..44199148b6 100755 --- a/pandora_console/godmode/reporting/reporting_builder.main.php +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -176,6 +176,31 @@ if (is_metaconsole() === true) { ); } +if (is_metaconsole() === true) { + $table->data['description'][0] = __('Description'); + $table->data['description'][1] = html_print_textarea( + 'description', + 2, + 80, + $description, + '', + true + ); +} else { + $table->colspan[1][0] = 2; + $table->data[1][0] = html_print_label_input_block( + __('Description'), + html_print_textarea( + 'description', + 2, + 1, + $description, + '', + true + ) + ); +} + if ($report_id_user == $config['id_user'] || is_user_admin($config['id_user']) ) { @@ -222,7 +247,7 @@ if ($report_id_user == $config['id_user'] $table->data['access'][1] .= ''; $table->data['access'][1] .= ''; } else { - $table->data[1][0] = html_print_label_input_block( + $table->data[2][0] = html_print_label_input_block( __('Write Access').ui_print_help_tip( __('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true @@ -244,7 +269,7 @@ if ($report_id_user == $config['id_user'] $options['div_class'] = ''; } - $table->data[1][1] = html_print_label_input_block( + $table->data[2][1] = html_print_label_input_block( __('Group'), html_print_select_groups( false, @@ -277,7 +302,7 @@ if ($enterpriseEnable) { true ); } else { - $table->data[2][0] = html_print_label_input_block( + $table->data[2][1] = html_print_label_input_block( __('Non interactive report'), html_print_checkbox_switch( 'non_interactive', @@ -289,29 +314,6 @@ if ($enterpriseEnable) { } } -if (is_metaconsole() === true) { - $table->data['description'][0] = __('Description'); - $table->data['description'][1] = html_print_textarea( - 'description', - 2, - 80, - $description, - '', - true - ); -} else { - $table->data[2][1] = html_print_label_input_block( - __('Description'), - html_print_textarea( - 'description', - 2, - 1, - $description, - '', - true - ) - ); -} if (enterprise_installed() === true) { if (is_metaconsole() === true) { diff --git a/pandora_console/images/menu/fav_menu_gray.svg b/pandora_console/images/menu/fav_menu_gray.svg new file mode 100644 index 0000000000..8a894d7948 --- /dev/null +++ b/pandora_console/images/menu/fav_menu_gray.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / star@svg + Created with Sketch. + + + + \ No newline at end of file diff --git a/pandora_console/images/star_fav_menu.png b/pandora_console/images/star_fav_menu.png new file mode 100644 index 0000000000..5d1521f202 Binary files /dev/null and b/pandora_console/images/star_fav_menu.png differ diff --git a/pandora_console/images/world@svg.svg b/pandora_console/images/world@svg.svg new file mode 100644 index 0000000000..c71297eda4 --- /dev/null +++ b/pandora_console/images/world@svg.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / web@svg + Created with Sketch. + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/fav_menu.ajax.php b/pandora_console/include/ajax/fav_menu.ajax.php new file mode 100644 index 0000000000..0b837ec9b3 --- /dev/null +++ b/pandora_console/include/ajax/fav_menu.ajax.php @@ -0,0 +1,82 @@ + $url, + 'id_user' => $config['id_user'], + ], + ['*'] +); +$res = false; +$action = ''; +if ($exist !== false) { + $res = db_process_sql_delete( + 'tfavmenu_user', + [ + 'url' => $url, + 'id_user' => $config['id_user'], + ] + ); + $action = 'delete'; +} else { + $res = db_process_sql_insert( + 'tfavmenu_user', + [ + 'id_element' => $id_element, + 'url' => $url, + 'label' => $label, + 'section' => $section, + 'id_user' => $id_user, + ] + ); + $action = 'create'; +} + +if ($res !== false) { + echo json_encode(['success' => true, 'action' => $action]); +} else { + echo json_encode(['success' => false, 'action' => $action]); +} diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 94e573c4bc..30b84be44f 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -2074,6 +2074,14 @@ if (check_login()) { if ($monitor_filters === false) { echo 'error'; } else { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id, + 'section' => 'Modules', + 'id_user' => $config['id_user'], + ] + ); echo 'ok'; } } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ba4f96b678..3dc77d2a00 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 = 'PC230314'; +$build_version = 'PC230315'; $pandora_version = 'v7.0NG.769'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 0bca01f557..f8bb2fc024 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2769,6 +2769,16 @@ function agents_delete_agent($id_agents, $disableACL=false) enterprise_include_once('include/functions_agents.php'); enterprise_hook('agent_delete_from_cache', [$id_agent]); + // Delete agent from fav menu. + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_agent, + 'section' => 'Agents', + 'id_user' => $config['id_user'], + ] + ); + // Break the loop on error. if ((bool) $error === true) { break; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 41356e9455..0b343d449d 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -221,6 +221,8 @@ function reports_update_report($id_report, $values) */ function reports_delete_report($id_report) { + global $config; + $id_report = safe_int($id_report); if (empty($id_report)) { return false; @@ -231,6 +233,16 @@ function reports_delete_report($id_report) return false; } + // Delete report from fav menu. + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_report, + 'section' => 'Reporting', + 'id_user' => $config['id_user'], + ] + ); + @db_process_sql_delete('treport_content', ['id_report' => $id_report]); return @db_process_sql_delete('treport', ['id_report' => $id_report]); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 89dc45d586..59a7c1bb13 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -5014,7 +5014,8 @@ function ui_print_standard_header( string $help='', bool $godmode=false, array $options=[], - array $breadcrumbs=[] + array $breadcrumbs=[], + array $fav_menu_config=[] ) { // For standard breadcrumbs. ui_require_css_file('discovery'); @@ -5058,7 +5059,9 @@ function ui_print_standard_header( '', GENERIC_SIZE_TEXT, '', - $headerInformation->printHeader(true) + $headerInformation->printHeader(true), + false, + $fav_menu_config ); // } if ($return !== true) { @@ -5099,7 +5102,8 @@ function ui_print_page_header( $numChars=GENERIC_SIZE_TEXT, $alias='', $breadcrumbs='', - $hide_left_small=false + $hide_left_small=false, + $fav_menu_config=[] ) { global $config; @@ -5163,6 +5167,17 @@ function ui_print_page_header( } } + if (is_array($fav_menu_config) === true && is_metaconsole() === false) { + if (count($fav_menu_config) > 0) { + $buffer .= ui_print_fav_menu( + $fav_menu_config['id_element'], + $fav_menu_config['url'], + $fav_menu_config['label'], + $fav_menu_config['section'] + ); + } + } + $buffer .= ''; if (is_metaconsole() === true) { @@ -7089,20 +7104,6 @@ function ui_query_result_editor($name='default') true ); - $editorSubContainer .= html_print_div( - [ - 'class' => 'action-buttons edit-button', - 'content' => html_print_submit_button( - __('Execute query'), - 'execute_query', - false, - ['icon' => 'next'], - true - ), - ], - true - ); - $editorContainer = html_print_div( [ 'id' => $name.'_editor_container', @@ -7160,6 +7161,11 @@ function ui_query_result_editor($name='default') 'content' => ui_get_full_url(false, false, false, false), ] ); + + $buttons = html_print_submit_button(__('Execute query'), 'execute_query', false, ['icon' => 'update'], true); + html_print_action_buttons( + $buttons + ); } @@ -7804,4 +7810,48 @@ function ui_print_status_div($status) } return $return; +} + + +function ui_print_fav_menu($id_element, $url, $label, $section) +{ + global $config; + $label = io_safe_output($label); + if (strlen($label) > 18) { + $label = io_safe_input(substr($label, 0, 18).'...'); + } + + $fav = db_get_row_filter( + 'tfavmenu_user', + [ + 'url' => $url, + 'id_user' => $config['id_user'], + ], + ['*'] + ); + $config_fav_menu = [ + 'id_element' => $id_element, + 'url' => $url, + 'label' => $label, + 'section' => $section, + ]; + + $output = ''; + $output .= html_print_input_image( + 'fav-menu-action', + (($fav !== false) ? 'images/star_fav_menu.png' : 'images/star_dark.png'), + base64_encode(json_encode($config_fav_menu)), + '', + true, + [ + 'onclick' => 'favMenuAction(this)', + 'class' => (($fav !== false) ? 'active' : ''), + ] + ); + $output .= ''; + $output .= '
'; + $output .= '

'.__('Title').'

'; + $output .= html_print_input_text('label_fav_menu', '', '', 25, 255, true, false, true); + $output .= '
'; + return $output; } \ No newline at end of file diff --git a/pandora_console/include/javascript/elasticsearch_queryResult.js b/pandora_console/include/javascript/elasticsearch_queryResult.js index 6a57e266bc..c50f8955b3 100644 --- a/pandora_console/include/javascript/elasticsearch_queryResult.js +++ b/pandora_console/include/javascript/elasticsearch_queryResult.js @@ -9,7 +9,7 @@ view.renderer.setShowGutter(false); view.setReadOnly(true); view.setShowPrintMargin(false); -$("#submit-execute_query").click(function() { +$("#button-execute_query").click(function() { view.setValue(""); let text; let selectText = editor.getSelectedText(); diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index f8252e79ac..944c454747 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -834,3 +834,55 @@ function unblockSubmit(button) { expireCookie("downloadReady"); attempts = 30; } + +function favMenuAction(e) { + var data = JSON.parse(atob(e.value)); + if (data.label === "" && $(e).hasClass("active") === false) { + $("#dialog-fav-menu").dialog({ + title: "Please choose a title", + width: 330, + buttons: [ + { + class: + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next", + text: "Confirm", + click: function() { + data.label = $("#text-label_fav_menu").val(); + if (data.label.length > 18) { + data.label = data.label.slice(0, 18) + "..."; + } + + $(e).val(btoa(JSON.stringify(data))); + favMenuAction(e); + $(this).dialog("close"); + $("input[name='label_fav_menu']").val(""); + } + } + ] + }); + return; + } + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "include/ajax/fav_menu.ajax", + id_element: data["id_element"], + url: data["url"], + label: data["label"], + section: data["section"] + }, + success: function(res) { + if (res.success) { + if (res.action === "create") { + $("#image-fav-menu-action1").attr("src", "images/star_fav_menu.png"); + $("#image-fav-menu-action1").addClass("active"); + } else { + $("#image-fav-menu-action1").attr("src", "images/star_dark.png"); + $("#image-fav-menu-action1").removeClass("active"); + } + } + } + }); +} diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index c36a3116af..db8235681a 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -568,6 +568,16 @@ class Manager implements PublicLogin 'tdashboard', ['id' => $this->dashboardId] ); + + // Delete dashboard from fav menu. + \db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $this->dashboardId, + 'section' => 'Dashboard_', + 'id_user' => $config['id_user'], + ] + ); } // Audit. diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 04879e9eda..4bb7b200c6 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -315,3 +315,15 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool bottom: -20px; top: auto; } +#dialog-fav-menu { + display: none; +} +#dialog-fav-menu p { + margin: 0px; + padding-top: 40px; +} +.fav-menu input { + padding: 0px; + max-width: 20px !important; + max-height: 20px; +} diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index 0a777074ed..17ccb5c662 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -248,6 +248,10 @@ background: url(../../images/menu/events.svg) no-repeat 50% 50%; background-size: 18px; } +.icon_fav-menu { + background: url(../../images/menu/fav_menu_gray.svg) no-repeat 50% 50%; + background-size: 18px; +} /* users */ .icon_oper-users { @@ -700,3 +704,7 @@ ul li { width: 215px !important; height: auto !important; } + +.fav-menu { + margin-left: 9px; +} diff --git a/pandora_console/install.php b/pandora_console/install.php index 9b1d6590fa..35c0c798f3 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
$id, + 'section' => 'Network_map', + 'id_user' => $config['id_user'], + ] + ); $result_txt = ui_print_result_message( $result, __('Succesfully deleted'), diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 7ad542f637..ea8bf7629d 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -2412,6 +2412,12 @@ if ($networkmap === false) { 'link' => '', 'label' => __('Network maps'), ], + ], + [ + 'id_element' => $networkmap['id'], + 'url' => 'operation/agentes/pandora_networkmap&tab=view&id_networkmap='.$networkmap['id'], + 'label' => $networkmap['name'], + 'section' => 'Network_map', ] ); } diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index b739ecb97a..6b25fd3ec2 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -93,27 +93,6 @@ if (is_metaconsole() === false) { } } -// Header. -ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, - [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], - ] -); - - if (is_metaconsole() === false) { if ($section == 'fields') { include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; @@ -173,6 +152,13 @@ if ($ag_freestring !== '' || $moduletype !== '' || $datatype !== '' $autosearch = true; } +// The execution has not been done manually. +$userRequest = (bool) get_parameter('uptbutton'); +if ($userRequest === false) { + $autosearch = true; + $status = AGENT_MODULE_STATUS_NOT_NORMAL; +} + if (is_metaconsole() === false) { $ag_group = (int) get_parameter('ag_group', 0); } else { @@ -285,8 +271,79 @@ if ($loaded_filter['id_filter'] > 0) { $ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true); } } + + // Fav menu. + $fav_menu = [ + 'id_element' => $loaded_filter['id_filter'], + 'url' => 'operation/agentes/status_monitor&pure=&load_filter=1&filter_id='.$loaded_filter['id_filter'], + 'label' => $loaded_filter['id_name'], + 'section' => 'Modules', + ]; } +if (is_metaconsole() === false) { + $section = (string) get_parameter('section', 'view'); + + $buttons['fields'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/edit_columns@svg.svg', + true, + [ + 'title' => __('Custom fields'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + 'operation' => true, + ]; + + $buttons['view'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/logs@svg.svg', + true, + [ + 'title' => __('View'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + 'operation' => true, + ]; + + switch ($section) { + case 'fields': + $buttons['fields']['active'] = true; + $subpage = ' » '.__('Custom fields'); + break; + + default: + $buttons['view']['active'] = true; + break; + } +} + +// Header. +ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ], + (empty($fav_menu) === true) ? [] : $fav_menu +); + + $all_groups = []; // Agent group selector. @@ -2220,11 +2277,7 @@ if (empty($result) === false) { $tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', false); } } else { - if ($first_interaction) { - ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); - } else { - ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); - } + ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); } if (is_metaconsole() !== true) { @@ -2464,4 +2517,4 @@ if( value_swtich != "") { }else { chkbox.checked = false; } - + \ No newline at end of file diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 3f1ca54d2a..8dab5a61e0 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1071,7 +1071,7 @@ if (is_ajax() === true) { */ $load_filter_id = (int) get_parameter('filter_id', 0); - +$fav_menu = []; if ($load_filter_id === 0) { // Load user filter. $loaded_filter = db_get_row_sql( @@ -1093,6 +1093,14 @@ if ($load_filter_id === 0) { 'id_filter', $load_filter_id ); + + // Fav menu + $fav_menu = [ + 'id_element' => $load_filter_id, + 'url' => 'operation/events/events&pure=&load_filter=1&filter_id='.$load_filter_id, + 'label' => $loaded_filter['id_name'], + 'section' => 'Events', + ]; } // Do not load the user filter if we come from the 24h event graph. @@ -1583,7 +1591,8 @@ if ($pure) { 'link' => '', 'label' => __('Events'), ], - ] + ], + $fav_menu ); } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 62984b4078..b9e2d2d714 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -606,6 +606,44 @@ if ($access_console_node === true) { } } +$favorite_menu = db_get_all_rows_sql( + sprintf( + 'SELECT id_element, url, label, section + FROM tfavmenu_user + WHERE id_user = "%s" + ORDER BY section DESC', + $config['id_user'] + ) +); +// Favorite. +if ($favorite_menu !== false) { + $menu_operation['favorite']['text'] = __('Favorite'); + $menu_operation['favorite']['id'] = 'fav-menu'; + + $section = ''; + $sub = []; + $sub2 = []; + foreach ($favorite_menu as $key => $row) { + if ($row['section'] !== $section) { + $section = $row['section']; + $sub2 = []; + } + + $sub[$section]['text'] = __(str_replace('_', ' ', $section)); + $sub[$section]['type'] = 'direct'; + $sub[$section]['subtype'] = 'nolink'; + $sub[$section]['id'] = $row['section']; + + $sub2[$row['url']]['text'] = io_safe_output($row['label']); + $sub[$section]['sub2'] = $sub2; + } + + $menu_operation['favorite']['sub'] = $sub; +} + + + + // Workspace. $menu_operation['workspace']['text'] = __('Workspace'); $menu_operation['workspace']['sec2'] = 'operation/users/user_edit'; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 2164aeb562..f476c30bfe 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 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 General Public License @@ -125,48 +125,31 @@ $draw = get_parameter('draw_button', ''); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); -if (is_metaconsole() === false) { - // Header. - ui_print_standard_header( - __('Netflow live view'), - 'images/op_netflow.png', - false, - '', - false, - [], +// Header. +ui_print_standard_header( + __('Netflow live view'), + 'images/op_netflow.png', + false, + '', + false, + [], + [ [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Network'), - ], - ] - ); + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Network'), + ], + ] +); - $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; - if ($is_windows) { - ui_print_error_message(__('Not supported in Windows systems')); - } else { - netflow_print_check_version_error(); - } +$is_windows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +if ($is_windows === true) { + ui_print_error_message(__('Not supported in Windows systems')); } else { - $nav_bar = [ - [ - 'link' => 'index.php?sec=main', - 'text' => __('Main'), - ], - [ - 'link' => 'index.php?sec=netf&sec2=operation/netflow/nf_live_view', - 'text' => __('Netflow live view'), - ], - ]; - - ui_meta_print_page_header($nav_bar); - - ui_meta_print_header(__('Netflow live view')); + netflow_print_check_version_error(); } // Save user defined filter. @@ -390,6 +373,7 @@ if (empty($filter['advanced_filter']) === false) { $filterTable = new stdClass(); $filterTable->id = ''; +$filterTable->width = '100%'; $filterTable->class = 'filter-table-adv'; $filterTable->size = []; $filterTable->size[0] = '33%'; diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index de1c8dc0cb..7784450371 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -221,6 +221,12 @@ ui_print_standard_header( 'link' => '', 'label' => __('Custom reports'), ], + ], + [ + 'id_element' => $id_report, + 'url' => 'operation/reporting/reporting_viewer&id='.$id_report, + 'label' => reporting_get_name($id_report), + 'section' => 'Reporting', ] ); diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 0c295c9914..3114671e9c 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -240,6 +240,12 @@ if (!$config['pure']) { 'link' => '', 'label' => __('Visual console'), ], + ], + [ + 'id_element' => $visualConsoleId, + 'url' => 'operation/visual_console/render_view&id='.$visualConsoleId, + 'label' => $visualConsoleName, + 'section' => 'Visual_Console', ] ); } diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 6f25987db7..b96c1837f6 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.769 -%define release 230314 +%define release 230315 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 556ed56d5f..42df022d13 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.769 -%define release 230314 +%define release 230315 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 14b5261fa5..15a35bcad7 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.769 -%define release 230314 +%define release 230315 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 6e2a05114d..a753ed0afe 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4246,3 +4246,15 @@ CREATE TABLE IF NOT EXISTS `twelcome_tip_file` ( REFERENCES `twelcome_tip` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tfavmenu_user` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tfavmenu_user` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(255) NOT NULL, + `id_element` TEXT, + `url` TEXT NOT NULL, + `label` VARCHAR(255) NOT NULL, + `section` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`)); \ No newline at end of file diff --git a/pandora_console/views/dashboard/header.php b/pandora_console/views/dashboard/header.php index bfe6b3b242..26f588b5ea 100644 --- a/pandora_console/views/dashboard/header.php +++ b/pandora_console/views/dashboard/header.php @@ -296,6 +296,12 @@ if ($publicLink === false) { 'link' => '', 'label' => __('Dashboard'), ], + ], + [ + 'id_element' => $dashboardId, + 'url' => 'operation/dashboard/dashboard&dashboardId='.$dashboardId, + 'label' => $dashboardName, + 'section' => 'Dashboard_', ] ); } else { diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 37128ad6f9..6ba602aedc 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.769-230314 +Version: 7.0NG.769-230315 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 3155a66bd2..b31e1f97da 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.769-230314" +pandora_version="7.0NG.769-230315" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 66854b8a61..a617f9b3cb 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.769"; -my $pandora_build = "230314"; +my $pandora_build = "230315"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 98dffb79a9..801cb88442 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.769"; -my $pandora_build = "230314"; +my $pandora_build = "230315"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 7509a39e71..36a3b52e2c 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 3bf0b70e97..8b81d27a4f 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index b71463cb86..400c64cc20 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230314" +PI_BUILD="230315" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index a26d4711b7..767b7ce8ea 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.769 Build 230314"; +my $version = "7.0NG.769 Build 230315"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index e48c36a8ac..feae35ab6b 100755 --- 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.769 Build 230314"; +my $version = "7.0NG.769 Build 230315"; # save program name for logging my $progname = basename($0);