Merge branch 'develop' into 'ent-6848-Varios-bugs-en-la-vista-Connected-users'
# Conflicts: # pandora_console/extensions/users_connected.php
This commit is contained in:
commit
66e4e2b173
|
@ -1 +1,11 @@
|
|||
pandora_console/attachment/agents
|
||||
.vstags
|
||||
MYMETA.json
|
||||
MYMETA.yml
|
||||
.vscode
|
||||
.vscode*
|
||||
.vstags
|
||||
**/blib
|
||||
**/PandoraFMS-Enterprise/Makefile
|
||||
**/PandoraFMS-Enterprise/pm_to_blib
|
||||
**/pandora_console/attachment/cache
|
||||
**/pandora_console/attachment/agents
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -0,0 +1,585 @@
|
|||
#!/bin/bash
|
||||
|
||||
# define variables
|
||||
PANDORA_CONSOLE=/var/www/html/pandora_console
|
||||
CONSOLE_PATH=/var/www/html/pandora_console
|
||||
PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
|
||||
PANDORA_SERVER_BIN=/usr/bin/pandora_server
|
||||
PANDORA_HA_BIN=/usr/bin/pandora_ha
|
||||
PANDORA_TABLES_MIN=160
|
||||
DBHOST=127.0.0.1
|
||||
DBNAME=pandora
|
||||
DBUSER=pandora
|
||||
DBPASS=pandora
|
||||
DBPORT=3306
|
||||
S_VERSION='2021012801'
|
||||
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
|
||||
|
||||
# Ansi color code variables
|
||||
red="\e[0;91m"
|
||||
green="\e[0;92m"
|
||||
bold="\e[1m"
|
||||
cyan="\e[0;36m"
|
||||
reset="\e[0m"
|
||||
|
||||
# Functions
|
||||
|
||||
execute_cmd () {
|
||||
local cmd="$1"
|
||||
local msg="$2"
|
||||
|
||||
echo -e "${cyan}$msg...${reset}"
|
||||
$cmd &>> $LOGFILE
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
[ "$3" ] && echo "$3"
|
||||
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
|
||||
rm -rf $HOME/pandora_deploy_tmp &>> $LOGFILE
|
||||
exit 1
|
||||
else
|
||||
echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_cmd_status () {
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
[ "$1" ] && echo "$1"
|
||||
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
|
||||
rm -rf $HOME/pandora_deploy_tmp/*.rpm* &>> $LOGFILE
|
||||
exit 1
|
||||
else
|
||||
echo -e "${green}OK${reset}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_pre_pandora () {
|
||||
export MYSQL_PWD=$DBPASS
|
||||
|
||||
echo -en "${cyan}Checking environment ... ${reset}"
|
||||
rpm -qa | grep pandora &>> /dev/null && local fail=true
|
||||
[ -d "$CONSOLE_PATH" ] && local fail=true
|
||||
[ -f /usr/bin/pandora_server ] && local fail=true
|
||||
echo "use $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true
|
||||
|
||||
[ ! $fail ]
|
||||
check_cmd_status 'Error there is a current Pandora FMS installation on this node, please remove it to execute a clean install'
|
||||
}
|
||||
|
||||
check_repo_connection () {
|
||||
execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection"
|
||||
execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo"
|
||||
execute_cmd "ping -c 2 support.artica.es" "Checking Enterprise repo"
|
||||
}
|
||||
|
||||
check_root_permissions () {
|
||||
echo -en "${cyan}Checking root account... ${reset}"
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
echo "Please use a root account or sudo for installing PandoraFMS"
|
||||
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
|
||||
exit 1
|
||||
|
||||
else
|
||||
echo -e "${green}OK${reset}"
|
||||
fi
|
||||
}
|
||||
|
||||
## Main
|
||||
echo "Starting PandoraFMS Community deployment ver. $S_VERSION"
|
||||
|
||||
# Centos Version
|
||||
if [ ! "$(grep -i centos /etc/redhat-release)" ]; then
|
||||
printf "${red}Error this is not a Centos Base system, this installer is compatible with Centos systems only${reset}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
execute_cmd "grep -i centos /etc/redhat-release" "Checking Centos" 'Error This is not a Centos Base system'
|
||||
|
||||
echo -en "${cyan}Check Centos Version...${reset}"
|
||||
[ $(sed -nr 's/VERSION_ID+=\s*"([0-9])"$/\1/p' /etc/os-release) -eq '7' ]
|
||||
check_cmd_status 'Error OS version, Centos 7 is expected'
|
||||
|
||||
# initialice logfile
|
||||
execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE"
|
||||
echo "Community installer version: $S_VERSION" >> $LOGFILE
|
||||
|
||||
# Pre checks
|
||||
# Root permisions
|
||||
check_root_permissions
|
||||
|
||||
# Pre installed pandora
|
||||
check_pre_pandora
|
||||
|
||||
# Connectivity
|
||||
check_repo_connection
|
||||
|
||||
# Systemd
|
||||
execute_cmd "systemctl status" "Cheking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env plese check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
|
||||
|
||||
# Check memomry greather or equal to 2G
|
||||
execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)'
|
||||
|
||||
# Check disk size at least 10 Gb free space
|
||||
execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)'
|
||||
|
||||
# Execute tools check
|
||||
execute_cmd "awk --version" 'Checking needed tools: awk'
|
||||
execute_cmd "grep --version" 'Checking needed tools: grep'
|
||||
execute_cmd "sed --version" 'Checking needed tools: sed'
|
||||
execute_cmd "yum --version" 'Checking needed tools: yum'
|
||||
|
||||
# Creating working directory
|
||||
rm -rf $HOME/pandora_deploy_tmp/*.rpm* &>> $LOGFILE
|
||||
mkdir $HOME/pandora_deploy_tmp &>> $LOGFILE
|
||||
execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp"
|
||||
|
||||
#Installing wget
|
||||
execute_cmd "yum install -y wget" "Installing wget"
|
||||
|
||||
#Installing extra repositiries
|
||||
extra_repos=" \
|
||||
tar \
|
||||
yum-utils \
|
||||
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
|
||||
http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
|
||||
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
|
||||
|
||||
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
|
||||
execute_cmd "yum install -y Percona-Server-server-57" "Installing Percona Server"
|
||||
|
||||
# Console dependencies
|
||||
console_dependencies=" \
|
||||
php \
|
||||
postfix \
|
||||
php-mcrypt \
|
||||
php-cli \
|
||||
php-gd \
|
||||
php-curl \
|
||||
php-session \
|
||||
php-mysqlnd \
|
||||
php-ldap \
|
||||
php-zip \
|
||||
php-zlib \
|
||||
php-fileinfo \
|
||||
php-gettext \
|
||||
php-snmp \
|
||||
php-mbstring \
|
||||
php-pecl-zip \
|
||||
php-xmlrpc \
|
||||
libxslt \
|
||||
wget \
|
||||
php-xml \
|
||||
httpd \
|
||||
mod_php \
|
||||
atk \
|
||||
avahi-libs \
|
||||
cairo \
|
||||
cups-libs \
|
||||
fribidi \
|
||||
gd \
|
||||
gdk-pixbuf2 \
|
||||
ghostscript \
|
||||
graphite2 \
|
||||
graphviz \
|
||||
gtk2 \
|
||||
harfbuzz \
|
||||
hicolor-icon-theme \
|
||||
hwdata \
|
||||
jasper-libs \
|
||||
lcms2 \
|
||||
libICE \
|
||||
libSM \
|
||||
libXaw \
|
||||
libXcomposite \
|
||||
libXcursor \
|
||||
libXdamage \
|
||||
libXext \
|
||||
libXfixes \
|
||||
libXft \
|
||||
libXi \
|
||||
libXinerama \
|
||||
libXmu \
|
||||
libXrandr \
|
||||
libXrender \
|
||||
libXt \
|
||||
libXxf86vm \
|
||||
libcroco \
|
||||
libdrm \
|
||||
libfontenc \
|
||||
libglvnd \
|
||||
libglvnd-egl \
|
||||
libglvnd-glx \
|
||||
libpciaccess \
|
||||
librsvg2 \
|
||||
libthai \
|
||||
libtool-ltdl \
|
||||
libwayland-client \
|
||||
libwayland-server \
|
||||
libxshmfence \
|
||||
mesa-libEGL \
|
||||
mesa-libGL \
|
||||
mesa-libgbm \
|
||||
mesa-libglapi \
|
||||
pango \
|
||||
pixman \
|
||||
xorg-x11-fonts-75dpi \
|
||||
xorg-x11-fonts-misc \
|
||||
poppler-data \
|
||||
php-yaml \
|
||||
http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
|
||||
execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
|
||||
|
||||
# Server dependencies
|
||||
server_dependencies=" \
|
||||
perl \
|
||||
vim \
|
||||
fping \
|
||||
perl-IO-Compress \
|
||||
nmap \
|
||||
sudo \
|
||||
perl-Time-HiRes \
|
||||
nfdump \
|
||||
net-snmp-utils \
|
||||
http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm"
|
||||
execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
|
||||
|
||||
# SDK VMware perl dependencies
|
||||
vmware_dependencies=" \
|
||||
http://firefly.artica.es/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm \
|
||||
perl-JSON \
|
||||
perl-Archive-Zip \
|
||||
openssl-devel \
|
||||
perl-Crypt-CBC \
|
||||
perl-Digest-SHA \
|
||||
http://firefly.artica.es/centos7/perl-Crypt-OpenSSL-AES-0.02-1.el7.x86_64.rpm"
|
||||
execute_cmd "yum install -y $vmware_dependencies" "Installing SDK VMware perl dependencies"
|
||||
|
||||
# Instant client Oracle
|
||||
oracle_dependencier=" \
|
||||
https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm \
|
||||
https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm"
|
||||
execute_cmd "yum install -y $vmware_dependencies" "Installing Oracle Instant client"
|
||||
|
||||
# Disabling SELINUX and firewalld
|
||||
setenforce 0
|
||||
sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
|
||||
systemctl disable firewalld --now &>> $LOGFILE
|
||||
|
||||
|
||||
#Configuring Database
|
||||
execute_cmd "systemctl start mysqld" "Starting database engine"
|
||||
export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev)
|
||||
echo """
|
||||
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Pandor4!');
|
||||
UNINSTALL PLUGIN validate_password;
|
||||
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pandora');
|
||||
""" | mysql --connect-expired-password -uroot
|
||||
|
||||
export MYSQL_PWD=$DBPASS
|
||||
echo -en "${cyan}Creating Pandora FMS database...${reset}"
|
||||
echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST
|
||||
check_cmd_status 'Error creating database pandora, is this an empty node? if you have a previus installation please contact with support.'
|
||||
|
||||
echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%' identified by \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST
|
||||
|
||||
#Generating my.cnf
|
||||
POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g")
|
||||
cat > /etc/my.cnf << EO_CONFIG_F
|
||||
[mysqld]
|
||||
datadir=/var/lib/mysql
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
user=mysql
|
||||
character-set-server=utf8
|
||||
skip-character-set-client-handshake
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
||||
# Mysql optimizations for Pandora FMS
|
||||
# Please check the documentation in http://pandorafms.com for better results
|
||||
|
||||
max_allowed_packet = 64M
|
||||
innodb_buffer_pool_size = $POOL_SIZE
|
||||
innodb_lock_wait_timeout = 90
|
||||
innodb_file_per_table
|
||||
innodb_flush_log_at_trx_commit = 0
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 16M
|
||||
innodb_io_capacity = 100
|
||||
thread_cache_size = 8
|
||||
thread_stack = 256K
|
||||
max_connections = 100
|
||||
|
||||
key_buffer_size=4M
|
||||
read_buffer_size=128K
|
||||
read_rnd_buffer_size=128K
|
||||
sort_buffer_size=128K
|
||||
join_buffer_size=4M
|
||||
|
||||
query_cache_type = 1
|
||||
query_cache_size = 64M
|
||||
query_cache_min_res_unit = 2k
|
||||
query_cache_limit = 256K
|
||||
|
||||
sql_mode=""
|
||||
|
||||
[mysqld_safe]
|
||||
log-error=/var/log/mysqld.log
|
||||
pid-file=/var/run/mysqld/mysqld.pid
|
||||
|
||||
EO_CONFIG_F
|
||||
|
||||
execute_cmd "systemctl restart mysqld" "Configuring database engine"
|
||||
|
||||
# Downloading Pandora Packages
|
||||
execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" "Downloading Pandora FMS Server community"
|
||||
execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" "Downloading Pandora FMS Console community"
|
||||
execute_cmd "wget http://firefly.artica.es/centos7/pandorafms_agent_unix-7.0NG.751_x86_64.rpm" "Downloading Pandora FMS Agent community"
|
||||
|
||||
# Install Pandora
|
||||
execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages"
|
||||
|
||||
# Copy gotty utility
|
||||
execute_cmd "wget https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
|
||||
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
|
||||
|
||||
# Enable Services
|
||||
execute_cmd "systemctl enable mysqld --now" "Enabling Database service"
|
||||
execute_cmd "systemctl enable httpd --now" "Enabling HTTPD service"
|
||||
|
||||
# Populate Database
|
||||
echo -en "${cyan}Loading pandoradb.sql to $DBNAME database...${reset}"
|
||||
mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb.sql &>> $LOGFILE
|
||||
check_cmd_status 'Error Loading database schema'
|
||||
|
||||
echo -en "${cyan}Loading pandoradb_data.sql to $DBNAME database...${reset}"
|
||||
mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb_data.sql &>> $LOGFILE
|
||||
check_cmd_status 'Error Loading database schema data'
|
||||
|
||||
# Configure console
|
||||
cat > $CONSOLE_PATH/include/config.php << EO_CONFIG_F
|
||||
<?php
|
||||
\$config["dbtype"] = "mysql";
|
||||
\$config["dbname"]="$DBNAME";
|
||||
\$config["dbuser"]="$DBUSER";
|
||||
\$config["dbpass"]="$DBPASS";
|
||||
\$config["dbhost"]="localhost";
|
||||
\$config["homedir"]="$PANDORA_CONSOLE";
|
||||
\$config["homeurl"]="/pandora_console";
|
||||
error_reporting(0);
|
||||
\$ownDir = dirname(__FILE__) . '/';
|
||||
include (\$ownDir . "config_process.php");
|
||||
|
||||
EO_CONFIG_F
|
||||
|
||||
cat > /etc/httpd/conf.d/pandora.conf << EO_CONFIG_F
|
||||
<Directory "/var/www/html">
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
EO_CONFIG_F
|
||||
|
||||
# Add ws proxy options to apache.
|
||||
cat >> /etc/httpd/conf.modules.d/00-proxy.conf << 'EO_HTTPD_MOD'
|
||||
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
|
||||
|
||||
EO_HTTPD_MOD
|
||||
|
||||
cat >> /etc/httpd/conf.d/wstunnel.conf << 'EO_HTTPD_WSTUNNEL'
|
||||
ProxyRequests Off
|
||||
<Proxy *>
|
||||
Require all granted
|
||||
</Proxy>
|
||||
|
||||
ProxyPass /ws ws://127.0.0.1:8080
|
||||
ProxyPassReverse /ws ws://127.0.0.1:8080
|
||||
|
||||
EO_HTTPD_WSTUNNEL
|
||||
|
||||
# Temporal quitar htaccess
|
||||
sed -i -e "s/php_flag engine off//g" $PANDORA_CONSOLE/images/.htaccess
|
||||
sed -i -e "s/php_flag engine off//g" $PANDORA_CONSOLE/attachment/.htaccess
|
||||
|
||||
# Fixing console permissions
|
||||
chmod 600 $CONSOLE_PATH/include/config.php
|
||||
chown apache. $CONSOLE_PATH/include/config.php
|
||||
mv $CONSOLE_PATH/install.php $CONSOLE_PATH/install.done
|
||||
|
||||
# Prepare php.ini
|
||||
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 = 500M/g" /etc/php.ini
|
||||
|
||||
cat > /var/www/html/index.html << EOF_INDEX
|
||||
<meta HTTP-EQUIV="REFRESH" content="0; url=/pandora_console/">
|
||||
EOF_INDEX
|
||||
|
||||
execute_cmd "systemctl restart httpd" "Restarting httpd after configuration"
|
||||
|
||||
# prepare snmptrapd
|
||||
cat > /etc/snmp/snmptrapd.conf << EOF
|
||||
authCommunity log public
|
||||
disableAuthorization yes
|
||||
EOF
|
||||
|
||||
# Prepare Server conf
|
||||
sed -i -e "s/^dbhost.*/dbhost $DBHOST/g" $PANDORA_SERVER_CONF
|
||||
sed -i -e "s/^dbname.*/dbname $DBNAME/g" $PANDORA_SERVER_CONF
|
||||
sed -i -e "s/^dbuser.*/dbuser $DBUSER/g" $PANDORA_SERVER_CONF
|
||||
sed -i -e "s|^dbpass.*|dbpass $DBPASS|g" $PANDORA_SERVER_CONF
|
||||
sed -i -e "s/^dbport.*/dbport $DBPORT/g" $PANDORA_SERVER_CONF
|
||||
|
||||
# Set Oracle environment for pandora_server
|
||||
cat > /etc/pandora/pandora_server.env << 'EOF_ENV'
|
||||
#!/bin/bash
|
||||
VERSION=19.8
|
||||
export PATH=$PATH:$HOME/bin:/usr/lib/oracle/$VERSION/client64/bin
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/$VERSION/client64/lib
|
||||
export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64
|
||||
EOF_ENV
|
||||
|
||||
# Kernel optimization
|
||||
cat >> /etc/sysctl.conf <<EO_KO
|
||||
# Pandora FMS Optimization
|
||||
|
||||
# default=5
|
||||
net.ipv4.tcp_syn_retries = 3
|
||||
|
||||
# default=5
|
||||
net.ipv4.tcp_synack_retries = 3
|
||||
|
||||
# default=1024
|
||||
net.ipv4.tcp_max_syn_backlog = 65536
|
||||
|
||||
# default=124928
|
||||
net.core.wmem_max = 8388608
|
||||
|
||||
# default=131071
|
||||
net.core.rmem_max = 8388608
|
||||
|
||||
# default = 128
|
||||
net.core.somaxconn = 1024
|
||||
|
||||
# default = 20480
|
||||
net.core.optmem_max = 81920
|
||||
|
||||
EO_KO
|
||||
|
||||
execute_cmd "sysctl --system" "Applying Kernel optimization"
|
||||
|
||||
# Fix pandora_server.{log,error} permissions to allow Console check them
|
||||
chown pandora:apache /var/log/pandora
|
||||
chmod g+s /var/log/pandora
|
||||
|
||||
cat > /etc/logrotate.d/pandora_server <<EO_LR
|
||||
/var/log/pandora/pandora_server.log
|
||||
/var/log/pandora/web_socket.log
|
||||
/var/log/pandora/pandora_server.error {
|
||||
su root apache
|
||||
weekly
|
||||
missingok
|
||||
size 300000
|
||||
rotate 3
|
||||
maxage 90
|
||||
compress
|
||||
notifempty
|
||||
copytruncate
|
||||
create 660 pandora apache
|
||||
}
|
||||
|
||||
/var/log/pandora/pandora_snmptrap.log {
|
||||
su root apache
|
||||
weekly
|
||||
missingok
|
||||
size 500000
|
||||
rotate 1
|
||||
maxage 30
|
||||
notifempty
|
||||
copytruncate
|
||||
create 660 pandora apache
|
||||
}
|
||||
|
||||
EO_LR
|
||||
|
||||
cat > /etc/logrotate.d/pandora_agent <<EO_LRA
|
||||
/var/log/pandora/pandora_agent.log {
|
||||
su root apache
|
||||
weekly
|
||||
missingok
|
||||
size 300000
|
||||
rotate 3
|
||||
maxage 90
|
||||
compress
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
|
||||
EO_LRA
|
||||
|
||||
chmod 0644 /etc/logrotate.d/pandora_server
|
||||
chmod 0644 /etc/logrotate.d/pandora_agent
|
||||
|
||||
# Add websocket engine start script.
|
||||
mv /var/www/html/pandora_console/pandora_websocket_engine /etc/init.d/
|
||||
chmod +x /etc/init.d/pandora_websocket_engine
|
||||
|
||||
# Start Websocket engine
|
||||
/etc/init.d/pandora_websocket_engine start &>> $LOGFILE
|
||||
|
||||
# Configure websocket to be started at start.
|
||||
systemctl enable pandora_websocket_engine &>> $LOGFILE
|
||||
|
||||
# Enable pandora ha service
|
||||
systemctl enable pandora_server --now &>> $LOGFILE
|
||||
execute_cmd "systemctl start pandora_server" "Starting Pandora FMS Server"
|
||||
|
||||
# starting tentacle server
|
||||
systemctl enable tentacle_serverd &>> $LOGFILE
|
||||
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
||||
|
||||
# Enabling condole cron
|
||||
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
||||
echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
||||
## Enabling agent
|
||||
systemctl enable pandora_agent_daemon &>> $LOGFILE
|
||||
execute_cmd "systemctl start pandora_agent_daemon" "starting Pandora FMS Agent"
|
||||
|
||||
#SSH banner
|
||||
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)
|
||||
|
||||
cat > /etc/issue.net << EOF_banner
|
||||
|
||||
Welcome to Pandora FMS appliance on CentOS
|
||||
------------------------------------------
|
||||
Go to Public http://$ipplublic/pandora_console$to to login web console
|
||||
$(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}')
|
||||
|
||||
You can find more information at http://pandorafms.com
|
||||
|
||||
EOF_banner
|
||||
|
||||
rm -f /etc/issue
|
||||
ln -s /etc/issue.net /etc/issue
|
||||
|
||||
echo 'Banner /etc/issue.net' >> /etc/ssh/sshd_config
|
||||
|
||||
# Remove temporary files
|
||||
execute_cmd "echo done" "Pandora FMS Community installed"
|
||||
cd
|
||||
execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files"
|
||||
|
||||
# Print nice finish message
|
||||
GREEN='\033[01;32m'
|
||||
NONE='\033[0m'
|
||||
printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server"
|
||||
ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use this credentials to login in the console "g"[ User: admin / Password: pandora ]"n" \n"}'
|
|
@ -9,7 +9,7 @@ RUN dnf install -y --setopt=tsflags=nodocs \
|
|||
http://rpms.remirepo.net/enterprise/remi-release-8.rpm
|
||||
|
||||
RUN dnf module reset -y php && dnf module install -y php:remi-7.3
|
||||
RUN dnf config-manager --set-enabled PowerTools
|
||||
RUN dnf config-manager --set-enabled powertools
|
||||
|
||||
# Install console
|
||||
RUN dnf install -y --setopt=tsflags=nodocs \
|
||||
|
@ -88,7 +88,7 @@ RUN dnf install -y --setopt=tsflags=nodocs \
|
|||
xorg-x11-fonts-75dpi \
|
||||
xorg-x11-fonts-misc \
|
||||
poppler-data \
|
||||
php-yaml; yum clean all
|
||||
php-yaml
|
||||
|
||||
RUN mkdir -p /run/php-fpm/ ; chown -R root:apache /run/php-fpm/
|
||||
# not installed perl-Net-Telnet gtk-update-icon-cach ghostscript-fonts
|
||||
|
@ -242,16 +242,31 @@ RUN dnf install -y --setopt=tsflags=nodocs \
|
|||
perl-DBD-MySQL \
|
||||
perl-DBI \
|
||||
initscripts \
|
||||
vim \
|
||||
fping \
|
||||
perl-IO-Compress \
|
||||
perl-Time-HiRes \
|
||||
perl-Math-Complex \
|
||||
libnsl \
|
||||
mysql \
|
||||
java \
|
||||
net-snmp-utils \
|
||||
net-tools \
|
||||
nmap-ncat \
|
||||
nmap \
|
||||
net-snmp-utils \
|
||||
sudo \
|
||||
http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
|
||||
http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm
|
||||
http://firefly.artica.es/centos8/wmi-1.3.14-4.el7.art.x86_64.rpm
|
||||
|
||||
# install utils
|
||||
RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
|
||||
# SDK VMware perl dependencies
|
||||
RUN dnf install -y http://firefly.artica.es/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm http://firefly.artica.es/centos8/perl-Crypt-SSLeay-0.73_07-1.gf.el8.x86_64.rpm perl-Net-HTTP perl-libwww-perl openssl-devel perl-Crypt-CBC perl-Bytes-Random-Secure perl-Crypt-Random-Seed perl-Math-Random-ISAAC perl-JSON http://firefly.artica.es/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm
|
||||
# Instant client Oracle
|
||||
RUN dnf install -y https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm
|
||||
|
||||
RUN dnf install -y supervisor crontabs mysql http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
|
||||
RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
|
||||
|
||||
|
||||
EXPOSE 80 443 41121 162/udp
|
||||
|
|
|
@ -64,6 +64,7 @@ wget $oconsoleurl
|
|||
wget $oserverurl
|
||||
|
||||
if [ "$BASEBUILD" == 1 ] ; then
|
||||
docker pull centos:8
|
||||
# Open Base image
|
||||
echo "building Base el8 image"
|
||||
cd $DOCKER_PATH/base
|
||||
|
@ -71,9 +72,12 @@ if [ "$BASEBUILD" == 1 ] ; then
|
|||
echo "Taging Open stack el8 latest image before upload"
|
||||
docker tag $OBASE_IMAGE:$VERSION $OBASE_IMAGE:latest
|
||||
echo -e ">>>> \n"
|
||||
else
|
||||
docker pull pandorafms/pandorafms-open-base-el8
|
||||
fi
|
||||
|
||||
if [ "$DBBUILD" == 1 ] ; then
|
||||
docker pull percona:5.7
|
||||
# Percona image
|
||||
echo "building Percona image"
|
||||
cd $OPEN/extras/docker/percona
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Pandora FMS Mail Transfer
|
||||
# This is a tool for transfering Pandora FMS data files by mail (SMTP/POP)
|
||||
##########################################################################
|
||||
# Copyright (c) 2011 Artica Soluciones Tecnologicas S.L
|
||||
# Copyright (c) 2011-2021 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -325,7 +325,7 @@ respective locations:
|
|||
root@blackbox01:/tmp/pandora/pandora_agents/linux# ./pandora_agent_installer
|
||||
--install
|
||||
|
||||
Pandora FMS Agent Installer 1.0 (c) 2007 Sancho Lerena
|
||||
Pandora FMS Agent Installer 1.0 (c) 2021 Sancho Lerena
|
||||
This program is licensed under GPL2 Terms. http://pandora.sourceforge.net
|
||||
|
||||
Checking default dir /usr/share/pandora_agent...
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, AIX version
|
||||
# Version 7.0NG.752, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#Pandora FMS- http:#pandorafms.com
|
||||
# ==================================================
|
||||
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
# Please see http:#pandorafms.org for full contribution list
|
||||
|
||||
# This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, FreeBSD Version
|
||||
# Version 7.0NG.752, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, HP-UX Version
|
||||
# Version 7.0NG.752, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, GNU/Linux
|
||||
# Version 7.0NG.752, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2010 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, GNU/Linux
|
||||
# Version 7.0NG.752, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, Solaris Version
|
||||
# Version 7.0NG.752, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2010 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.751
|
||||
|
||||
# (c) 2006-2021 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.752
|
||||
# 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2010 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.751, AIX version
|
||||
# Version 7.0NG.752, AIX version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.751
|
||||
# Version 7.0NG.752
|
||||
# FreeBSD/IPSO version
|
||||
# Licenced under GPL licence, 2003-2007 Sancho Lerena
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# **********************************************************************
|
||||
# Pandora FMS Generic IPSO/HPUX
|
||||
# (c) 2009 Artica Soluciones Tecnológicas SL
|
||||
# (c) 2009-2021 Artica Soluciones Tecnológicas SL
|
||||
# with the help of many people. Please see http://pandorafms.org
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.751, HPUX Version
|
||||
# Version 7.0NG.752, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#Pandora FMS- http:#pandorafms.com
|
||||
# ==================================================
|
||||
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
# Please see http:#pandorafms.org for full contribution list
|
||||
|
||||
# This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751
|
||||
# Version 7.0NG.752
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751
|
||||
# Version 7.0NG.752
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# **********************************************************************
|
||||
# Pandora FMS Agent Simulator (MetaAgent)
|
||||
# (c) 2009 Artica Soluciones Tecnológicas SL
|
||||
# (c) 2009-2021 Artica Soluciones Tecnológicas SL
|
||||
# with the help of many people. Please see http://pandorafms.org
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751
|
||||
# Version 7.0NG.752
|
||||
# Licensed under GPL license v2,
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.751, Solaris version
|
||||
# Version 7.0NG.752, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, AIX version
|
||||
# Version 7.0NG.752, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.751-201210
|
||||
Version: 7.0NG.752-210302
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#Pandora FMS- http:#pandorafms.com
|
||||
# ==================================================
|
||||
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
# Please see http:#pandorafms.org for full contribution list
|
||||
|
||||
# This program is free software; you can redistribute it and/or
|
||||
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.751-201210"
|
||||
pandora_version="7.0NG.752-210302"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -24,7 +24,7 @@ fi
|
|||
if [ "$#" -ge 2 ]; then
|
||||
VERSION="$2"
|
||||
else
|
||||
VERSION="7.0NG.751"
|
||||
VERSION="7.0NG.752"
|
||||
fi
|
||||
|
||||
# Path for the generated DMG file
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
<choice id="com.pandorafms.pandorafms_src" visible="false">
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src"/>
|
||||
</choice>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.751" onConclusion="none">pandorafms_src.pdk</pkg-ref>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.752" onConclusion="none">pandorafms_src.pdk</pkg-ref>
|
||||
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
|
||||
</choice>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.751" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.752" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
|
||||
<!-- <installation-check script="check()" />
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
|
||||
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
|
||||
|
||||
<key>CFBundleVersion</key> <string>7.0NG.751</string>
|
||||
<key>CFBundleGetInfoString</key> <string>7.0NG.751 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
|
||||
<key>CFBundleShortVersionString</key> <string>7.0NG.751</string>
|
||||
<key>CFBundleVersion</key> <string>7.0NG.752</string>
|
||||
<key>CFBundleGetInfoString</key> <string>7.0NG.752 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
|
||||
<key>CFBundleShortVersionString</key> <string>7.0NG.752</string>
|
||||
|
||||
<key>NSPrincipalClass</key><string>NSApplication</string>
|
||||
<key>NSMainNibFile</key><string>MainMenu</string>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, GNU/Linux
|
||||
# Version 7.0NG.752, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, FreeBSD Version
|
||||
# Version 7.0NG.752, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, HP-UX Version
|
||||
# Version 7.0NG.752, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, GNU/Linux
|
||||
# Version 7.0NG.752, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2010 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, GNU/Linux
|
||||
# Version 7.0NG.752, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, NetBSD Version
|
||||
# Version 7.0NG.752, NetBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.751, Solaris Version
|
||||
# Version 7.0NG.752, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
||||
# General Parameters
|
||||
|
|
|
@ -20,6 +20,977 @@ Version 6.0
|
|||
|
||||
=cut
|
||||
|
||||
=pod
|
||||
This section is copied from PandoraFMS::Omnishell. Do not develop anything here
|
||||
Go to Omnishell.pm to apply all fixes you need, and then copy entire library
|
||||
here to allow pandora_agent run from this single
|
||||
|
||||
=cut
|
||||
BEGIN {
|
||||
package PandoraFMS::Omnishell;
|
||||
################################################################################
|
||||
# Pandora FMS Omnishell common functions.
|
||||
#
|
||||
# (c) Fco de Borja Sánchez <fborja.sanchez@pandorafms.com>
|
||||
#
|
||||
################################################################################
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Copy;
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use lib '/usr/lib/perl5';
|
||||
|
||||
################################################################################
|
||||
# Erase blank spaces before and after the string
|
||||
################################################################################
|
||||
sub trim {
|
||||
my $string = shift;
|
||||
if (empty($string)){
|
||||
return "";
|
||||
}
|
||||
|
||||
$string =~ s/\r//g;
|
||||
|
||||
chomp($string);
|
||||
$string =~ s/^\s+//g;
|
||||
$string =~ s/\s+$//g;
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Empty
|
||||
################################################################################
|
||||
sub empty {
|
||||
my $str = shift;
|
||||
|
||||
if (!(defined($str)) ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(looks_like_number($str)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ref($str) eq "ARRAY") {
|
||||
return (($#{$str}<0)?1:0);
|
||||
}
|
||||
|
||||
if (ref($str) eq "HASH") {
|
||||
my @tmp = keys %{$str};
|
||||
return (($#tmp<0)?1:0);
|
||||
}
|
||||
|
||||
if ($str =~ /^\ *[\n\r]{0,2}\ *$/) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# initialize plugin (advanced - hashed configuration)
|
||||
################################################################################
|
||||
sub init {
|
||||
my $options = shift;
|
||||
my $conf;
|
||||
|
||||
eval {
|
||||
$conf = init_system($options);
|
||||
|
||||
if (defined($options->{lwp_enable})) {
|
||||
if (empty($options->{lwp_timeout})) {
|
||||
$options->{lwp_timeout} = 3;
|
||||
}
|
||||
|
||||
$conf->{'__system'}->{ua} = LWP::UserAgent->new((keep_alive => "10"));
|
||||
$conf->{'__system'}->{ua}->timeout($options->{lwp_timeout});
|
||||
# Enable environmental proxy settings
|
||||
$conf->{'__system'}->{ua}->env_proxy;
|
||||
# Enable in-memory cookie management
|
||||
$conf->{'__system'}->{ua}->cookie_jar( {} );
|
||||
if ( defined($options->{ssl_verify}) && ( ($options->{ssl_verify} eq "no") || (!is_enabled($options->{ssl_verify})) ) ) {
|
||||
# Disable verify host certificate (only needed for self-signed cert)
|
||||
$conf->{'__system'}->{ua}->ssl_opts( 'verify_hostname' => 0 );
|
||||
$conf->{'__system'}->{ua}->ssl_opts( 'SSL_verify_mode' => 0x00 );
|
||||
|
||||
# Disable library extra checks
|
||||
BEGIN {
|
||||
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
|
||||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if($@) {
|
||||
# Failed
|
||||
return {
|
||||
error => $@
|
||||
};
|
||||
}
|
||||
|
||||
return $conf;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# initialize plugin (basic)
|
||||
################################################################################
|
||||
sub init_system {
|
||||
my ($conf) = @_;
|
||||
|
||||
my %system;
|
||||
|
||||
if ($^O =~ /win/i ){
|
||||
$system{devnull} = "NUL";
|
||||
$system{cat} = "type";
|
||||
$system{os} = "Windows";
|
||||
$system{ps} = "tasklist";
|
||||
$system{grep} = "findstr";
|
||||
$system{echo} = "echo";
|
||||
$system{wcl} = "wc -l";
|
||||
$system{tmp} = ".\\";
|
||||
$system{cmdsep} = "\&";
|
||||
}
|
||||
else {
|
||||
$system{devnull} = "/dev/null";
|
||||
$system{cat} = "cat";
|
||||
$system{os} = "Linux";
|
||||
$system{ps} = "ps -eo pmem,pcpu,comm";
|
||||
$system{grep} = "grep";
|
||||
$system{echo} = "echo";
|
||||
$system{wcl} = "wc -l";
|
||||
$system{tmp} = "/tmp";
|
||||
$system{cmdsep} = ";";
|
||||
|
||||
if ($^O =~ /hpux/i) {
|
||||
$system{os} = "HPUX";
|
||||
$system{ps} = "ps -eo pmem,pcpu,comm";
|
||||
}
|
||||
|
||||
if ($^O =~ /solaris/i ) {
|
||||
$system{os} = "solaris";
|
||||
$system{ps} = "ps -eo pmem,pcpu,comm";
|
||||
}
|
||||
}
|
||||
|
||||
$conf->{'__system'} = \%system;
|
||||
return $conf;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Reads a file and returns entire content or undef if error.
|
||||
################################################################################
|
||||
sub read_file {
|
||||
my $path = shift;
|
||||
|
||||
my $_FILE;
|
||||
if( !open($_FILE, "<", $path) ) {
|
||||
|
||||
# failed to open, return undef
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Slurp configuration file content.
|
||||
my $content = do { local $/; <$_FILE> };
|
||||
|
||||
# Close file
|
||||
close($_FILE);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Mix hashses
|
||||
################################################################################
|
||||
sub merge_hashes {
|
||||
my $_h1 = shift;
|
||||
my $_h2 = shift;
|
||||
|
||||
if (ref($_h1) ne "HASH") {
|
||||
return \%{$_h2} if (ref($_h2) eq "HASH");
|
||||
}
|
||||
|
||||
if (ref($_h2) ne "HASH") {
|
||||
return \%{$_h1} if (ref($_h1) eq "HASH");
|
||||
}
|
||||
|
||||
if ((ref($_h1) ne "HASH") && (ref($_h2) ne "HASH")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
my %ret = (%{$_h1}, %{$_h2});
|
||||
|
||||
return \%ret;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# is Enabled
|
||||
################################################################################
|
||||
sub is_enabled {
|
||||
my $value = shift;
|
||||
|
||||
if ((defined ($value)) && looks_like_number($value) && ($value > 0)){
|
||||
# return true
|
||||
return 1;
|
||||
}
|
||||
#return false
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Parses any configuration, from file (1st arg to program) or direct arguments
|
||||
#
|
||||
# Custom evals are defined in an array reference of hash references:
|
||||
#
|
||||
# $custom_eval = [
|
||||
# {
|
||||
# 'exp' => 'regular expression to match',
|
||||
# 'target' => \&target_custom_method_to_parse_line
|
||||
# },
|
||||
# {
|
||||
# 'exp' => 'another regular expression to search',
|
||||
# 'target' => \&target_custom_method_to_parse_line2
|
||||
# },
|
||||
# ]
|
||||
#
|
||||
# Target is an user defined function wich will be invoked with following
|
||||
# arguments:
|
||||
#
|
||||
# $config : The configuration read to the point the regex matches
|
||||
# $exp : The matching regex which fires this action
|
||||
# $line : The complete line readed from the file
|
||||
# $file_pointer : A pointer to the file which is being parsed.
|
||||
# $current_entity : The current_entity (optional) when regex matches
|
||||
#
|
||||
# E.g.
|
||||
#
|
||||
# sub target_custom_method_to_parse_line {
|
||||
# my ($config, $exp, $line, $file_pointer, $current_entity) = @_;
|
||||
#
|
||||
# if ($line =~ /$exp/) {
|
||||
# $config->{'my_key'} = complex_operation_on_data($1,$2,$3);
|
||||
# }
|
||||
#
|
||||
# return $config;
|
||||
# }
|
||||
#
|
||||
################################################################################
|
||||
sub read_configuration {
|
||||
my ($config, $separator, $custom_eval) = @_;
|
||||
|
||||
if ((!empty(@ARGV)) && (-f $ARGV[0])) {
|
||||
$config = merge_hashes($config, parse_configuration(shift @ARGV, $separator, $custom_eval));
|
||||
}
|
||||
$config = merge_hashes($config, parse_arguments(\@ARGV));
|
||||
|
||||
if(is_enabled($config->{'as_agent_plugin'})) {
|
||||
$config->{'as_server_plugin'} = 0 if (empty($config->{'as_server_plugin'}));
|
||||
}
|
||||
else {
|
||||
$config->{'as_server_plugin'} = 1 if (empty($config->{'as_server_plugin'}));
|
||||
}
|
||||
|
||||
if(is_enabled($config->{'as_server_plugin'})) {
|
||||
$config->{'as_agent_plugin'} = 0 if (empty($config->{'as_agent_plugin'}));
|
||||
}
|
||||
else {
|
||||
$config->{'as_agent_plugin'} = 1 if (empty($config->{'as_agent_plugin'}));
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
my $YAML = 0;
|
||||
# Dynamic load. Avoid unwanted behaviour.
|
||||
eval {
|
||||
eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');
|
||||
};
|
||||
if ($@) {
|
||||
$YAML = 0;
|
||||
} else {
|
||||
$YAML = 1;
|
||||
}
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw();
|
||||
|
||||
# 2 to the power of 32.
|
||||
use constant POW232 => 2**32;
|
||||
|
||||
################################################################################
|
||||
# Return the MD5 checksum of the given string as a hex string.
|
||||
# Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode
|
||||
################################################################################
|
||||
my @S = (
|
||||
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
||||
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
||||
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
||||
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
|
||||
);
|
||||
my @K = (
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
|
||||
);
|
||||
sub md5 {
|
||||
my $str = shift;
|
||||
|
||||
# No input!
|
||||
if (!defined($str)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
# Note: All variables are unsigned 32 bits and wrap modulo 2^32 when
|
||||
# calculating.
|
||||
|
||||
# Initialize variables.
|
||||
my $h0 = 0x67452301;
|
||||
my $h1 = 0xEFCDAB89;
|
||||
my $h2 = 0x98BADCFE;
|
||||
my $h3 = 0x10325476;
|
||||
|
||||
# Pre-processing.
|
||||
my $msg = unpack ("B*", pack ("A*", $str));
|
||||
my $bit_len = length ($msg);
|
||||
|
||||
# Append "1" bit to message.
|
||||
$msg .= '1';
|
||||
|
||||
# Append "0" bits until message length in bits ≡ 448 (mod 512).
|
||||
$msg .= '0' while ((length ($msg) % 512) != 448);
|
||||
|
||||
# Append bit /* bit, not byte */ length of unpadded message as 64-bit
|
||||
# little-endian integer to message.
|
||||
$msg .= unpack ("B32", pack ("V", $bit_len));
|
||||
$msg .= unpack ("B32", pack ("V", ($bit_len >> 16) >> 16));
|
||||
|
||||
# Process the message in successive 512-bit chunks.
|
||||
for (my $i = 0; $i < length ($msg); $i += 512) {
|
||||
|
||||
my @w;
|
||||
my $chunk = substr ($msg, $i, 512);
|
||||
|
||||
# Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <=
|
||||
# 15.
|
||||
for (my $j = 0; $j < length ($chunk); $j += 32) {
|
||||
push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32))));
|
||||
}
|
||||
|
||||
# Initialize hash value for this chunk.
|
||||
my $a = $h0;
|
||||
my $b = $h1;
|
||||
my $c = $h2;
|
||||
my $d = $h3;
|
||||
my $f;
|
||||
my $g;
|
||||
|
||||
# Main loop.
|
||||
for (my $y = 0; $y < 64; $y++) {
|
||||
if ($y <= 15) {
|
||||
$f = $d ^ ($b & ($c ^ $d));
|
||||
$g = $y;
|
||||
}
|
||||
elsif ($y <= 31) {
|
||||
$f = $c ^ ($d & ($b ^ $c));
|
||||
$g = (5 * $y + 1) % 16;
|
||||
}
|
||||
elsif ($y <= 47) {
|
||||
$f = $b ^ $c ^ $d;
|
||||
$g = (3 * $y + 5) % 16;
|
||||
}
|
||||
else {
|
||||
$f = $c ^ ($b | (0xFFFFFFFF & (~ $d)));
|
||||
$g = (7 * $y) % 16;
|
||||
}
|
||||
|
||||
my $temp = $d;
|
||||
$d = $c;
|
||||
$c = $b;
|
||||
$b = ($b + leftrotate (($a + $f + $K[$y] + $w[$g]) % POW232, $S[$y])) % POW232;
|
||||
$a = $temp;
|
||||
}
|
||||
|
||||
# Add this chunk's hash to result so far.
|
||||
$h0 = ($h0 + $a) % POW232;
|
||||
$h1 = ($h1 + $b) % POW232;
|
||||
$h2 = ($h2 + $c) % POW232;
|
||||
$h3 = ($h3 + $d) % POW232;
|
||||
}
|
||||
|
||||
# Digest := h0 append h1 append h2 append h3 #(expressed as little-endian)
|
||||
return unpack ("H*", pack ("V", $h0)) .
|
||||
unpack ("H*", pack ("V", $h1)) .
|
||||
unpack ("H*", pack ("V", $h2)) .
|
||||
unpack ("H*", pack ("V", $h3));
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# MD5 leftrotate function. See: http://en.wikipedia.org/wiki/MD5#Pseudocode
|
||||
################################################################################
|
||||
sub leftrotate {
|
||||
my ($x, $c) = @_;
|
||||
|
||||
return (0xFFFFFFFF & ($x << $c)) | ($x >> (32 - $c));
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# return last error.
|
||||
################################################################################
|
||||
sub get_last_error {
|
||||
my ($self) = @_;
|
||||
|
||||
if (!empty($self->{'last_error'})) {
|
||||
return $self->{'last_error'};
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Update last error.
|
||||
################################################################################
|
||||
sub set_last_error {
|
||||
my ($self, $error) = @_;
|
||||
|
||||
$self->{'last_error'} = $error;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Try to load extra libraries.c
|
||||
################################################################################
|
||||
sub load_libraries {
|
||||
my $self = shift;
|
||||
|
||||
# Dynamic load. Avoid unwanted behaviour.
|
||||
eval {eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');};
|
||||
if ($@) {
|
||||
$self->set_last_error($@);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Create new omnishell handler.
|
||||
################################################################################
|
||||
sub new {
|
||||
my ($class, $args) = @_;
|
||||
|
||||
if (ref($args) ne 'HASH') {
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $system = init();
|
||||
my $self = {
|
||||
'server_ip' => 'localhost',
|
||||
'server_path' => '/var/spool/pandora/data_in',
|
||||
'server_port' => 41121,
|
||||
'transfer_mode' => 'tentacle',
|
||||
'transfer_mode_user' => 'apache',
|
||||
'transfer_timeout' => 30,
|
||||
'server_user' => 'pandora',
|
||||
'server_pwd' => '',
|
||||
'server_ssl' => '0',
|
||||
'server_opts' => '',
|
||||
'delayed_startup' => 0,
|
||||
'pandora_nice' => 10,
|
||||
'cron_mode' => 0,
|
||||
'last_error' => undef,
|
||||
%{$system},
|
||||
%{$args},
|
||||
};
|
||||
|
||||
$self->{'temporal'} =~ s/\"|\'//g;
|
||||
$self = bless($self, $class);
|
||||
$self->prepare_commands();
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Run all, output mode 'xml' will dump to STDOUT and return an array of strings
|
||||
#, any other option will return an array with all results.
|
||||
################################################################################
|
||||
sub run {
|
||||
my ($self, $output_mode) = @_;
|
||||
|
||||
my @results;
|
||||
|
||||
foreach my $ref (keys %{$self->{'commands'}}) {
|
||||
my $rs = $self->runCommand($ref, $output_mode);
|
||||
if ($rs) {
|
||||
push @results, $rs;
|
||||
}
|
||||
}
|
||||
|
||||
if ($output_mode eq 'xml') {
|
||||
print join("\n",@results);
|
||||
}
|
||||
|
||||
return \@results;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Run command, output mode 'xml' will dump to STDOUT, other will return a hash
|
||||
# with all results.
|
||||
################################################################################
|
||||
sub runCommand {
|
||||
my ($self, $ref, $output_mode) = @_;
|
||||
|
||||
if($self->load_libraries()) {
|
||||
# Functionality possible.
|
||||
my $command = $self->{'commands'}->{$ref};
|
||||
my $result = $self->evaluate_command($ref);
|
||||
if (ref($result) eq "HASH") {
|
||||
# Process command result.
|
||||
if (defined($output_mode) && $output_mode eq 'xml') {
|
||||
my $output = '';
|
||||
$output .= "<cmd_report>\n";
|
||||
$output .= " <cmd_response>\n";
|
||||
$output .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
|
||||
$output .= " <cmd_key><![CDATA[".$ref."]]></cmd_key>\n";
|
||||
$output .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
|
||||
$output .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
|
||||
$output .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
|
||||
$output .= " </cmd_response>\n";
|
||||
$output .= "</cmd_report>\n";
|
||||
|
||||
return $output;
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
$self->set_last_error('Failed to process ['.$ref.']: '.$result);
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check for remote commands defined.
|
||||
################################################################################
|
||||
sub prepare_commands {
|
||||
my ($self) = @_;
|
||||
|
||||
if ($YAML == 0) {
|
||||
$self->set_last_error('Cannot use commands without YAML dependency, please install it.');
|
||||
return;
|
||||
}
|
||||
|
||||
# Force configuration file read.
|
||||
my $commands = $self->{'commands'};
|
||||
|
||||
if (empty($commands)) {
|
||||
$self->{'commands'} = {};
|
||||
} else {
|
||||
foreach my $rcmd (keys %{$commands}) {
|
||||
$self->{'commands'}->{trim($rcmd)} = {};
|
||||
}
|
||||
}
|
||||
|
||||
# Cleanup old commands. Not registered.
|
||||
$self->cleanup_old_commands();
|
||||
|
||||
foreach my $ref (keys %{$self->{'commands'}}) {
|
||||
my $file_content;
|
||||
my $download = 0;
|
||||
my $rcmd_file = $self->{'ConfDir'}.'/commands/'.$ref.'.rcmd';
|
||||
|
||||
# Search for local .rcmd file
|
||||
if (-e $rcmd_file) {
|
||||
my $remote_md5_file = $self->{'temporal'}.'/'.$ref.'.md5';
|
||||
|
||||
$file_content = read_file($rcmd_file);
|
||||
if ($self->recv_file($ref.'.md5', $remote_md5_file) != 0) {
|
||||
# Remote file could not be retrieved, skip.
|
||||
delete $self->{'commands'}->{$ref};
|
||||
next;
|
||||
}
|
||||
|
||||
my $local_md5 = md5($file_content);
|
||||
my $remote_md5 = md5(read_file($remote_md5_file));
|
||||
|
||||
if ($local_md5 ne $remote_md5) {
|
||||
# Must be downloaded again.
|
||||
$download = 1;
|
||||
}
|
||||
} else {
|
||||
$download = 1;
|
||||
}
|
||||
|
||||
# Search for remote .rcmd file
|
||||
if ($download == 1) {
|
||||
# Download .rcmd file
|
||||
if ($self->recv_file($ref.'.rcmd') != 0) {
|
||||
# Remote file could not be retrieved, skip.
|
||||
delete $self->{'commands'}->{$ref};
|
||||
next;
|
||||
} else {
|
||||
# Success
|
||||
move($self->{'temporal'}.'/'.$ref.'.rcmd', $rcmd_file);
|
||||
}
|
||||
}
|
||||
|
||||
# Parse and prepare in memory skel.
|
||||
eval {
|
||||
$self->{'commands'}->{$ref} = YAML::Tiny->read($rcmd_file);
|
||||
};
|
||||
if ($@) {
|
||||
# Failed.
|
||||
$self->set_last_error('Failed to decode command. ' . "\n".$@);
|
||||
delete $self->{'commands'}->{$ref};
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Command report.
|
||||
################################################################################
|
||||
sub report_command {
|
||||
my ($self, $ref, $err_level) = @_;
|
||||
|
||||
# Retrieve content from .stdout and .stderr
|
||||
my $stdout_file = $self->{'temporal'}.'/'.$ref.'.stdout';
|
||||
my $stderr_file = $self->{'temporal'}.'/'.$ref.'.stderr';
|
||||
|
||||
my $return;
|
||||
eval {
|
||||
$return = {
|
||||
'error_level' => $err_level,
|
||||
'stdout' => read_file($stdout_file),
|
||||
'stderr' => read_file($stderr_file),
|
||||
};
|
||||
|
||||
$return->{'name'} = $self->{'commands'}->{$ref}->[0]->{'name'};
|
||||
};
|
||||
if ($@) {
|
||||
$self->set_last_error('Failed to report command output. ' . $@);
|
||||
}
|
||||
|
||||
# Cleanup
|
||||
unlink($stdout_file) if (-e $stdout_file);
|
||||
unlink($stderr_file) if (-e $stderr_file);
|
||||
|
||||
# Mark command as done.
|
||||
open (my $R_FILE, '> '.$self->{'ConfDir'}.'/commands/'.$ref.'.rcmd.done');
|
||||
print $R_FILE $err_level;
|
||||
close($R_FILE);
|
||||
|
||||
|
||||
$return->{'stdout'} = '' unless defined ($return->{'stdout'});
|
||||
$return->{'stderr'} = '' unless defined ($return->{'stderr'});
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Cleanup unreferenced rcmd and rcmd.done files.
|
||||
################################################################################
|
||||
sub cleanup_old_commands {
|
||||
my ($self) = @_;
|
||||
|
||||
# Cleanup old .rcmd and .rcmd.done files.
|
||||
my %registered = map { $_.'.rcmd' => 1 } keys %{$self->{'commands'}};
|
||||
if(opendir(my $dir, $self->{'ConfDir'}.'/commands/')) {
|
||||
while (my $item = readdir($dir)) {
|
||||
|
||||
# Skip other files.
|
||||
next if ($item !~ /\.rcmd$/);
|
||||
|
||||
# Clean .rcmd.done file if its command is not referenced in conf.
|
||||
if (!defined($registered{$item})) {
|
||||
if (-e $self->{'ConfDir'}.'/commands/'.$item) {
|
||||
unlink($self->{'ConfDir'}.'/commands/'.$item);
|
||||
}
|
||||
if (-e $self->{'ConfDir'}.'/commands/'.$item.'.done') {
|
||||
unlink($self->{'ConfDir'}.'/commands/'.$item.'.done');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Close dir.
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Executes a command using defined timeout.
|
||||
################################################################################
|
||||
sub execute_command_timeout {
|
||||
my ($self, $cmd, $timeout) = @_;
|
||||
|
||||
if (!defined($timeout)
|
||||
|| !looks_like_number($timeout)
|
||||
|| $timeout <= 0
|
||||
) {
|
||||
`$cmd`;
|
||||
return $?>>8;
|
||||
}
|
||||
|
||||
my $remaining_timeout = $timeout;
|
||||
|
||||
my $RET;
|
||||
my $output;
|
||||
|
||||
my $pid = open ($RET, "-|");
|
||||
if (!defined($pid)) {
|
||||
# Failed to fork.
|
||||
$self->set_last_error('[command] Failed to fork.');
|
||||
return undef;
|
||||
}
|
||||
if ($pid == 0) {
|
||||
# Child.
|
||||
my $ret;
|
||||
eval {
|
||||
local $SIG{ALRM} = sub { die "timeout\n" };
|
||||
alarm $timeout;
|
||||
`$cmd`;
|
||||
alarm 0;
|
||||
};
|
||||
|
||||
my $result = ($?>>8);
|
||||
return $result;
|
||||
|
||||
# Exit child.
|
||||
# Child finishes.
|
||||
exit;
|
||||
|
||||
} else {
|
||||
# Parent waiting.
|
||||
while( --$remaining_timeout > 0 ){
|
||||
if (wait == -1) {
|
||||
last;
|
||||
}
|
||||
# Wait child up to timeout seconds.
|
||||
sleep 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($remaining_timeout > 0) {
|
||||
# Retrieve output from child.
|
||||
$output = do { local $/; <$RET> };
|
||||
$output = $output>>8;
|
||||
}
|
||||
else {
|
||||
# Timeout expired.
|
||||
return 124;
|
||||
}
|
||||
|
||||
close($RET);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Executes a block of commands, returns error level, leaves output in
|
||||
# redirection set by $std_files. E.g:
|
||||
# $std_files = ' >> /tmp/stdout 2>> /tmp/stderr
|
||||
################################################################################
|
||||
sub execute_command_block {
|
||||
my ($self, $commands, $std_files, $timeout, $retry) = @_;
|
||||
|
||||
return 0 unless defined($commands);
|
||||
|
||||
my $retries = $retry;
|
||||
|
||||
$retries = 1 unless looks_like_number($retries) && $retries > 0;
|
||||
|
||||
my $err_level = 0;
|
||||
$std_files = '' unless defined ($std_files);
|
||||
|
||||
if (ref($commands) ne "ARRAY") {
|
||||
return 0 if $commands eq '';
|
||||
|
||||
do {
|
||||
$err_level = $self->execute_command_timeout(
|
||||
"($commands) $std_files",
|
||||
$timeout
|
||||
);
|
||||
|
||||
# Do not retry if success.
|
||||
last if looks_like_number($err_level) && $err_level == 0;
|
||||
} while ((--$retries) > 0);
|
||||
|
||||
} else {
|
||||
foreach my $comm (@{$commands}) {
|
||||
next unless defined($comm);
|
||||
$retries = $retry;
|
||||
$retries = 1 unless looks_like_number($retries) && $retries > 0;
|
||||
|
||||
do {
|
||||
$err_level = $self->execute_command_timeout(
|
||||
"($comm) $std_files",
|
||||
$timeout
|
||||
);
|
||||
|
||||
# Do not retry if success.
|
||||
$retries = 0 if looks_like_number($err_level) && $err_level == 0;
|
||||
|
||||
} while ((--$retries) > 0);
|
||||
|
||||
# Do not continue evaluating block if failed.
|
||||
last unless ($err_level == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return $err_level;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Evalate given command.
|
||||
################################################################################
|
||||
sub evaluate_command {
|
||||
my ($self, $ref) = @_;
|
||||
|
||||
# Not found.
|
||||
return "undefined command" unless defined $self->{'commands'}->{$ref};
|
||||
|
||||
# Already completed.
|
||||
return "already executed" if (-e $self->{'ConfDir'}.'/commands/'.$ref.'.rcmd.done');
|
||||
|
||||
# [0] because how library works.
|
||||
my $cmd = $self->{'commands'}->{$ref}->[0];
|
||||
|
||||
my $std_files = ' >> "'.$self->{'temporal'}.'/'.$ref.'.stdout" ';
|
||||
$std_files .= ' 2>> "'.$self->{'temporal'}.'/'.$ref.'.stderr" ';
|
||||
|
||||
# Check preconditions
|
||||
my $err_level;
|
||||
|
||||
$err_level = $self->execute_command_block(
|
||||
$cmd->{'preconditions'},
|
||||
$std_files,
|
||||
$cmd->{'timeout'}
|
||||
);
|
||||
|
||||
# Precondition not satisfied.
|
||||
return $self->report_command($ref, $err_level) unless ($err_level == 0);
|
||||
|
||||
# Main run.
|
||||
$err_level = $self->execute_command_block(
|
||||
$cmd->{'script'},
|
||||
$std_files,
|
||||
$cmd->{'timeout'}
|
||||
);
|
||||
|
||||
# Script not success.
|
||||
return $self->report_command($ref, $err_level) unless ($err_level == 0);
|
||||
|
||||
# Check postconditions
|
||||
$err_level = $self->execute_command_block(
|
||||
$cmd->{'postconditions'},
|
||||
$std_files,
|
||||
$cmd->{'timeout'}
|
||||
);
|
||||
|
||||
# Return results.
|
||||
return $self->report_command($ref, $err_level);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# File transference and imported methods
|
||||
################################################################################
|
||||
################################################################################
|
||||
## Remove any trailing / from directory names.
|
||||
################################################################################
|
||||
sub fix_directory ($) {
|
||||
my $dir = shift;
|
||||
|
||||
my $char = chop($dir);
|
||||
return $dir if ($char eq '/');
|
||||
return $dir . $char;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Receive a file from the server.
|
||||
################################################################################
|
||||
sub recv_file {
|
||||
my ($self, $file, $relative) = @_;
|
||||
my $output;
|
||||
|
||||
my $DevNull = $self->{'__system'}->{'devnull'};
|
||||
my $CmdSep = $self->{'__system'}->{'cmdsep'};
|
||||
|
||||
my $pid = fork();
|
||||
return 1 unless defined $pid;
|
||||
|
||||
# Fix remote dir to some transfer mode
|
||||
my $remote_dir = $self->{'server_path'};
|
||||
$remote_dir .= "/" . fix_directory($relative) if defined($relative);
|
||||
|
||||
if ($pid == 0) {
|
||||
# execute the transfer program by child process.
|
||||
eval {
|
||||
local $SIG{'ALRM'} = sub {die};
|
||||
alarm ($self->{'transfer_timeout'});
|
||||
if ($self->{'transfer_mode'} eq 'tentacle') {
|
||||
$output = `cd "$self->{'temporal'}"$CmdSep tentacle_client -v -g -a $self->{'server_ip'} -p $self->{'server_port'} $self->{'server_opts'} $file 2>&1 >$DevNull`
|
||||
} elsif ($self->{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $self->{'server_port'} pandora@"$self->{'server_ip'}:$self->{'server_path'}/$file" $self->{'temporal'} 2>&1 >$DevNull`;
|
||||
} elsif ($self->{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
|
||||
$output = `ftp -n $self->{'server_opts'} $self->{'server_ip'} $self->{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER $self->{'server_user'}
|
||||
quote PASS $self->{'server_pwd'}
|
||||
lcd "$self->{'temporal'}"
|
||||
cd "$self->{'server_path'}"
|
||||
get "$file"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($self->{'transfer_mode'} eq 'local') {
|
||||
$output = `cp "$remote_dir/$file" $self->{'temporal'} 2>&1 >$DevNull`;
|
||||
}
|
||||
alarm (0);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$self->set_last_error("Error retrieving file: '.$file.' File transfer command is not responding.");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Get the errorlevel
|
||||
my $rc = $? >> 8;
|
||||
if ($rc != 0) {
|
||||
$self->set_last_error("Error retrieving file: '$file' $output");
|
||||
}
|
||||
exit $rc;
|
||||
}
|
||||
|
||||
# Wait the child process termination and get the errorlevel
|
||||
waitpid ($pid, 0);
|
||||
my $rc = $? >> 8;
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -34,7 +1005,6 @@ use Sys::Syslog;
|
|||
use Time::Local;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
use PandoraFMS::Omnishell;
|
||||
|
||||
# Agent XML data
|
||||
my $Xml;
|
||||
|
@ -45,8 +1015,8 @@ my $Sem = undef;
|
|||
# Semaphore used to control the number of threads
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.751';
|
||||
use constant AGENT_BUILD => '201210';
|
||||
use constant AGENT_VERSION => '7.0NG.752';
|
||||
use constant AGENT_BUILD => '210302';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -3401,3 +4371,5 @@ This is released under the GNU Lesser General Public License.
|
|||
Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.751
|
||||
%define release 201210
|
||||
%define version 7.0NG.752
|
||||
%define release 210302
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.751
|
||||
%define release 201210
|
||||
%define version 7.0NG.752
|
||||
%define release 210302
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -62,8 +62,9 @@ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUI
|
|||
rm -Rf $RPM_BUILD_ROOT
|
||||
|
||||
%pre
|
||||
if [ "`id pandora | grep uid | wc -l`" = 0 ]
|
||||
if [ "`id pandora 2>/dev/null | grep uid | wc -l`" = 0 ]
|
||||
then
|
||||
echo "User pandora does not exist. Creating it..."
|
||||
/usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora
|
||||
fi
|
||||
|
||||
|
@ -105,10 +106,15 @@ then
|
|||
echo "Copying new version of pandora_agent_daemon service"
|
||||
cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/
|
||||
chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service
|
||||
# Enable the services on SystemD
|
||||
systemctl enable pandora_agent_daemon.service
|
||||
else
|
||||
chkconfig pandora_agent_daemon on
|
||||
# Enable the services on SystemD
|
||||
systemctl enable pandora_agent_daemon.service || chkconfig pandora_agent_daemon on
|
||||
else
|
||||
chkconfig pandora_agent_daemon on
|
||||
fi
|
||||
|
||||
if [ "$?" -gt 0 ]
|
||||
then
|
||||
echo "There was a problem configuring pandora_agent_daemon service to run on boot. Please enable it manually."
|
||||
fi
|
||||
|
||||
if [ "$1" -gt 1 ]
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.751"
|
||||
PI_BUILD="201210"
|
||||
PI_VERSION="7.0NG.752"
|
||||
PI_BUILD="210302"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2017 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.751
|
||||
|
||||
# (c) 2006-2021 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.752
|
||||
# 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2014 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns used space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2014 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns used space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2014 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2014 Sancho Lerena
|
||||
' Pandora FMS Plugin, (c) 2021 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
Option Explicit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' nettraffic.vbs
|
||||
' Pandora FMS Agent Plugin for Microsoft Windows (All platfforms)
|
||||
' (c) 2014 Sancho Lerena <slerena@artica.es>
|
||||
' (c) 2021 Sancho Lerena <slerena@artica.es>
|
||||
' Returns total bytes in network since bootup and % of network use
|
||||
' ----------------------------------------------------------------
|
||||
' usage: cscript //B nettraffic.vbs
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' windows_product_key.vbs
|
||||
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
|
||||
' (c) 2015 Sancho Lerena <slerena@artica.es>
|
||||
' (c) 2021 Sancho Lerena <slerena@artica.es>
|
||||
' This plugin extends agent inventory feature. Only enterprise version
|
||||
' ----------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
' windows_product_key.vbs
|
||||
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
|
||||
' (c) 2015 Sancho Lerena <slerena@artica.es>
|
||||
' (c) 2021 Sancho Lerena <slerena@artica.es>
|
||||
' This plugin extends agent inventory feature. Only enterprise version
|
||||
' ----------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
|
||||
' (c) 2015 Sancho Lerena <slerena@artica.es>
|
||||
' (c) 2021 Sancho Lerena <slerena@artica.es>
|
||||
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
|
||||
' This plugin extends agent inventory feature. Only enterprise version
|
||||
' --------------------------------------------------------------------------
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Class to abstract an FTP client. It uses libcurl.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Class to abstract an FTP client. It uses libcurl.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Test module to prove FTP connection.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Test module to prove FTP connection.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -3,7 +3,7 @@ AllowLanguageSelection
|
|||
{Yes}
|
||||
|
||||
AppName
|
||||
{Pandora FMS Windows Agent v7.0NG.751}
|
||||
{Pandora FMS Windows Agent v7.0NG.752}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{201210}
|
||||
{210302}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora Windows agent main file.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora cron manager for Win32.
|
||||
|
||||
Copyright (C) 2018 Artica ST.
|
||||
Copyright (c) 2018-2021 Artica ST.
|
||||
Written by Fermin Hernandez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora cron manager for Win32.
|
||||
|
||||
Copyright (C) 2018 Artica ST.
|
||||
Copyright (c) 2018-2021 Artica ST.
|
||||
Written by Fermin Hernandez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Misc utils for files.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Misc utils for files.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora agents service for Win32.
|
||||
|
||||
Copyright (C) 2016 Artica ST.
|
||||
Copyright (c) 2016-2021 Artica ST.
|
||||
Written by Ramon Novoa.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora agents service for Win32.
|
||||
|
||||
Copyright (C) 2016 Artica ST.
|
||||
Copyright (c) 2016-2021 Artica ST.
|
||||
Written by Ramon Novoa.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora data class to represent a value and a timestamp.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Pandora data class to represent a value and a timestamp.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Defines a parent class for a Pandora module.
|
||||
|
||||
Copyright (C) 2006 Artica ST.
|
||||
Copyright (c) 2006-2021 Artica ST.
|
||||
Written by Esteban Sanchez.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue