diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 58c64f5677..68f584bb56 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.744-200406 +Version: 7.0NG.744-200407 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 9d79b755eb..2ef77996ae 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.744-200406" +pandora_version="7.0NG.744-200407" 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/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 34f9d8e02b..52ca10f17b 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -254,6 +254,9 @@ module_plugin pandora_mem_used module_plugin pandora_netusage +# Service autodiscovery plugin +module_plugin autodiscover --default + # Plugin for inventory on the agent (Only Enterprise) #module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index da1937cf81..970cc126a5 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.744'; -use constant AGENT_BUILD => '200406'; +use constant AGENT_BUILD => '200407'; # 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 1ca2654d76..ced8451deb 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.744 -%define release 200406 +%define release 200407 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 22339fec52..2faf27e873 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.744 -%define release 200406 +%define release 200407 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 b238a7dc46..55e3cb26c8 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.744" -PI_BUILD="200406" +PI_BUILD="200407" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/autodiscover b/pandora_agents/unix/plugins/autodiscover new file mode 100644 index 0000000000..cbe4de677e Binary files /dev/null and b/pandora_agents/unix/plugins/autodiscover differ diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index ba1e0b6444..b0f3c97c61 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.744 +# Version 7.0NG.744 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -245,6 +245,10 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\network.vbs" #module_crontab * 12-15 * * 1 #module_end +# Service autodiscovery plugin +module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default + + ######################################### # EXAMPLES # ######################################### diff --git a/pandora_agents/win32/bin/util/autodiscover.exe b/pandora_agents/win32/bin/util/autodiscover.exe new file mode 100644 index 0000000000..41b7bf3629 Binary files /dev/null and b/pandora_agents/win32/bin/util/autodiscover.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3f26dd55e1..32489c9944 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200406} +{200407} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 61e6b73618..dabb1a12ca 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.744(Build 200406)") +#define PANDORA_VERSION ("7.0NG.744(Build 200407)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 93ddf508f4..576f8ea7b7 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.744(Build 200406))" + VALUE "ProductVersion", "(7.0NG.744(Build 200407))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4105406deb..8127ba5a01 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.744-200406 +Version: 7.0NG.744-200407 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 94c250b30f..cc9fe49320 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.744-200406" +pandora_version="7.0NG.744-200407" package_pear=0 package_pandora=1 diff --git a/pandora_console/images/os_icons/satellite.png b/pandora_console/images/os_icons/satellite.png index bc585e076f..f30573039c 100644 Binary files a/pandora_console/images/os_icons/satellite.png and b/pandora_console/images/os_icons/satellite.png differ diff --git a/pandora_console/images/satellite.png b/pandora_console/images/satellite.png index bc585e076f..f30573039c 100644 Binary files a/pandora_console/images/satellite.png and b/pandora_console/images/satellite.png differ diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ce18f53213..38523d5223 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 = 'PC200406'; +$build_version = 'PC200407'; $pandora_version = 'v7.0NG.744'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/javascript/pandora_taskList.js b/pandora_console/include/javascript/pandora_taskList.js index 0a61e1a831..0d0b1f8298 100644 --- a/pandora_console/include/javascript/pandora_taskList.js +++ b/pandora_console/include/javascript/pandora_taskList.js @@ -82,6 +82,7 @@ function fetchTaskList(id, callback) { } function show_map(id, name) { + var myPos = ["center" / 2, 1]; $("#map_task") .empty() .hide() @@ -91,8 +92,9 @@ function show_map(id, name) { resizable: true, draggable: true, modal: false, - width: 1280, - height: 700 + width: 900, + height: 550, + position: { my: "center", at: "center", of: window } }) .show(); diff --git a/pandora_console/install.php b/pandora_console/install.php index b2702f2466..c57e0fc2ca 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
'; + echo '
'; $width = '90%'; $height = '450'; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index e8e5c5896f..9337cf9a53 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1538,7 +1538,7 @@ if (!empty($result)) { $graph_params_str = http_build_query($graph_params); - $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 1000, 700)'; $data[8] = get_module_realtime_link_graph($row); diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index a52ecba5f9..4cef1ddb54 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.744 -%define release 200406 +%define release 200407 # 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 74d0ceeb2c..27d34caf52 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.744 -%define release 200406 +%define release 200407 # 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 928ea2300d..201ecea0a2 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.744 -%define release 200406 +%define release 200407 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_plugins/Autodiscover services/autodiscover b/pandora_plugins/Autodiscover services/autodiscover new file mode 100644 index 0000000000..cbe4de677e Binary files /dev/null and b/pandora_plugins/Autodiscover services/autodiscover differ diff --git a/pandora_plugins/Autodiscover services/autodiscover.exe b/pandora_plugins/Autodiscover services/autodiscover.exe new file mode 100644 index 0000000000..41b7bf3629 Binary files /dev/null and b/pandora_plugins/Autodiscover services/autodiscover.exe differ diff --git a/pandora_plugins/Autodiscover services/autodiscover.py b/pandora_plugins/Autodiscover services/autodiscover.py new file mode 100644 index 0000000000..78a70cddba --- /dev/null +++ b/pandora_plugins/Autodiscover services/autodiscover.py @@ -0,0 +1,398 @@ +#!/usr/bin/env python3 +################################################### +# +# Pandora FMS Autodiscovery plugin. +# Checks the status of the services in list and monitors CPU and Memory for each of them. +# +# (c) A. Kevin Rojas +# +# TO DO LIST: +# - Enable child services detection (Windows) +# - Make CPU/Memory usage available for child services (Windows) +# +################################################### + +from sys import argv, path, stderr, exit +import psutil +from subprocess import * + +global module_list +module_list = [] + + +######################################################################################### +# 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 == True 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 == True: + children = PSCheck.getchildren(element, memcpu) + if type(children) == list and len(children) > 1: + for child in children: + output += child + else: + output += children + else: + next + + #if output != '': + if output and element and procname: + return ({"name" : element, "process" : procname, "modules": output}) + else: + return (None) + + @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 == True: + kidsusage = get_memcpu(str(child)) + for usage in kidsusage: + kids += usage + 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) + + +######################################################################################### +# Services creation +######################################################################################### + +def service_module(name, value, parent=None): + #print ("service_module BEGIN "+str(now(0,1))) + module = [{ + "name" : "Service "+ name + " - Status", + "type" : "generic_proc", + "value" : value, + "module_parent" : parent, + }] + #print ("service_module END "+str(now(0,1))) + return (module) + +def get_memcpu (process, servicename): + """Creates a module for Memory and CPU for a given process. Returns a list of dictionaries.""" + modules = [] + if process: + if servicename != None: + parentname = servicename + else: + parentname = process + modules += [{ + "name" : "Service "+ process + " - Memory usage", + "type" : "generic_data", + "value" : proc_percentbyname(process)[0], + "unit" : "%", + "module_parent" : "Service "+ parentname + " - Status", + }, + {"name" : "Service "+ process + " - CPU usage", + "type" : "generic_data", + "value" : proc_percentbyname(process)[1], + "unit" : "%", + "module_parent" : "Service "+ parentname + " - Status", + }] + return (modules) + +def proc_percentbyname(procname): ############# 03/03/2020 + """Gets Memory and CPU usage for a given process. Returns a list.""" + #print ("proc_percentbyname BEGIN "+str(now(0,1))) + procs = [p for p in psutil.process_iter() if procname in p.name().lower()] + memory = [] + cpu = [] + try: + for proc in procs: + if proc.name() == procname: + cpu.append(proc.cpu_percent(interval=0.5)) + memory.append(proc.memory_percent()) + else: + next + except psutil.NoSuchProcess: + 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 != 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", "is-active", srvc], stdout=PIPE, + stdin=DEVNULL, universal_newlines=True) + result = syscall.communicate() + result = result[0].strip().lower() + if result == "active": + modules += service_module(srvc, 1) + status = 1 + elif result == "inactive": + modules += service_module(srvc, 0) + status = 0 + elif result == "unknown": + next + 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 == True: + modules += get_memcpu(srvc, None) + + for m in modules: + print_module (m, 1) + + +######################################################################################### +# print_module function +######################################################################################### +def print_module(module, str_flag=False): + """Returns module in XML format. Accepts only {dict}.\n + + Only works with one module at a time: otherwise iteration is needed. + + Module "value" field accepts str type or [list] for datalists. + + Use not_print_flag to avoid printing the XML (only populates variables). + """ + data = dict(module) + module_xml = ("\n" + "\t\n" + "\t" + str(data["type"]) + "\n" + ) + #### Strip spaces if module not generic_data_string + if type(data["type"]) is not str and "string" not in data["type"]: + data["value"] = data["value"].strip() + if isinstance(data["value"], list): # Checks if value is a list + module_xml += "\t\n" + for value in data["value"]: + if type(value) is dict and "value" in value: + module_xml += "\t\n" + module_xml += "\t\t\n" + if "timestamp" in value: + module_xml += "\t\t\n" + module_xml += "\t\n" + else: + module_xml += "\t\n" + if "desc" in data: + module_xml += "\t\n" + if "unit" in data: + module_xml += "\t\n" + if "interval" in data: + module_xml += "\t\n" + if "tags" in data: + module_xml += "\t" + str(data["tags"]) + "\n" + if "module_group" in data: + module_xml += "\t" + str(data["module_group"]) + "\n" + if "module_parent" in data and data["module_parent"] != None: + module_xml += "\t" + str(data["module_parent"]) + "\n" + if "min_warning" in data: + module_xml += "\t\n" + if "max_warning" in data: + module_xml += "\t\n" + if "min_critical" in data: + module_xml += "\t\n" + if "max_critical" in data: + module_xml += "\t\n" + if "str_warning" in data: + module_xml += "\t\n" + if "str_critical" in data: + module_xml += "\t\n" + if "critical_inverse" in data: + module_xml += "\t\n" + if "warning_inverse" in data: + module_xml += "\t\n" + if "max" in data: + module_xml += "\t\n" + if "min" in data: + module_xml += "\t\n" + if "post_process" in data: + module_xml += "\t\n" + if "disabled" in data: + module_xml += "\t\n" + if "min_ff_event" in data: + module_xml += "\t\n" + if "status" in data: + module_xml += "\t\n" + if "timestamp" in data: + module_xml += "\t\n" + if "custom_id" in data: + module_xml += "\t\n" + if "critical_instructions" in data: + module_xml += "\t\n" + if "warning_instructions" in data: + module_xml += "\t\n" + if "unknown_instructions" in data: + module_xml += "\t\n" + if "quiet" in data: + module_xml += "\t\n" + if "module_ff_interval" in data: + module_xml += "\t\n" + if "crontab" in data: + module_xml += "\t\n" + if "min_ff_event_normal" in data: + module_xml += "\t\n" + if "min_ff_event_warning" in data: + module_xml += "\t\n" + if "min_ff_event_critical" in data: + module_xml += "\t\n" + if "ff_type" in data: + module_xml += "\t\n" + if "ff_timeout" in data: + module_xml += "\t\n" + if "each_ff" in data: + module_xml += "\t\n" + if "module_parent_unlink" in data: + module_xml += "\t\n" + if "global_alerts" in data: + for alert in data["alert"]: + module_xml += "\t\n" + module_xml += "\n" + + #### Print flag + if str_flag is not False: + print (module_xml) + + return (module_xml) + + +######################################################################################### +# MAIN +######################################################################################### + +def main(): + """Checks OS and calls the discover function.""" + if psutil.WINDOWS: + OS = "Windows" + 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" + service_list = ["httpd", "apache2", "nginx", "ldap", "docker", + "postfix", "mysqld", "postgres", "oracle", "mongod"] + discover(OS, service_list) + else: + print ("OS not recognized. Exiting...", file=stderr) + exit() + +def discover(osyst, servicelist): + """Shows help and triggers the creation of service modules""" + if "--usage" in argv: + memcpu = True + else: + memcpu = False + if len(argv) > 2 and argv[1] == "--list": + servicelist = argv[2].split(",") + if osyst == "Windows": + win_service(servicelist, False, memcpu) ## False won't get children + elif osyst == "Linux": + lnx_service(servicelist, memcpu) + elif len(argv) > 1 and argv[1] == "--default": + if osyst == "Windows": + win_service(servicelist, False, memcpu) ## False won't get children + elif osyst == "Linux": + lnx_service(servicelist, memcpu) + else: + print ("\nPandora FMS Autodiscovery plugin.") + print ("Checks the status of the services in list and monitors CPU and Memory for each of them.\n") + print ("Usage:") + print ("{} [options] [--usage]".format(argv[0])) + print ("--help") + print ("\tPrints this help screen") + print ("--default") + print ("\tRuns this tool with default monitoring.".format(argv[0])) + print ("\tServices monitored by default for {}:".format(osyst)) + print ("\t",", ".join(servicelist)) + print ("--list \"\"") + print ("\tReplaces default services for a given list (comma-separated)") + if osyst == "Windows": + print ("\tEach element of the list will be treated as a regexp, but they must be over 2 characters.") + print ("\tElements under 2 characters will be discarded.") + print ("--usage") + print ("\tAdds modules for CPU and Memory usage per service/process (optional, can take some time).\n") + + +##### RUN #### +main() \ No newline at end of file diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 25ecc64fe5..66a66386f9 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.744-200406 +Version: 7.0NG.744-200407 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 b46b477387..1da4be99df 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.744-200406" +pandora_version="7.0NG.744-200407" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index effafaeb3b..dee508cb4c 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.744"; -my $pandora_build = "200406"; +my $pandora_build = "200407"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 1bb16f5db6..f05785755d 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -633,8 +633,9 @@ Process an alert given the status returned by pandora_evaluate_alert. =cut ########################################################################## -sub pandora_process_alert ($$$$$$$$;$) { - my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $timestamp, $extra_macros) = @_; +sub pandora_process_alert ($$$$$$$$;$$) { + my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $timestamp, + $extra_macros, $is_correlated_alert) = @_; if (defined ($agent)) { logger ($pa_config, "Processing alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output($agent->{'nombre'}) . "': " . (defined ($AlertStatus[$rc]) ? $AlertStatus[$rc] : 'Unknown status') . ".", 10); @@ -740,7 +741,8 @@ sub pandora_process_alert ($$$$$$$$;$) { last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?', $alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id); - pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, 0, $extra_macros); + pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, + $dbh, $timestamp, 0, $extra_macros, $is_correlated_alert); return; } } @@ -752,9 +754,10 @@ Execute the given alert. =cut ########################################################################## -sub pandora_execute_alert ($$$$$$$$$;$) { +sub pandora_execute_alert ($$$$$$$$$;$$) { my ($pa_config, $data, $agent, $module, - $alert, $alert_mode, $dbh, $timestamp, $forced_alert, $extra_macros) = @_; + $alert, $alert_mode, $dbh, $timestamp, $forced_alert, + $extra_macros, $is_correlated_alert) = @_; # 'in-process' events can inhibit alers too. if ($pa_config->{'event_inhibit_alerts'} == 1 && $alert_mode != RECOVERED_ALERT) { @@ -922,9 +925,50 @@ sub pandora_execute_alert ($$$$$$$$$;$) { #If we've spotted an alert recovered, we set the new event's severity to 2 (NORMAL), otherwise the original value is maintained. my ($text, $event, $severity) = ($alert_mode == RECOVERED_ALERT) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'}); - pandora_event ($pa_config, "Alert $text (" . safe_output($alert->{'name'}) . ") " . (defined ($module) ? 'assigned to ('. safe_output($module->{'nombre'}) . ")" : ""), - (defined ($agent) ? $agent->{'id_grupo'} : 0), (defined ($agent) ? $agent->{'id_agente'} : 0), $severity, (defined ($alert->{'id_template_module'}) ? $alert->{'id_template_module'} : 0), - (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), $event, 0, $dbh, 'monitoring_server', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions); + if (defined($is_correlated_alert) && $is_correlated_alert == 1) { + $text = "Correlated alert $text"; + pandora_event ( + $pa_config, + "$text (" . safe_output($alert->{'name'}) . ") " . (defined ($module) ? 'assigned to ('. safe_output($module->{'nombre'}) . ")" : ""), + (defined ($agent) ? $agent->{'id_grupo'} : 0), + (defined ($agent) ? $agent->{'id_agente'} : 0), + $severity, + (defined ($alert->{'id_template_module'}) ? $alert->{'id_template_module'} : 0), + (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), + $event, + 0, + $dbh, + 'monitoring_server', + '', + '', + '', + '', + $critical_instructions, + $warning_instructions, + $unknown_instructions + ); + } else { + pandora_event ( + $pa_config, + "$text (" . safe_output($alert->{'name'}) . ") " . (defined ($module) ? 'assigned to ('. safe_output($module->{'nombre'}) . ")" : ""), + (defined ($agent) ? $agent->{'id_grupo'} : 0), + (defined ($agent) ? $agent->{'id_agente'} : 0), + $severity, + (defined ($alert->{'id_template_module'}) ? $alert->{'id_template_module'} : 0), + (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), + $event, + 0, + $dbh, + 'monitoring_server', + '', + '', + '', + '', + $critical_instructions, + $warning_instructions, + $unknown_instructions + ); + } } } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 9824b8cf16..5eeeb8a171 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,7 +33,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.744"; -my $pandora_build = "200406"; +my $pandora_build = "200407"; 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 956aa83e79..f0c3892ee4 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.744 -%define release 200406 +%define release 200407 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index bc0e8fbbe4..66aa4329a9 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.744 -%define release 200406 +%define release 200407 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 71350caa9c..154cde97df 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.744" -PI_BUILD="200406" +PI_BUILD="200407" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index a0e53e35d9..96c44efc84 100644 --- 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.744 PS200406"; +my $version = "7.0NG.744 PS200407"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 494e4aff95..73cb9227e2 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.744 PS200406"; +my $version = "7.0NG.744 PS200407"; # save program name for logging my $progname = basename($0);