diff --git a/extras/deploy-scripts/pandora_agent_deploy.sh b/extras/deploy-scripts/pandora_agent_deploy.sh index eac5a02930..9292998ccf 100644 --- a/extras/deploy-scripts/pandora_agent_deploy.sh +++ b/extras/deploy-scripts/pandora_agent_deploy.sh @@ -68,7 +68,7 @@ check_root_permissions () { install_autodiscover () { local arch=$1 - wget https://pandorafms.com/library/wp-content/uploads/2020/04/autodiscover-linux.zip + wget http://firefly.artica.es/projects/autodiscover-linux.zip unzip autodiscover-linux.zip chmod +x $arch/autodiscover mv -f $arch/autodiscover /etc/pandora/plugins/autodiscover diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 00c31d911b..7f70addfec 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -151,7 +151,7 @@ execute_cmd "yum install -y $extra_repos" "Installing extra repositories" execute_cmd "yum-config-manager --enable remi-php73" "Configuring PHP" # Install percona Database -[ -f /etc/resolv.conf ] && rm -rf /etc/my.cnf +[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf execute_cmd "yum install -y Percona-Server-server-57" "Installing Percona Server" # Console dependencies @@ -429,6 +429,7 @@ sed -i -e "s/^max_input_time.*/max_input_time = -1/g" /etc/php.ini sed -i -e "s/^max_execution_time.*/max_execution_time = 0/g" /etc/php.ini sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini +sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini cat > /var/www/html/index.html << EOF_INDEX diff --git a/extras/docker/centos8/pandora-stack/sources/init_pandora.sh b/extras/docker/centos8/pandora-stack/sources/init_pandora.sh index 7c000ebebd..76a0954bb8 100755 --- a/extras/docker/centos8/pandora-stack/sources/init_pandora.sh +++ b/extras/docker/centos8/pandora-stack/sources/init_pandora.sh @@ -149,6 +149,7 @@ EOF_INDEX sed -i -e "s/^max_execution_time.*/max_execution_time = 0/g" /etc/php.ini sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini + sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini echo "- Setting Public URL: $PUBLICURL" q=$(mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "select token from tconfig;" | grep public_url) diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 0b0218fd34..b64a2dc4ea 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, AIX version +# Version 7.0NG.756, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index d2251c41ba..69983a0775 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, FreeBSD Version +# Version 7.0NG.756, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 6f0e8d6e6e..2213d2135b 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, HP-UX Version +# Version 7.0NG.756, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 6f65b704d8..559795971f 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, GNU/Linux +# Version 7.0NG.756, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index b3cfa41db6..96e78f48bd 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, GNU/Linux +# Version 7.0NG.756, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index c952eedd88..13a72353a0 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, Solaris Version +# Version 7.0NG.756, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 70fefa6f00..2f003f7dea 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2021 Artica Soluciones Tecnologicas -# Version 7.0NG.755 +# Version 7.0NG.756 # 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 # Foundation; either version 2 of the Licence or any later version diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 34df0fff2d..ce8ee249b5 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.755, AIX version +# Version 7.0NG.756, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 9850e82438..c67b1f7b75 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.755 +# Version 7.0NG.756 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index d24b488e43..4696abf65e 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.755, HPUX Version +# Version 7.0NG.756, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 45f2940a99..eeacf16b01 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755 +# Version 7.0NG.756 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index d14f54dc9f..9574810cdd 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755 +# Version 7.0NG.756 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index a634d59866..509988935e 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755 +# Version 7.0NG.756 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 949a86b747..e40edc5de5 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.755, Solaris version +# Version 7.0NG.756, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 3f739f52ec..8d7610ce47 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.755, AIX version +# Version 7.0NG.756, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index cf998519b7..59ee0d826e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.755-210714 +Version: 7.0NG.756-210901 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 d4abcf2576..e77a70c178 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.755-210714" +pandora_version="7.0NG.756-210901" 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/Darwin/dmg/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index 53c52ca387..9d3ba98b42 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.755" + VERSION="7.0NG.756" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index 8a5eca5c84..7d83113d91 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk upload (Local) -conf_ftp_putfile /home/mariopc/Descargas/ejemplo.zip +conf_ftp_putfile /tmp/test_upload.zip # Configure name of ftp file --> upload (FTP server) -conf_ftp_putname prueba.zip +conf_ftp_putname /tmp/test.zip # Configure Ip for FTP Connection conf_ftp_host localhost # Configure name of ftp file --> download (FTP server) -conf_ftp_getfile prueba.zip +conf_ftp_getfile /tmp/test.zip # Configure complete name os ftp file --> download (Local) -conf_ftp_getname prueba.zip +conf_ftp_getname /tmp/test.zip # Configure Operating System (Unix or Windows) conf_operating_system Unix @@ -34,10 +40,10 @@ conf_operating_system Unix conf_ftp_compare write -conf_ftp_compare_file prueba.zip +conf_ftp_compare_file /tmp/prueba.zip -conf_local_comp_file prueba.zip +conf_local_comp_file /tmp/prueba.zip conf_local_downcomp_file /tmp/prueba.zip diff --git a/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl b/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl index 0aa463e597..e464c42057 100644 --- a/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl +++ b/pandora_plugins/FTP/ftp_plugin/plugin_ftp.pl @@ -8,6 +8,7 @@ use strict; use warnings; use Data::Dumper; use Net::FTP; +use Net::SFTP::Foreign; use Time::HiRes qw ( gettimeofday ); my $archivo_cfg = $ARGV[0]; @@ -115,6 +116,14 @@ sub load_external_setup ($) if ($parametro =~ m/^conf\_ftp\_host\s(.*)/i) { $plugin_setup{"conf_ftp_host"} = $1; } + + if ($parametro =~ m/^conf\_ftp\_port\s(.*)/i) { + $plugin_setup{"conf_ftp_port"} = $1; + } + + if ($parametro =~ m/^conf\_ftp\_sftp\s(.*)/i) { + $plugin_setup{"conf_ftp_sftp"} = $1; + } if ($parametro =~ m/^conf\_ftp\_putfile\s(.*)/i) { $plugin_setup{"conf_ftp_putfile"} = $1; @@ -184,20 +193,38 @@ load_external_setup ($archivo_cfg); #------------------------------------------------------------------------- # Start session in FTP server #-------------------------------------------------------------------------- - -my $ftp = Net::FTP->new($plugin_setup{"conf_ftp_host"}) or die("Unable to connect to server: $!");#Connect FTP server -$ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or die("Failed Login: $!");# Login at FTP server +my $ftp; +if (($plugin_setup{"conf_ftp_sftp"}) && ( $plugin_setup{"conf_ftp_sftp"} == 1)){ + if ($plugin_setup{"conf_ftp_port"}){ + #port => $plugin_setup{"port"}, + $ftp = Net::SFTP::Foreign->new(host => $plugin_setup{"conf_ftp_host"}, port => $plugin_setup{"conf_ftp_port"}, stderr_discard => 1, user => $plugin_setup{"conf_ftp_user"} , password => $plugin_setup{"conf_ftp_pass"},expect_log_user => 'false'); + if($ftp->error){ + die($ftp->error); + } + }else{ + $ftp = Net::SFTP::Foreign->new(host => $plugin_setup{"conf_ftp_host"}, stderr_discard => 1, user => $plugin_setup{"conf_ftp_user"} , password => $plugin_setup{"conf_ftp_pass"},expect_log_user => 'false'); + if($ftp->error){ + die($ftp->error); + } + } +} else { + if ($plugin_setup{"conf_ftp_port"}){ + $ftp = Net::FTP->new(host => $plugin_setup{"conf_ftp_host"},port => $plugin_setup{"conf_ftp_port"}) or die("Unable to connect to server: $!");#Connect FTP server + }else{ + $ftp = Net::FTP->new($plugin_setup{"conf_ftp_host"}) or die("Unable to connect to server: $!");#Connect FTP server + } + $ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or die("Failed Login: $!");# Login at FTP server #print_module ( "Disp_FTP_$plugin_setup{conf_ftp_host}" , "generic_proc", 1, " Determines whether FTP login to $plugin_setup{conf_ftp_host} has been successful or not" ); +} #------------------------------------------------------------------------- # Returns the module that shows the time and transfer rate.(Upload a file) #-------------------------------------------------------------------------- my $clock0 = gettimeofday(); - $ftp->put($plugin_setup{"conf_ftp_putfile"},$plugin_setup{"conf_ftp_putname"});# Upload file at FTP server + $ftp->put($plugin_setup{"conf_ftp_putfile"},$plugin_setup{"conf_ftp_putname"}) or die("Cannot upload file to server");# Upload file at FTP server my $clock1 = gettimeofday(); my $clockd = $clock1 - $clock0;# Calculate upload transfer time - $ftp->size($plugin_setup{"conf_ftp_putname"});# File size - my $putrate = $ftp->size($plugin_setup{"conf_ftp_putname"})/$clockd;# Calculate rate transfer + my $putrate = $ftp->stat($plugin_setup{"conf_ftp_putname"})->size/$clockd;# Calculate rate transfer my $time_puftp=sprintf("%.2f",$clockd); my $rate_puftp=sprintf("%.2f",$putrate); @@ -212,8 +239,8 @@ $ftp->login($plugin_setup{"conf_ftp_user"},$plugin_setup{"conf_ftp_pass"}) or di $ftp->get($plugin_setup{"conf_ftp_getfile"},$plugin_setup{"conf_ftp_getname"}); my $clock3 = gettimeofday(); my $clockg = $clock3 - $clock2; - $ftp->size($plugin_setup{"conf_ftp_getname"}); - my $getrate = $ftp->size($plugin_setup{"conf_ftp_getname"})/$clockg; + #$ftp->stat($plugin_setup{"conf_ftp_getname"})->size; + my $getrate = $ftp->stat($plugin_setup{"conf_ftp_getname"})->size/$clockg; my $time_getftp=sprintf("%.2f",$clockg); my $rate_getftp=sprintf("%.2f",$getrate); diff --git a/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py b/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py index 522f5fb75e..715657da28 100644 --- a/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py +++ b/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py @@ -102,6 +102,9 @@ def get_graph_by_moduleid (baseUrl,pUser, pPass, apiPass, moduleId, graphInterva if graph.text == "Id does not exist in database.": print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None + if graph.text == "The user has not enough permissions for perform this action.": + print (f"Error requested Pandora api url, status code: {graph.text} Skiping graph generation") + return None except: print("Error requested api url. skipping graph generation") return None diff --git a/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py b/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py index b09938b885..5eb24fc865 100644 --- a/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py +++ b/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py @@ -106,6 +106,9 @@ def get_graph_by_moduleid (baseUrl,pUser, pPass, apiPass, moduleId, graphInterva if graph.text == "Id does not exist in database.": print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None + if graph.text == "The user has not enough permissions for perform this action.": + print (f"Error requested Pandora api url, status code: {graph.text} Skiping graph generation") + return None except: print("Error requested api url. skipping graph generation") diff --git a/pandora_plugins/message_app_connectors/telegram-bot-cli/pandora-telegram-cli.py b/pandora_plugins/message_app_connectors/telegram-bot-cli/pandora-telegram-cli.py index bcba8b65b0..8ee7520355 100644 --- a/pandora_plugins/message_app_connectors/telegram-bot-cli/pandora-telegram-cli.py +++ b/pandora_plugins/message_app_connectors/telegram-bot-cli/pandora-telegram-cli.py @@ -1,27 +1,169 @@ import requests, argparse, json, sys, os +from datetime import datetime +from base64 import b64decode + +__version__='080621' ### Variables and arg parser ### -parser = argparse.ArgumentParser(description='Bot telegram cli') +parser = argparse.ArgumentParser(description=f'Bot telegram cli, Version: {__version__}') parser.add_argument('-m', '--message', help='Message to be send', required=True) parser.add_argument('-t', '--token', help='Bot token', required=True) parser.add_argument('-c', '--chat_id', help='chat id to send messages', required=True) +parser.add_argument('--api_conf', help='Api configuration parameters in coma separate keypairs. EX "user=admin,pass=pandora,api_pass=1234,api_url=http://test.artica.es/pandora_console/include/api.php"') +parser.add_argument('--module_graph', help='Uses pandora API to generate a module graph and attach it to the alert needs module_id and interval parameters in coma separate keypairs. EX "module_id=55,interval=3600"') +parser.add_argument('--tmp_dir', help='Temporary path to store graph images', default='/tmp') args = parser.parse_args() +def parse_dic(cValues): + """convert coma separate keypairs into a dic. EX "test=5,house=8,market=2" wil return "{'test': '5', 'casa': '8', 'mercado': '2'}" """ + data={} + try : + for kv in cValues.split(","): + k,v = kv.strip().split("=") + data[k.strip()]=v.strip() + except Exception as e : + print(f"Warning, error parsing keypairs values: {e}") + return data + + +def parse_api_conf(cConf): + """Check apiconfiguration parameters """ + if args.api_conf : + # Parse Api config + print ("Api config enable", file=sys.stderr) + apid = parse_dic(cConf) + + if apid.get("user") is None: + print ("Warning. no user defined in api_conf keypairs, skiping graph generation.") + return None + + if apid.get("pass") is None: + print ("Warning. no password defined in api_conf keypairs, skiping graph generation.") + return None + + if apid.get("api_pass") is None: + print ("Warning. no api pass defined in api_conf keypairs, skiping graph generation.") + return None + + if apid.get("api_url") is None: + apid['api_url'] = "http://127.0.0.1/pandora_console/include/api.php" + #print(f"api_url: {apid['api_url']}") + + return apid + else: + return None + +def parse_graph_conf(cGraph): + """Check module graph parameters """ + if cGraph : + # Parse Api config + graphd = parse_dic(cGraph) + if graphd.get("module_id") is None: + print ("Warning. no module_id defined in module_graph keypairs, skiping graph generation.") + return + + if graphd.get("interval") is None: + graphd["interval"] = 3600 + + return graphd + else: + print("Warning. no module_graph keypairs defined, skiping graph generation") + return None + +def get_graph_by_moduleid (baseUrl,pUser, pPass, apiPass, moduleId, graphInterval, sep="url_encode_separator_%7C") : + """Call Pandorafms api to get graph""" + + try: + url = f"{baseUrl}?op=get&op2=module_graph&id={moduleId}&other={graphInterval}%7C1&other_mode={sep}&apipass={apiPass}&api=1&user={pUser}&pass={pPass}" + graph = requests.get(url) + if graph.status_code != 200: + print (f"Error requested api url, status code: {graph.status_code}. Skiping graph generation") + return None + if graph.text == "auth error": + print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + return None + if graph.text == "Id does not exist in database.": + print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + return None + if graph.text == "The user has not enough permissions for perform this action.": + print (f"Error requested Pandora api url, status code: {graph.text} Skiping graph generation") + return None + + except: + print("Error requested api url. Skiping graph generation") + return None + return graph def send(mssg, chatId, token): url = f"https://api.telegram.org/bot{token}/sendMessage" headers = {'content-type': 'application/json'} - data = { "chat_id": chatId, "text": mssg } - response = requests.get(url, data=json.dumps(data), headers=headers) + try: + response = requests.get(url, data=json.dumps(data), headers=headers) + r = response.json() + print(r) + except Exception as e : + r = None + exit(f"Error requesting telegram api: {e}") - r = response.json() - print(r) +def sendMedia(mssg, chatId, token, filepath): + url = f"https://api.telegram.org/bot{token}/sendPhoto" + data = { + "chat_id": chatId, + "caption": mssg + } + try: + with open(filepath, "rb") as photog: + request = requests.post(url, data=data, files={'photo': (filepath, photog)}) + r = request.json() + except Exception as e : + r = None + print(f"Error, cant add graph file: {e}") + + if r is not None: + r = request.json() + print(r) + +# Parse api config +filecap=None + +if args.api_conf : + api = parse_api_conf(args.api_conf) + # Parse graph config + if api is not None: + graph_cfg = parse_graph_conf(args.module_graph) + + ## Generate graph + if graph_cfg is not None : + graph = get_graph_by_moduleid (api["api_url"],api["user"], api["pass"], api["api_pass"], graph_cfg["module_id"], graph_cfg["interval"]) + if graph is not None: + try: + filename = f"{args.tmp_dir}/graph_{graph_cfg['module_id']}.{datetime.now().strftime('%s')}.png" + with open(filename, "wb") as f: + f.write(b64decode(graph.text)) + f.close + print (f"Graph generated on temporary file {filename}", file=sys.stderr) + except Exception as e : + print(f"Error, cant generate graph file: {e}", file=sys.stderr) + filename = None + else: filename = None + + if filename is not None: + filecap=f"graph_{graph_cfg['module_id']}.{datetime.now().strftime('%s')}.png" + +# Send message send(mssg=args.message, chatId=args.chat_id, token=args.token) + +if filecap is not None: + sendMedia(mssg='', chatId=args.chat_id, token=args.token, filepath=filename) + try: + os.remove(filename) + except Exception as e: + exit('Error: {e}') \ No newline at end of file diff --git a/pandora_plugins/message_app_connectors/telegram-bot-cli/test_exec.txt b/pandora_plugins/message_app_connectors/telegram-bot-cli/test_exec.txt index 86844d04c2..c108b7a684 100644 --- a/pandora_plugins/message_app_connectors/telegram-bot-cli/test_exec.txt +++ b/pandora_plugins/message_app_connectors/telegram-bot-cli/test_exec.txt @@ -4,3 +4,6 @@ python3 pandora-telegram-cli.py -t 1412764845:AAG-OxOKISOXwhITLFFNm6oq5YD2KI72fT # Pandora FMS command definition example python3 pandora-telegram-cli.py -t _field1_ -c _field2_ -m" _field3_" + +# New +python3 pandora-telegram-cli.py -m 'test message for telegram new bot script' -t 1874294647:AAHRBk4YDf1QZXh_WuZ8m7ONrAQoKbTW6eQ -c -261593656 --api_conf "user=admin,pass=pandora,api_pass=pandora,api_url=http://192.168.80.44:8080/pandora_console/include/api.php" --module_graph "module_id=402, interval=3600" --tmp_dir /tmp diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 2c752faabc..dedb157964 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.755-210714 +Version: 7.0NG.756-210901 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 ce7fcc50e0..37d7d302e9 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.755-210714" +pandora_version="7.0NG.756-210901" package_cpan=0 package_pandora=1 diff --git a/pandora_server/FreeBSD/pandora_server b/pandora_server/FreeBSD/pandora_server index 491a57d062..c0cea74859 100755 --- a/pandora_server/FreeBSD/pandora_server +++ b/pandora_server/FreeBSD/pandora_server @@ -1,8 +1,8 @@ #!/bin/sh # ********************************************************************** -# Pandora FMS Server Daemon launcher for FreeBSD -# (c) 2010 Junichi Satoh +# Pandora FMS Server Daemon launcher through pandora_ha for FreeBSD +# (c) 2010-2021 Junichi Satoh # (c) 2014 Koichiro Kikuchi # # ********************************************************************** @@ -13,63 +13,53 @@ # Add the following lines to /etc/rc.conf to enable pandora_server: # pandora_server_enable (bool): Set to "YES" to enable pandora_server (default: NO) -# pandora_server_profiles (str): Define your profiles here (default: "") # . "/etc/rc.subr" PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin -name="pandora_server" +name="pandora_ha" rcvar=pandora_server_enable : ${pandora_server_enable:=NO} : ${pandora_server_configfile:=/usr/local/etc/pandora/pandora_server.conf} -command=/usr/local/bin/${name} -command_args="-D" +command=/usr/local/bin/pandora_ha +command_pandora=/usr/local/bin/pandora_server command_interpreter=/usr/local/bin/perl -_pidprefix=/var/run/$name +_pidprefix=/var/run/pandora_ha +_pidprefix_pandora=/var/run/pandora_server pidfile=${_pidprefix}.pid +pidfile_pandora=${_pidprefix_pandora}.pid required_files="$pandora_server_configfile" +extra_commands="status_server start_server stop_server restart_server" + +stop_postcmd=stop_postcmd + +status_server_cmd=control_pandora_server +start_server_cmd=control_pandora_server +stop_server_cmd=control_pandora_server +restart_server_cmd=control_pandora_server load_rc_config $name -if [ "$2" ]; then - profile="$2" - if [ "$pandora_server_profiles" ]; then - pidfile="${_pidprefix}.${profile}.pid" - eval pandora_server_configfile="\${pandora_server_${profile}_configfile:-}" - if [ -z "$pandora_server_configfile" ]; then - echo "You must define a configuration file (pandora_server_${profile}_configfile)" - exit 1 - fi - required_files="$pandora_server_configfile" - eval pandora_server_enable="\${pandora_server_${profile}_enable:-$pandora_server_enable}" - eval pandora_server_flags="\${pandora_server_${profile}_flags:-$pandora_server_flags}" - eval pidfile="\${pandora_server_${profile}_pidfile:-$pidfile}" - else - echo "$0: extra argument ignored" - fi -elif [ "${pandora_server_profiles}" ] && [ "$1" ]; then - for profile in ${pandora_server_profiles}; do - eval _enable="\${pandora_server_${profile}_enable}" - case "${_enable:-${pandora_server_enable}}" in - [Yy][Ee][Ss]);; - *) continue;; - esac - echo "===> pandora_server profile: ${profile}" - /usr/local/etc/rc.d/pandora_server $1 ${profile} - retcode="$?" - if [ "0${retcode}" -ne 0 ]; then - failed="${profile} (${retcode}) ${failed:-}" - else - success="${profile} ${success:-}" - fi - done - exit 0 -fi +control_pandora_server() { + local name command pidfile + name="pandora_server" + command=$command_pandora + pidfile=$pidfile_pandora + pandora_server_flags="-D $pandora_server_flags -P $pidfile_pandora $pandora_server_configfile" + pandora_arg=`echo $rc_arg | sed 's/_server//g'` + unset "${pandora_arg}_cmd" "${pandora_arg}_precmd" "${pandora_arg}_postcmd" + run_rc_command $pandora_arg +} -pandora_server_flags="$pandora_server_flags -P $pidfile $pandora_server_configfile" +stop_postcmd() +{ + rm -f $pidfile +} + +pandora_ha_flags="-d -p $pidfile $pandora_server_configfile" run_rc_command "$1" diff --git a/pandora_server/FreeBSD/tentacle_server b/pandora_server/FreeBSD/tentacle_server index a8752e2cf5..9457d1fe52 100755 --- a/pandora_server/FreeBSD/tentacle_server +++ b/pandora_server/FreeBSD/tentacle_server @@ -2,7 +2,7 @@ # ********************************************************************** # Tentacle Server Daemon launcher for FreeBSD -# (c) 2010-2012 Junichi Satoh +# (c) 2010-2021 Junichi Satoh # # ********************************************************************** @@ -21,17 +21,25 @@ name="tentacle_server" rcvar=tentacle_server_enable # read configuration and set defaults -tentacle_server_enable=${tentacle_server_enable:-"NO"} -tentacle_server_flags=${tentacle_server_flags:-'-a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf\;.*\.md5:md5\;.*\.zip:collections -d'} -tentacle_server_user=${tentacle_server_user:-"pandora"} load_rc_config $name +: ${tentacle_server_enable="NO"} +: ${tentacle_server_config="/usr/local/etc/tentacle/${name}.conf"} +: ${tentacle_server_pidfile="/var/run/${name}.pid"} PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin command=/usr/local/bin/${name} command_interpreter=/usr/local/bin/perl +tentacle_server_user=${tentacle_server_user:-"pandora"} +# +# Use tentacle_server.conf by default. +tentacle_server_flags="-F ${tentacle_server_config}" +# +# Each parameters can also be specified as arguments like this: +#tentacle_server_flags=${tentacle_server_flags:-'-a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf\;.*\.md5:md5\;.*\.zip:collections -d'} +# procname=$command -pidfile=/var/run/$name.pid +pidfile=${tentacle_server_pidfile} start_postcmd=start_postcmd stop_postcmd=stop_postcmd diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 6a45ad4ac2..6b1c36c158 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -620,15 +620,7 @@ sub main() { # Only if console_api_url was not defined if( !defined($Config{"console_api_url"}) ) { - my $console_api_url = pandora_get_tconfig_token ($DBH, 'public_url', ''); - my $include_api = 'include/api.php'; - # If public_url is empty in database - if ( $console_api_url eq '' ) { - $Config{"console_api_url"} = 'http://127.0.0.1/pandora_console/' . $include_api; - logger(\%Config, "Assuming default path for API url: " . $Config{"console_api_url"}, 3); - } else { - $Config{"console_api_url"} = $console_api_url . $include_api; - } + $Config{"console_api_url"} = get_console_api_url(\%Config, $DBH); } # Definition of configuration file @@ -689,6 +681,7 @@ sub main() { print CFG "console_pass " .$Config{"console_pass"} . "\n"; close (CFG); + } else { logger(\%Config, "[WARNING] Error with configuration file when define `console_pass`: $!", 3); } @@ -733,6 +726,7 @@ sub main() { print CFG "\n# Console User (created for API use)\n"; print CFG "console_user " . $Config{"console_user"} . "\n"; close (CFG); + } else { logger(\%Config, "Warning. Was not possible edit configuration file for add console user", 3); } @@ -749,6 +743,12 @@ sub main() { if ( $res_testing_api[0] ne 'OK' ) { logger(\%Config, "Warning! The server does not have access to the API, this can trigger problems in the generation of reports and graphs.", 1); pandora_event (\%Config, "Server does not have access to the API", 0, 0, 0, 0, 0, 'system', 0, $DBH); + } else { + # Test successful. + pandora_set_tconfig_token($DBH, 'internal_user_pass', + pandora_input_password(\%Config, $Config{"console_pass"}) + ); + pandora_set_tconfig_token($DBH, 'internal_user', $Config{"console_user"}); } # Generate 'going up' events diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 64c42fe1b0..6cc743999b 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -1,7 +1,7 @@ ############################################################################# # Pandora FMS Server Parameters # Pandora FMS, the Flexible Monitoring System. -# Version 7.0NG.755 +# Version 7.0NG.756 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -692,10 +692,10 @@ syslog_max 65535 # Address # sync_address -# Pandora FMS Database HA Tool execution interval in seconds (PANDORA FMS ENTERPRISE ONLY). +# Pandora FMS Daemon Watchdog execution interval in seconds (PANDORA FMS ENTERPRISE ONLY). ha_interval 30 -# Pandora FMS Database HA Tool monitoring interval in seconds. Must be a multiple of ha_interval (PANDORA FMS ENTERPRISE ONLY). +# Pandora FMS Daemon Watchdog monitoring interval in seconds. Must be a multiple of ha_interval (PANDORA FMS ENTERPRISE ONLY). ha_monitoring_interval 60 # Enable (1) or disable (0) Pandora FMS Alert Server. diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 74134135f8..1ed807e4ac 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -39,13 +39,14 @@ our @EXPORT = qw( pandora_start_log pandora_get_sharedconfig pandora_get_tconfig_token + pandora_set_tconfig_token pandora_get_initial_product_name pandora_get_initial_copyright_notice ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.755"; -my $pandora_build = "210714"; +my $pandora_version = "7.0NG.756"; +my $pandora_build = "210901"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -337,6 +338,7 @@ sub pandora_load_config { $pa_config->{"mssql_driver"} = undef; # 745 $pa_config->{"snmpconsole_lock"} = 0; # 755. $pa_config->{"snmpconsole_period"} = 0; # 755. + $pa_config->{"snmpconsole_threshold"} = 0; # 755. # Internal MTA for alerts, each server need its own config. $pa_config->{"mta_address"} = ''; # Introduced on 2.0 @@ -1369,6 +1371,31 @@ sub pandora_get_tconfig_token ($$$) { return $default_value; } +########################################################################## +# Write the given token to tconfig table. +########################################################################## +sub pandora_set_tconfig_token ($$$) { + my ($dbh, $token, $value) = @_; + + my $token_value = get_db_value ($dbh, + "SELECT `value` FROM `tconfig` WHERE `token` = ?", $token + ); + if (defined ($token_value) && $token_value ne '') { + db_update($dbh, + 'UPDATE `tconfig` SET `value`=? WHERE `token`= ?', + safe_input($value), + $token + ); + } else { + db_insert($dbh, 'id_config', + 'INSERT INTO `tconfig`(`token`, `value`) VALUES (?, ?)', + $token, + safe_input($value) + ); + } + +} + ########################################################################## # Get the product name in previous tasks to read from database. ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index b24d6696a1..6f4e16e9fe 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1424,11 +1424,11 @@ sub pandora_execute_action ($$$$$$$$$;$) { my $threshold = shift; my $period = $hours * 3600; # Hours to seconds if($threshold == 0){ - $params->{"other"} = $period . '%7C1%7C0%7C225'; + $params->{"other"} = $period . '%7C1%7C0%7C225%7C""%7C14'; $cid = 'module_graph_' . $hours . 'h'; } else{ - $params->{"other"} = $period . '%7C1%7C1%7C225'; + $params->{"other"} = $period . '%7C1%7C1%7C225%7C""%7C14'; $cid = 'module_graphth_' . $hours . 'h'; } @@ -1651,7 +1651,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field20 = subst_alert_macros ($field20, \%macros, $pa_config, $dbh, $agent, $module, $alert); # Field 1 (Integria IMS API path) - my $api_path = $config_api_path . "/integria/include/api.php"; + my $api_path = $config_api_path . "/include/api.php"; # Field 2 (Integria IMS API pass) my $api_pass = $config_api_pass; @@ -3683,7 +3683,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status); # Do not write to the event file return $event_id if ($pa_config->{'event_file'} eq ''); @@ -3983,13 +3983,66 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { $alert_data .= " Custom: $trap_custom_oid"; } - # Assign default values to the _snmp_fx_ macros from variable bindings + # Parse variables data. + my @custom_values = split("\t", $trap_custom_oid); + + # Evaluate variable filters + my $filter_match = 1; + for (my $i = 1; $i <= 20; $i++) { + my $order_field = $alert->{'order_'.$i} - 1; + + # Only values greater than 0 allowed. + next if $order_field < 0; + + my $filter_name = '_snmp_f' . $i . '_'; + my $filter_regex = safe_output ($alert->{$filter_name}); + my $field_value = $custom_values[$order_field]; + + # No filter for the current binding var + next if ($filter_regex eq ''); + + # The referenced binding var does not exist + if (! defined ($field_value)) { + $filter_match = 0; + last; + } + + # Evaluate the filter + eval { + local $SIG{__DIE__}; + if ($field_value !~ m/$filter_regex/) { + $filter_match = 0; + } + }; + + # Probably an invalid regexp + if ($@) { + # Filter is ignored. + logger($pa_config, "Invalid regex in SNMP alert #".$alert->{'id_as'}.": [".$filter_regex."]", 3); + # Invalid regex are ignored, test next variables. + next; + } + + # The filter did not match + last if ($filter_match == 0); + } + + # A filter did not match + next if ($filter_match == 0); + + # Assign values to _snmp_fx_ macros. my $count; - my @custom_values = split ("\t", $trap_custom_oid); - for ($count = 1; defined ($custom_values[$count-1]); $count++) { - my $macro_name = '_snmp_f' . $count . '_'; - my $order_field = $alert->{'order_'.$count}; - if ($custom_values[$count] =~ m/= \S+: (.*)/) { + for ($count = 0; defined ($custom_values[$count]); $count++) { + my $macro_name = '_snmp_f' . ($count+1) . '_'; + my $target = $custom_values[$count]; + + if (!defined($target)) { + # Ignore emtpy data. + $macros{$macro_name} = ''; + next; + } + + if ($target =~ m/= \S+: (.*)/) { my $value = $1; # Strip leading and trailing double quotes @@ -4009,40 +4062,6 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { # All variables $macros{'_snmp_argv_'} = $trap_custom_oid; - - # Evaluate _snmp_fx_ filters - my $filter_match = 1; - for (my $i = 1; $i <= 10; $i++) { - my $filter_name = '_snmp_f' . $i . '_'; - my $filter_value = safe_output ($alert->{$filter_name}); - - # No filter for the current binding var - next if ($filter_value eq ''); - - # The referenced binding var does not exist - if (! defined ($macros{$filter_name})) { - $filter_match = 0; - last; - } - - # Evaluate the filter - eval { - if ($macros{$filter_name} !~ m/$filter_value/) { - $filter_match = 0; - } - }; - - # Probably an invalid regexp - if ($@) { - last; - } - - # The filter did not match - last if ($filter_match == 0); - } - - # A filter did not match - next if ($filter_match == 0); # Replace macros $alert->{'al_field1'} = subst_alert_macros ($alert->{'al_field1'}, \%macros); @@ -4702,9 +4721,9 @@ sub get_module_status ($$$) { # (-inf, warning_min), [warning_max, +inf) else { if ($warning_min == 0) { - return 1 if ($data > $warning_max); + return 2 if ($data > $warning_max); }elsif ($warning_max == 0) { - return 1 if ($data <= $warning_min); + return 2 if ($data <= $warning_min); } else { return 2 if ($data < $warning_min || $data >= $warning_max); return 2 if ($data <= $warning_max && $warning_max < $warning_min); @@ -5276,6 +5295,8 @@ sub pandora_process_policy_queue ($) { my $dbh = db_connect ($pa_config{'dbengine'}, $pa_config{'dbname'}, $pa_config{'dbhost'}, $pa_config{'dbport'}, $pa_config{'dbuser'}, $pa_config{'dbpass'}); + my $dbh_metaconsole; + logger($pa_config, "Starting policy queue patrol process.", 1); while($THRRUN == 1) { @@ -5291,6 +5312,58 @@ sub pandora_process_policy_queue ($) { my $operation = enterprise_hook('get_first_policy_queue', [$dbh]); next unless (defined ($operation) && $operation ne ''); + $pa_config->{"node_metaconsole"} = pandora_get_tconfig_token( + $dbh, 'node_metaconsole', 0 + ); + + # Only for nodes connected to a MC in centralised environment + # tsync_queue will have elements ONLY if env is centralised on MC. + if (!is_metaconsole($pa_config) + && $pa_config->{"node_metaconsole"} + ) { + + if (!defined($dbh_metaconsole)) { + $dbh_metaconsole = enterprise_hook( + 'get_metaconsole_dbh', + [$pa_config, $dbh] + ); + } + + $pa_config->{"metaconsole_node_id"} = pandora_get_tconfig_token( + $dbh, 'metaconsole_node_id', 0 + ); + + if (!defined($dbh_metaconsole)) { + logger($pa_config, + "Node has no access to metaconsole, this is required in centralised environments.", + 3 + ); + + sleep($pa_config->{'server_threshold'}); + + # Skip. + next; + } + + my $policies_updated = PandoraFMS::DB::get_db_value( + $dbh_metaconsole, + 'SELECT count(*) as N FROM `tsync_queue` WHERE `table` IN ( "tpolicies", "tpolicy_alerts", "tpolicy_alerts_actions", "tpolicy_collections", "tpolicy_modules", "tpolicy_modules_inventory", "tpolicy_plugins" ) AND `target` = ?', + $pa_config->{"metaconsole_node_id"} + ); + + if (!defined($policies_updated) || "$policies_updated" ne "0") { + $policies_updated = 'unknown' unless defined($policies_updated); + logger($pa_config, + "Policy definitions are not up to date (missing changes - $policies_updated - from MC) waiting synchronizer.", + 3 + ); + + sleep($pa_config->{'server_threshold'}); + # Skip. + next; + } + } + if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') { enterprise_hook('pandora_apply_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}, $operation->{'id'}, $operation->{'operation'}]); } @@ -5306,8 +5379,8 @@ sub pandora_process_policy_queue ($) { enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]); }}; - # Check the queue each 5 seconds - sleep(5); + # Check the queue each server_threshold seconds + sleep($pa_config->{'server_threshold'}); } @@ -6404,7 +6477,7 @@ sub pandora_sync_agents_integria ($) { my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', ''); my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', ''); - my $api_path = $config_api_path . "/integria/include/api.php"; + my $api_path = $config_api_path . "/include/api.php"; my @agents_string = ''; my @agents = get_db_rows ($dbh, 'SELECT * FROM tagente'); @@ -6452,7 +6525,7 @@ sub pandora_get_integria_ticket_types($) { my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', ''); my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', ''); - my $api_path = $config_api_path . "/integria/include/api.php"; + my $api_path = $config_api_path . "/include/api.php"; my $call_api = $api_path . '?' . 'user=' . $config_integria_user . '&' . diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 2c950c54b0..1f53cb228b 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -69,6 +69,7 @@ our @EXPORT = qw( get_alert_template_module_id get_alert_template_name get_command_id + get_console_api_url get_db_rows get_db_rows_limit get_db_single_row @@ -216,6 +217,33 @@ sub db_disconnect ($) { $dbh->disconnect(); } +######################################################################## +## Return local console API url. +######################################################################## +sub get_console_api_url ($$) { + my ($pa_config, $dbh) = @_; + + # Only if console_api_url was not defined + if( !defined($pa_config->{"console_api_url"}) ) { + my $console_api_url = PandoraFMS::Config::pandora_get_tconfig_token( + $dbh, 'public_url', '' + ); + + my $include_api = 'include/api.php'; + # If public_url is empty in database + if ( $console_api_url eq '' ) { + $pa_config->{"console_api_url"} = 'http://127.0.0.1/pandora_console/' . $include_api; + logger($pa_config, "Assuming default path for API url: " . $pa_config->{"console_api_url"}, 3); + } else { + if ($console_api_url !~ /\/$/) { + $console_api_url .= '/'; + } + $pa_config->{"console_api_url"} = $console_api_url . $include_api; + } + } + return $pa_config->{'console_api_url'}; +} + ######################################################################## ## Return action ID given the action name. ######################################################################## diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index f1c10268e6..286d5633ce 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -148,7 +148,7 @@ sub data_producer ($) { OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id); } else { @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task - WHERE (id_recon_server = ? OR id_recon_server = ANY(SELECT id_server FROM tserver WHERE status = 0 AND server_type = ?)) + WHERE (id_recon_server = ? OR id_recon_server = ANY(SELECT id_server FROM tserver WHERE status <> 1 AND server_type = ?)) AND disabled = 0 AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1) OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id, DISCOVERYSERVER); diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index be8a96a9f9..f33df804f9 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -112,7 +112,7 @@ sub data_producer ($) { } else { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.last_execution_try, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado - WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status = 0 AND server_type = ?))) + WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?))) AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index a6b4d68ecd..6720126518 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -110,7 +110,7 @@ sub data_producer ($) { } else { @rows = get_db_rows ($dbh, 'SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado - WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status = 0 AND server_type = ?))) + WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?))) AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 2747753e19..fc499c17d4 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,8 +33,8 @@ use base 'Exporter'; our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.755"; -my $pandora_build = "210714"; +my $pandora_version = "7.0NG.756"; +my $pandora_build = "210901"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 5cd5cbe2cf..f7c557128d 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -115,7 +115,7 @@ sub data_producer ($) { WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver - WHERE status = 0 AND server_type = ?)) + WHERE status <> 1 AND server_type = ?)) OR ((server_name = 0 OR server_name IS NULL) AND 1=?) ) AND tagente_modulo.id_agente = tagente.id_agente diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index c8a8759bd8..3f65ee76ba 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -109,7 +109,7 @@ sub data_producer ($) { } else { @rows = get_db_rows ($dbh, 'SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado, tserver - WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status = 0 AND server_type = ?))) + WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?))) AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 diff --git a/pandora_server/lib/PandoraFMS/WebServer.pm b/pandora_server/lib/PandoraFMS/WebServer.pm index b900c21fb9..7906b22691 100644 --- a/pandora_server/lib/PandoraFMS/WebServer.pm +++ b/pandora_server/lib/PandoraFMS/WebServer.pm @@ -135,7 +135,7 @@ sub data_producer ($) { } else { @rows = get_db_rows ($dbh, 'SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado, tserver - WHERE ((server_name = ?) OR (server_name = ANY(SELECT server_name FROM tserver WHERE status = 0 AND server_type = ?))) + WHERE ((server_name = ?) OR (server_name = ANY(SELECT server_name FROM tserver WHERE status <> 1 AND server_type = ?))) AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 4dfc0392ae..e58804116e 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.755 -%define release 210714 +%define version 7.0NG.756 +%define release 210901 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 39f232bab5..22ec73e204 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.755 -%define release 210714 +%define version 7.0NG.756 +%define release 210901 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index a92a5177cb..0fe2ae1c66 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -8,8 +8,8 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.755" -PI_BUILD="210714" +PI_VERSION="7.0NG.756" +PI_BUILD="210901" MODE=$1 if [ $# -gt 1 ]; then @@ -407,6 +407,11 @@ install () { mv ${sh_script}.new $sh_script chmod a+x $sh_script done + # install pandora_ha + INSTALL_DIR="$DESTDIR$PREFIX/bin/" + echo ">Installing the pandora_ha binary to $INSTALL_DIR..." + cp -f $DESTDIR$PANDORA_HOME/util/pandora_ha.pl "$INSTALL_DIR/pandora_ha" + chmod +x "$INSTALL_DIR/pandora_ha" ;; *) SYSTEMD_DIR=$DESTDIR/etc/systemd/system @@ -422,7 +427,7 @@ install () { [ -d "$SYSTEMD_DIR" ] || mkdir -p "$SYSTEMD_DIR" cat > $SYSTEMD_DIR/pandora_ha.service <<-EOF [Unit] -Description=Pandora FMS Database HA Tool +Description=Pandora FMS Daemon Watchdog [Service] Type=forking diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 4700cad136..9ba4d5ab15 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.755 Build 210714"; +my $version = "7.0NG.756 Build 210901"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index ffe4dea01f..ac8774972c 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl ############################################################################### -# Pandora FMS Database HA +# Pandora FMS Daemon Watchdog ############################################################################### # Copyright (c) 2018-2021 Artica Soluciones Tecnologicas S.L ############################################################################### @@ -12,7 +12,6 @@ use Getopt::Std; use POSIX qw(setsid strftime :sys_wait_h); use threads; use threads::shared; -use Storable; use File::Path qw(rmtree); # Default lib dir for Pandora FMS RPM and DEB packages. @@ -106,7 +105,7 @@ sub ha_daemonize($) { sub ha_init_pandora($) { my $conf = shift; - log_message($conf, '', "\nPandora FMS Database HA Tool " . $PandoraFMS::Tools::VERSION . " Copyright (c) Artica ST\n"); + log_message($conf, '', "\nPandora FMS Daemon Watchdog " . $PandoraFMS::Tools::VERSION . " Copyright (c) Artica ST\n"); getopts('dp:', \%Opts); @@ -160,6 +159,8 @@ sub help_screen { ############################################################################## sub ha_keep_pandora_running($$) { my ($conf, $dbh) = @_; + my $OSNAME = $^O; + my $control_command; $conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); @@ -170,8 +171,9 @@ sub ha_keep_pandora_running($$) { 'SELECT count(*) AS "delayed" FROM tserver WHERE ((status = -1) OR ( (unix_timestamp() - unix_timestamp(keepalive)) > (server_keepalive+1) AND status != 0 )) - AND server_type != ? AND name = ?', + AND server_type NOT IN (?, ?) AND name = ?', PandoraFMS::Tools::SATELLITESERVER, + PandoraFMS::Tools::MFSERVER, $conf->{'servername'} ); @@ -180,18 +182,30 @@ sub ha_keep_pandora_running($$) { $Pandora_Service = $conf->{'pandora_service_cmd'}; # Check if service is running - my $pid = `$Pandora_Service status-server | awk '{print \$NF*1}' | tr -d '\.'`; + $control_command = "status-server"; + if ($OSNAME eq "freebsd") { + $control_command = "status_server"; + } + my $pid = `$Pandora_Service $control_command | awk '{print \$NF*1}' | tr -d '\.'`; if ( ($pid > 0) && ($component_last_contact > 0)) { # service running but not all components log_message($conf, 'LOG', 'Pandora service running but not all components.'); print ">> service running but delayed...\n"; - `$Pandora_Service restart-server 2>/dev/null`; + $control_command = "restart-server"; + if ($OSNAME eq "freebsd") { + $control_command = "restart_server"; + } + `$Pandora_Service $control_command 2>/dev/null`; } elsif ($pid == 0) { # service not running log_message($conf, 'LOG', 'Pandora service not running.'); print ">> service not running...\n"; - `$Pandora_Service start-server 2>/dev/null`; + $control_command = "start-server"; + if ($OSNAME eq "freebsd") { + $control_command = "start_server"; + } + `$Pandora_Service $control_command 2>/dev/null`; } elsif ($pid > 0 && $nservers == 0 ) { @@ -203,7 +217,11 @@ sub ha_keep_pandora_running($$) { log_message($conf, 'LOG', 'Pandora service running without servers ['.$nservers.'].'); if ($nservers >= 0) { log_message($conf, 'LOG', 'Restarting Pandora service...'); - `$Pandora_Service restart-serer 2>/dev/null`; + $control_command = "restart-server"; + if ($OSNAME eq "freebsd") { + $control_command = "restart_server"; + } + `$Pandora_Service $control_command 2>/dev/null`; } } } @@ -213,6 +231,7 @@ sub ha_keep_pandora_running($$) { ############################################################################### sub ha_update_server($$) { my ($config, $dbh) = @_; + my $OSNAME = $^O; my $repoServer = pandora_get_tconfig_token( $dbh, 'remote_config', '/var/spool/pandora/data_in' @@ -251,8 +270,11 @@ sub ha_update_server($$) { # Restart service $config->{'pandora_service_cmd'} = 'service pandora_server' unless defined($config->{'pandora_service_cmd'}); - - `$config->{'pandora_service_cmd'} restart-server 2>/dev/null`; + my $control_command = "restart-server"; + if ($OSNAME eq "freebsd") { + $control_command = "restart_server"; + } + `$config->{'pandora_service_cmd'} $control_command 2>/dev/null`; `touch "$lockFile"`; # After apply update, permission over files are changed, allow group to @@ -336,7 +358,10 @@ sub ha_main($) { # Exit current eval. return; } - + + # Synchronize database. + enterprise_hook('pandoraha_sync_node', [$conf, $dbh]); + # Monitoring. enterprise_hook('pandoraha_monitoring', [$conf, $dbh]); @@ -357,11 +382,17 @@ sub ha_main($) { # Stop pandora server ################################################################################ sub stop { + my $OSNAME = $^O; + if ($Running == 1) { $Running = 0; # cleanup and stop pandora_server print ">> stopping server...\n"; - `$Pandora_Service stop-server 2>/dev/null`; + my $control_command = "stop-server"; + if ($OSNAME eq "freebsd") { + $control_command = "stop_server"; + } + `$Pandora_Service $control_command 2>/dev/null`; } } diff --git a/pandora_server/util/pandora_ha.service b/pandora_server/util/pandora_ha.service index d513572f27..a0324f7ad6 100644 --- a/pandora_server/util/pandora_ha.service +++ b/pandora_server/util/pandora_ha.service @@ -1,5 +1,5 @@ [Unit] -Description=Pandora FMS Database HA Tool +Description=Pandora FMS Daemon Watchdog [Service] Type=forking diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index d08b95c4d1..c33687b3b0 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.755 Build 210714"; +my $version = "7.0NG.756 Build 210901"; # save program name for logging my $progname = basename($0); @@ -197,7 +197,6 @@ sub help_screen{ help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system'); help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); - help_screen_line('--meta_synch_user', " [ \n\t ]", 'Synchronize metaconsole users'); print "\nEVENTS:\n\n" unless $param ne ''; help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); help_screen_line('--validate_event', " \n\t []", 'Validate events'); @@ -6053,18 +6052,6 @@ sub cli_disable_double_auth () { exit; } -############################################################################### -# Synchronize metaconsole users -# Related option: --meta_synch_user -############################################################################### -sub cli_meta_synch_user() { - my ($user_name,$server_name,$profile_mode,$group,$profiles,$create_groups) = @ARGV[2..7]; - - my $result = api_call(\%conf,'set', 'meta_synch_user', undef, undef, "$user_name|$server_name|$profile_mode|$group|$profiles|$create_groups"); - print "$result \n\n "; - -} - ############################################################################### # Enable user # Related option: --enable_user @@ -7378,10 +7365,6 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 1); cli_disable_double_auth(); } - elsif ($param eq '--meta_synch_user') { - param_check($ltotal, 6, 4); - cli_meta_synch_user(); - } elsif ($param eq '--disable_group') { param_check($ltotal, 1); cli_disable_group(); diff --git a/visual_console_client/src/Item.ts b/visual_console_client/src/Item.ts index 29a241dea2..322fc57263 100644 --- a/visual_console_client/src/Item.ts +++ b/visual_console_client/src/Item.ts @@ -64,6 +64,7 @@ export interface ItemProps extends Position, Size { aclGroupId: number | null; cacheExpiration: number | null; colorStatus: string; + cellId: number | null; } export interface ItemClickEvent { @@ -140,6 +141,7 @@ export function itemBasePropsDecoder(data: AnyObject): ItemProps | never { aclGroupId: parseIntOr(data.aclGroupId, null), cacheExpiration: parseIntOr(data.cacheExpiration, null), colorStatus: notEmptyStringOr(data.colorStatus, "#CCC"), + cellId: parseIntOr(data.cellId, null), ...sizePropsDecoder(data), // Object spread. It will merge the properties of the two objects. ...positionPropsDecoder(data) // Object spread. It will merge the properties of the two objects. }; diff --git a/visual_console_client/src/items/Line.ts b/visual_console_client/src/items/Line.ts index 2c39a3cb8b..cd58f78a93 100644 --- a/visual_console_client/src/items/Line.ts +++ b/visual_console_client/src/items/Line.ts @@ -339,6 +339,10 @@ export default class Line extends Item { } protected updateDomElement(element: HTMLElement): void { + if (element.parentElement != null) { + element.parentElement.style.cursor = "default"; + } + let { x, // Box x y, // Box y @@ -419,6 +423,7 @@ export default class Line extends Item { startCircle.style.position = "absolute"; startCircle.style.left = `${x1 - this.circleRadius}px`; startCircle.style.top = `${y1 - this.circleRadius}px`; + startCircle.style.cursor = `move`; endCircle.classList.add( "visual-console-item-line-circle", @@ -431,6 +436,7 @@ export default class Line extends Item { endCircle.style.position = "absolute"; endCircle.style.left = `${x2 - this.circleRadius}px`; endCircle.style.top = `${y2 - this.circleRadius}px`; + endCircle.style.cursor = `move`; if (element.parentElement !== null) { const circles = element.parentElement.getElementsByClassName( diff --git a/visual_console_client/src/items/Odometer.ts b/visual_console_client/src/items/Odometer.ts index a11f802b9d..159a5a1d16 100644 --- a/visual_console_client/src/items/Odometer.ts +++ b/visual_console_client/src/items/Odometer.ts @@ -115,6 +115,12 @@ export default class Odometer extends Item { "visual-console-container" ) as HTMLElement; + if (backgroundColor === null) { + backgroundColor = document.getElementById( + `visual-console-container-${this.props.cellId}` + ) as HTMLElement; + } + if (backgroundColor.style.backgroundColor == "") { backgroundColor.style.backgroundColor = "#fff"; }