Merge remote-tracking branch 'origin/develop' into ent-9586-acls-en-llamada-a-funcion-get_tree_agent-de-la-api

This commit is contained in:
Luis 2022-12-14 16:25:36 +01:00
commit 7716157b8d
326 changed files with 87104 additions and 88137 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.exe filter=lfs diff=lfs merge=lfs -text

View File

@ -170,7 +170,7 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm" https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "yum install -y $extra_repos" "Installing extra repositories" execute_cmd "yum install -y $extra_repos" "Installing extra repositories"
execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP" execute_cmd "yum-config-manager --enable remi-php80" "Configuring PHP"
# Install percona Database # Install percona Database
#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf #[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf

View File

@ -20,7 +20,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables # define default variables
[ "$TZ" ] || TZ="Europe/Madrid" [ "$TZ" ] || TZ="Europe/Madrid"
[ "$MYVER" ] || MYVER=57 [ "$MYVER" ] || MYVER=57
[ "$PHPVER" ] || PHPVER=7 [ "$PHPVER" ] || PHPVER=8
[ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora [ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora [ "$DBUSER" ] || DBUSER=pandora

View File

@ -21,7 +21,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables # define default variables
[ "$TZ" ] || TZ="Europe/Madrid" [ "$TZ" ] || TZ="Europe/Madrid"
[ "$PHPVER" ] || PHPVER=7.4 [ "$PHPVER" ] || PHPVER=8.0
[ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora [ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora [ "$DBUSER" ] || DBUSER=pandora
@ -138,6 +138,9 @@ check_root_permissions
# Connectivity # Connectivity
check_repo_connection check_repo_connection
#Install awk, sed, grep if not present
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
# Systemd # Systemd
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
@ -155,7 +158,7 @@ execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
execute_cmd "awk --version" 'Checking needed tools: awk' execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep' execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed' execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "apt --version" 'Checking needed tools: dnf' execute_cmd "apt --version" 'Checking needed tools: apt'
# Creating working directory # Creating working directory
rm -rf "$WORKDIR" &>> "$LOGFILE" rm -rf "$WORKDIR" &>> "$LOGFILE"

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, AIX version # Version 7.0NG.767, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, FreeBSD Version # Version 7.0NG.767, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, HP-UX Version # Version 7.0NG.767, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, GNU/Linux # Version 7.0NG.767, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, GNU/Linux # Version 7.0NG.767, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, Solaris Version # Version 7.0NG.767, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.765 # Version 7.0NG.767
# This program is Free Software, you can redistribute it and/or modify it # 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 # under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version # Foundation; either version 2 of the Licence or any later version

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService(); Win32::Daemon::StopService();
} }
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################ ################################################################################
# Main # Main
################################################################################ ################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();
exit 1; exit 1;
} }
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status # Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') { if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled."); print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.765, AIX version # Version 7.0NG.767, AIX version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.765 # Version 7.0NG.767
# FreeBSD/IPSO version # FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena # Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.765, HPUX Version # Version 7.0NG.767, HPUX Version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765 # Version 7.0NG.767
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas # (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765 # Version 7.0NG.767
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas # (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765 # Version 7.0NG.767
# Licensed under GPL license v2, # Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.765, Solaris version # Version 7.0NG.767, Solaris version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, AIX version # Version 7.0NG.767, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.765-221024 Version: 7.0NG.767-221214
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.765-221024" pandora_version="7.0NG.767-221214"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -31,7 +31,7 @@ fi
if [ "$#" -ge 2 ]; then if [ "$#" -ge 2 ]; then
VERSION="$2" VERSION="$2"
else else
VERSION="7.0NG.765" VERSION="7.0NG.767"
fi fi
# Path for the generated DMG file # Path for the generated DMG file

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false"> <choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/> <pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice> </choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.765" onConclusion="none">pandorafms_src.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.767" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications"> <choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/> <pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice> </choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.765" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.767" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" /> <!-- <installation-check script="check()" />
<script> <script>
<![CDATA[ <![CDATA[

View File

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string> <key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string> <key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.765</string> <key>CFBundleVersion</key> <string>7.0NG.767</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.765 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string> <key>CFBundleGetInfoString</key> <string>7.0NG.767 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.765</string> <key>CFBundleShortVersionString</key> <string>7.0NG.767</string>
<key>NSPrincipalClass</key><string>NSApplication</string> <key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string> <key>NSMainNibFile</key><string>MainMenu</string>

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, GNU/Linux # Version 7.0NG.767, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, FreeBSD Version # Version 7.0NG.767, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, HP-UX Version # Version 7.0NG.767, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, GNU/Linux # Version 7.0NG.767, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, GNU/Linux # Version 7.0NG.767, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, NetBSD Version # Version 7.0NG.767, NetBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.765, Solaris Version # Version 7.0NG.767, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1014,8 +1014,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.765'; use constant AGENT_VERSION => '7.0NG.767';
use constant AGENT_BUILD => '221024'; use constant AGENT_BUILD => '221214';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -2403,6 +2403,11 @@ sub check_collections () {
if (open (MD5_FILE, "< $ConfDir/collections/$collection_md5_file")) { if (open (MD5_FILE, "< $ConfDir/collections/$collection_md5_file")) {
$local_collection_md5 = <MD5_FILE>; $local_collection_md5 = <MD5_FILE>;
close MD5_FILE; close MD5_FILE;
if ( ! defined ($local_collection_md5) ) {
log_message ('Collection', "Size of $ConfDir/collections/$collection_md5_file is 0");
unlink ("$ConfDir/collections/$collection_md5_file");
$local_collection_md5 = "Size 0";
}
} else { } else {
log_message ('Collection', "Could not open dir $ConfDir/collections/$collection_md5_file"); log_message ('Collection', "Could not open dir $ConfDir/collections/$collection_md5_file");
next; next;

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.767
%define release 221024 %define release 221214
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.767
%define release 221024 %define release 221214
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.765" PI_VERSION="7.0NG.767"
PI_BUILD="221024" PI_BUILD="221214"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -12,32 +12,34 @@
# #
################################################### ###################################################
from sys import argv try:
from sys import path from sys import argv
from sys import stderr from sys import stderr
from sys import exit from sys import exit
from subprocess import Popen from subprocess import Popen
from subprocess import PIPE from subprocess import PIPE
from subprocess import DEVNULL from subprocess import DEVNULL
from subprocess import getstatusoutput from subprocess import getstatusoutput
import psutil import psutil
except ModuleNotFoundError as err:
print("{} error: {}. Exiting...".format(argv[0], err), file=stderr)
exit(1)
global module_list
module_list = [] module_list = []
version = "1.1" VERSION = "1.2"
######################################################################################### #########################################################################################
# Powershell class # Powershell class
######################################################################################### #########################################################################################
class PSCheck: class PSCheck:
@staticmethod @staticmethod
def check_service(servicename, option=False, memcpu=False): def check_service(servicename, option=False, memcpu=False):
"""Check services with powershell by parsing their DisplayName. Returns a dict\ """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 list with the name of the service and a boolean with its status.\n
Requires service name (case insensitive).""" Requires service name (case insensitive)."""
pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'", pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'",
"|", "Select-Object", "-ExpandProperty", "Name"], "|", "Select-Object", "-ExpandProperty", "Name"],
stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
result = pscall.communicate() result = pscall.communicate()
result = str(result[0]).strip().split("\n") result = str(result[0]).strip().split("\n")
@ -50,15 +52,15 @@ class PSCheck:
procname = PSCheck.get_serviceprocess(element) procname = PSCheck.get_serviceprocess(element)
# Get process status # Get process status
parstatus = PSCheck.getstatus(element) parstatus = PSCheck.getstatus(element)
if memcpu == True and parstatus == 1: if memcpu and parstatus == 1:
usage = get_memcpu(str(procname), str(element)) usage = get_memcpu(str(procname), str(element))
output += usage output += usage
# Generate module with name and status # Generate module with name and status
parent = service_module(str(element), parstatus) parent = service_module(str(element), parstatus)
output += parent output += parent
if option == True: if option:
children = PSCheck.getchildren(element, memcpu) children = PSCheck.getchildren(element, memcpu)
if type(children) == list and len(children) > 1: if isinstance(children, list) and len(children) > 1:
for child in children: for child in children:
output += child output += child
else: else:
@ -66,7 +68,6 @@ class PSCheck:
else: else:
next next
#if output != '':
if output and element and procname: if output and element and procname:
return ({"name" : element, "process" : procname, "modules": output}) return ({"name" : element, "process" : procname, "modules": output})
else: else:
@ -84,22 +85,22 @@ class PSCheck:
status = PSCheck.getstatus(child) status = PSCheck.getstatus(child)
kids += service_module(str(child), status, "Service " + str(servicename) + " - Status") kids += service_module(str(child), status, "Service " + str(servicename) + " - Status")
if status: if status:
if memcpu == True: if memcpu:
kidsusage = get_memcpu(str(child)) kidsusage = get_memcpu(str(child))
for usage in kidsusage: for usage in kidsusage:
kids += usage kids += usage
else: else:
next next
return (kids) return kids
@staticmethod @staticmethod
def getstatus(servicename): def getstatus(servicename):
"""Gets the status of a given Windows service""" """Gets the status of a given Windows service"""
running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) +
"' |", "Select-Object", "-ExpandProperty", "Status"], "' |", "Select-Object", "-ExpandProperty", "Status"],
stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
status = running.communicate()[0].strip() status = running.communicate()[0].strip()
return (int(status == "Running")) return int(status == "Running")
@staticmethod @staticmethod
def get_serviceprocess(servicename): def get_serviceprocess(servicename):
@ -108,7 +109,7 @@ class PSCheck:
srv_pid = service.pid() srv_pid = service.pid()
process = psutil.Process(srv_pid) process = psutil.Process(srv_pid)
proc_name = process.name() proc_name = process.name()
return (proc_name) return proc_name
######################################################################################### #########################################################################################
@ -124,13 +125,13 @@ def service_module(name, value, parent=None):
"module_parent" : parent, "module_parent" : parent,
}] }]
#print ("service_module END "+str(now(0,1))) #print ("service_module END "+str(now(0,1)))
return (module) return module
def get_memcpu (process, servicename): def get_memcpu (process, servicename=None):
"""Creates a module for Memory and CPU for a given process. Returns a list of dictionaries.""" """Creates a module for Memory and CPU for a given process. Returns a list of dictionaries."""
modules = [] modules = []
if process: if process:
if servicename != None: if servicename is not None:
parentname = servicename parentname = servicename
else: else:
parentname = process parentname = process
@ -147,7 +148,7 @@ def get_memcpu (process, servicename):
"unit" : "%", "unit" : "%",
"module_parent" : "Service "+ parentname + " - Status", "module_parent" : "Service "+ parentname + " - Status",
}] }]
return (modules) return modules
def proc_percentbyname(procname): ############# 03/03/2020 def proc_percentbyname(procname): ############# 03/03/2020
"""Gets Memory and CPU usage for a given process. Returns a list.""" """Gets Memory and CPU usage for a given process. Returns a list."""
@ -165,7 +166,7 @@ def proc_percentbyname(procname): ############# 03/03/2020
except psutil.NoSuchProcess: except psutil.NoSuchProcess:
next next
#print ("proc_percentbyname END "+str(now(0,1))) #print ("proc_percentbyname END "+str(now(0,1)))
return ([sum(memory),sum(cpu)]) return [sum(memory),sum(cpu)]
def win_service(servicelist, option=False, memcpu=False): def win_service(servicelist, option=False, memcpu=False):
"""Creates modules for Windows servers.""" """Creates modules for Windows servers."""
@ -173,7 +174,7 @@ def win_service(servicelist, option=False, memcpu=False):
for srvc in servicelist: for srvc in servicelist:
if srvc and len(srvc) > 2: if srvc and len(srvc) > 2:
output = PSCheck.check_service(srvc, option, memcpu) output = PSCheck.check_service(srvc, option, memcpu)
if output != None and output["modules"]: if output is not None and output["modules"]:
modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"] modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"]
module_list.append(srvc) module_list.append(srvc)
#winprocess = output["name"] #winprocess = output["name"]
@ -197,9 +198,9 @@ def lnx_service(services_list, memcpu=False):
if sysctl == 0: if sysctl == 0:
### Systemd available ### Systemd available
syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE,
stdin=DEVNULL, universal_newlines=True) stdin=DEVNULL, universal_newlines=True)
result = syscall.communicate() result = syscall.communicate()
srvstatus= result[0].strip().lower().split("\n") srvstatus = result[0].strip().lower().split("\n")
if srvstatus[0] == "loadstate=not-found": if srvstatus[0] == "loadstate=not-found":
next next
else: else:
@ -212,7 +213,7 @@ def lnx_service(services_list, memcpu=False):
elif sysctl != 0 and servic == 0: elif sysctl != 0 and servic == 0:
### Systemd not available, switch to service command ### Systemd not available, switch to service command
syscall = Popen(["service", srvc, "status"], stdout=PIPE, syscall = Popen(["service", srvc, "status"], stdout=PIPE,
stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
result = syscall.communicate()[0].lower() result = syscall.communicate()[0].lower()
if "is running" in result: if "is running" in result:
modules += service_module(srvc, 1) modules += service_module(srvc, 1)
@ -223,15 +224,15 @@ def lnx_service(services_list, memcpu=False):
else: else:
next next
else: else:
print ("No systemd or service commands available. Exiting...", file=stderr) print("No systemd or service commands available. Exiting...", file=stderr)
exit() exit()
if status: if status:
module_list.append(srvc) module_list.append(srvc)
if memcpu == True: if memcpu:
modules += get_memcpu(srvc, None) modules += get_memcpu(srvc, None)
for m in modules: for m in modules:
print_module (m, 1) print_module(m, 1)
######################################################################################### #########################################################################################
@ -339,7 +340,7 @@ def print_module(module, str_flag=False):
#### Print flag #### Print flag
if str_flag is not False: if str_flag is not False:
print (module_xml) print(module_xml)
return (module_xml) return (module_xml)
@ -362,7 +363,7 @@ def main():
"postfix", "mysqld", "postgres", "oracle", "mongod"] "postfix", "mysqld", "postgres", "oracle", "mongod"]
discover(OS, service_list) discover(OS, service_list)
else: else:
print ("OS not recognized. Exiting...", file=stderr) print("OS not recognized. Exiting...", file=stderr)
exit() exit()
def discover(osyst, servicelist): def discover(osyst, servicelist):
@ -383,24 +384,24 @@ def discover(osyst, servicelist):
elif osyst == "Linux": elif osyst == "Linux":
lnx_service(servicelist, memcpu) lnx_service(servicelist, memcpu)
else: else:
print ("\nPandora FMS Autodiscovery plugin v{}".format(version)) print("\nPandora FMS Autodiscovery plugin v{}".format(VERSION))
print ("Checks the status of the services in list and monitors CPU and Memory for each of them.\n") print("Checks the status of the services in list and monitors CPU and Memory for each of them.\n")
print ("Usage:") print("Usage:")
print ("{} [options] [--usage]".format(argv[0])) print("{} [options] [--usage]".format(argv[0]))
print ("--help") print("--help")
print ("\tPrints this help screen") print("\tPrints this help screen")
print ("--default") print("--default")
print ("\tRuns this tool with default monitoring.") print("\tRuns this tool with default monitoring.")
print ("\tServices monitored by default for {}:".format(osyst)) print("\tServices monitored by default for {}:".format(osyst))
print ("\t",", ".join(servicelist)) print("\t", ", ".join(servicelist))
print ("--list \"<srvc1,srvc2,srvc3>\"") print("--list \"<srvc1,srvc2,srvc3>\"")
print ("\tReplaces default services for a given list (comma-separated)") print("\tReplaces default services for a given list (comma-separated)")
if osyst == "Windows": if osyst == "Windows":
print ("\tEach element of the list will be treated as a regexp, but they must be over 2 characters.") 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("\tElements under 2 characters will be discarded.")
print ("--usage") print("--usage")
print ("\tAdds modules for CPU and Memory usage per service/process (optional, can take some time).\n") print("\tAdds modules for CPU and Memory usage per service/process (optional, can take some time).\n")
##### RUN #### ##### RUN ####
main() main()

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService(); Win32::Daemon::StopService();
} }
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################ ################################################################################
# Main # Main
################################################################################ ################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();
exit 1; exit 1;
} }
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status # Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') { if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled."); print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.765 # Version 7.0NG.767
# This program is Free Software, you can redistribute it and/or modify it # 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 # under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version # Foundation; either version 2 of the Licence or any later version

Some files were not shown because too many files have changed in this diff Show More