mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
Feature: tests to support older Ubuntu 14 & 16 (#46)
This commit is contained in:
parent
c129bf941f
commit
6355c13658
48
.travis.yml
48
.travis.yml
@ -3,6 +3,54 @@ language: bash
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
|
name: "Zabbix 4.0 @ Ubuntu 14 trusty, PHP default"
|
||||||
|
arch: amd64
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- sourceline: 'deb http://repo.zabbix.com/zabbix/4.0/ubuntu trusty main'
|
||||||
|
key_url: "https://repo.zabbix.com/zabbix-official-repo.key"
|
||||||
|
packages:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- grep
|
||||||
|
- sed
|
||||||
|
- gawk
|
||||||
|
- lsof
|
||||||
|
- jq
|
||||||
|
- libfcgi0ldbl
|
||||||
|
- unzip
|
||||||
|
- zabbix-agent
|
||||||
|
- zabbix-get
|
||||||
|
- php5-fpm
|
||||||
|
before_script:
|
||||||
|
- sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2
|
||||||
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
|
name: "Zabbix 4.0 @ Ubuntu 16 xenial, PHP default"
|
||||||
|
arch: amd64
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- sourceline: 'deb http://repo.zabbix.com/zabbix/4.0/ubuntu xenial main'
|
||||||
|
key_url: "https://repo.zabbix.com/zabbix-official-repo.key"
|
||||||
|
packages:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- grep
|
||||||
|
- sed
|
||||||
|
- gawk
|
||||||
|
- lsof
|
||||||
|
- jq
|
||||||
|
- libfcgi0ldbl
|
||||||
|
- unzip
|
||||||
|
- zabbix-agent
|
||||||
|
- zabbix-get
|
||||||
|
- php-fpm
|
||||||
|
before_script:
|
||||||
|
- sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: bionic
|
dist: bionic
|
||||||
name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP default"
|
name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP default"
|
||||||
|
31
README.md
31
README.md
@ -123,14 +123,25 @@ Please refer to [Wiki](https://github.com/rvalitov/zabbix-php-fpm/wiki/Installat
|
|||||||
Please refer to [Wiki](https://github.com/rvalitov/zabbix-php-fpm/wiki/Testing-and-Troubleshooting).
|
Please refer to [Wiki](https://github.com/rvalitov/zabbix-php-fpm/wiki/Testing-and-Troubleshooting).
|
||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
Should work with any version of PHP-FPM (starting with PHP 5.3.3), Zabbix 4.0.x and later.
|
|
||||||
Can work with any version of ISPConfig as long as you have a valid PHP-FPM status page configuration there.
|
|
||||||
|
|
||||||
Tested with:
|
### System requirements
|
||||||
- [Travis CI](https://travis-ci.com/rvalitov/zabbix-php-fpm)
|
|
||||||
- PHP 7.4, 7.3, 7.2, 7.1, 7.0
|
- **PHP**. Should work with any version of PHP-FPM (starting with PHP 5.3.3)
|
||||||
- Zabbix 5.0.1, 4.4.4, 4.2.5, 4.0.20, 4.0.16, 4.0.4
|
- **Zabbix** 4.0.x and later.
|
||||||
- Debian 10, 9
|
- **ISPConfig**. Can work with any version of ISPConfig as long as you have a valid PHP-FPM status page configuration there.
|
||||||
- Ubuntu 18
|
- Minimal `bash` version 4.
|
||||||
- CentOS 7
|
- **OS**
|
||||||
- ISPConfig v.3.1.14p2
|
- **Debian** 8 Jessie or newer
|
||||||
|
- **Ubuntu** 20 Focal, 18 Bionic, 16 Xenial, 14 Trusty. Other versions are supported if they are present in the [Zabbix repository](http://repo.zabbix.com/zabbix/4.0/ubuntu/dists/).
|
||||||
|
- **CentOS** 6 or newer
|
||||||
|
- **RHEL** 5 or newer
|
||||||
|
|
||||||
|
### Tested with:
|
||||||
|
|
||||||
|
- [**Travis CI**](https://travis-ci.com/rvalitov/zabbix-php-fpm)
|
||||||
|
- **PHP** 7.4, 7.3, 7.2, 7.1, 7.0
|
||||||
|
- **Zabbix** 5.0.1, 4.4.4, 4.2.5, 4.0.20, 4.0.16, 4.0.4
|
||||||
|
- **Debian** 10, 9
|
||||||
|
- **Ubuntu** 18 Bionic, 16 Xenial, 14 Trusty
|
||||||
|
- **CentOS** 7
|
||||||
|
- **ISPConfig** v.3.1.14p2
|
||||||
|
80
tests/all.sh
80
tests/all.sh
@ -7,13 +7,53 @@ MAX_POOLS=3
|
|||||||
MAX_PORTS=3
|
MAX_PORTS=3
|
||||||
MIN_PORT=9000
|
MIN_PORT=9000
|
||||||
|
|
||||||
|
function getPHPVersion() {
|
||||||
|
TEST_STRING=$1
|
||||||
|
PHP_VERSION=$(echo "$TEST_STRING" | grep -oP "(\d\.\d)")
|
||||||
|
if [[ -z "$PHP_VERSION" ]]; then
|
||||||
|
PHP_VERSION=$(echo "$TEST_STRING" | grep -oP "php(\d)" | grep -oP "(\d)")
|
||||||
|
fi
|
||||||
|
echo "$PHP_VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEtcPHPDirectory() {
|
||||||
|
LIST_OF_DIRS=(
|
||||||
|
"/etc/php/"
|
||||||
|
"/etc/php5/"
|
||||||
|
)
|
||||||
|
for PHP_TEST_DIR in "${LIST_OF_DIRS[@]}"; do
|
||||||
|
if [[ -d "$PHP_TEST_DIR" ]]; then
|
||||||
|
echo "$PHP_TEST_DIR"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRunPHPDirectory() {
|
||||||
|
LIST_OF_DIRS=(
|
||||||
|
"/run/"
|
||||||
|
"/var/run/"
|
||||||
|
)
|
||||||
|
for PHP_TEST_DIR in "${LIST_OF_DIRS[@]}"; do
|
||||||
|
RESULT_DIR=$(find "$PHP_TEST_DIR" -name 'php*-fpm.sock' -type s -exec dirname {} \; 2>/dev/null | sort | head -n1)
|
||||||
|
if [[ -d "$RESULT_DIR" ]]; then
|
||||||
|
echo "$RESULT_DIR"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
copyPool() {
|
copyPool() {
|
||||||
ORIGINAL_FILE=$1
|
ORIGINAL_FILE=$1
|
||||||
POOL_NAME=$2
|
POOL_NAME=$2
|
||||||
POOL_SOCKET=$3
|
POOL_SOCKET=$3
|
||||||
POOL_TYPE=$4
|
POOL_TYPE=$4
|
||||||
POOL_DIR=$(dirname "${ORIGINAL_FILE}")
|
POOL_DIR=$(dirname "${ORIGINAL_FILE}")
|
||||||
PHP_VERSION=$(echo "$POOL_DIR" | grep -oP "(\d\.\d)")
|
PHP_VERSION=$(getPHPVersion "$POOL_DIR")
|
||||||
|
|
||||||
NEW_POOL_FILE="$POOL_DIR/${POOL_NAME}.conf"
|
NEW_POOL_FILE="$POOL_DIR/${POOL_NAME}.conf"
|
||||||
sudo cp "$ORIGINAL_FILE" "$NEW_POOL_FILE"
|
sudo cp "$ORIGINAL_FILE" "$NEW_POOL_FILE"
|
||||||
@ -31,7 +71,11 @@ copyPool() {
|
|||||||
setupPool() {
|
setupPool() {
|
||||||
POOL_FILE=$1
|
POOL_FILE=$1
|
||||||
POOL_DIR=$(dirname "${POOL_FILE}")
|
POOL_DIR=$(dirname "${POOL_FILE}")
|
||||||
PHP_VERSION=$(echo "$POOL_DIR" | grep -oP "(\d\.\d)")
|
PHP_VERSION=$(getPHPVersion "$POOL_DIR")
|
||||||
|
|
||||||
|
PHP_RUN_DIR=$(getRunPHPDirectory)
|
||||||
|
EXIT_CODE=$?
|
||||||
|
assertEquals "Failed to find PHP run directory" "0" "$EXIT_CODE"
|
||||||
|
|
||||||
#Delete all active pools except www.conf:
|
#Delete all active pools except www.conf:
|
||||||
find "$POOL_DIR" -name '*.conf' -type f -not -name 'www.conf' -exec rm -rf {} \;
|
find "$POOL_DIR" -name '*.conf' -type f -not -name 'www.conf' -exec rm -rf {} \;
|
||||||
@ -44,7 +88,7 @@ setupPool() {
|
|||||||
#Create new socket pools
|
#Create new socket pools
|
||||||
for ((c = 1; c <= MAX_POOLS; c++)); do
|
for ((c = 1; c <= MAX_POOLS; c++)); do
|
||||||
POOL_NAME="socket$c"
|
POOL_NAME="socket$c"
|
||||||
POOL_SOCKET="/run/php/php${PHP_VERSION}-fpm-${POOL_NAME}.sock"
|
POOL_SOCKET="${PHP_RUN_DIR}php${PHP_VERSION}-fpm-${POOL_NAME}.sock"
|
||||||
copyPool "$POOL_FILE" "$POOL_NAME" "$POOL_SOCKET" "static"
|
copyPool "$POOL_FILE" "$POOL_NAME" "$POOL_SOCKET" "static"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -67,7 +111,11 @@ setupPool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupPools() {
|
setupPools() {
|
||||||
PHP_LIST=$(find /etc/php/ -name 'www.conf' -type f)
|
PHP_DIR=$(getEtcPHPDirectory)
|
||||||
|
EXIT_CODE=$?
|
||||||
|
assertEquals "Failed to find PHP directory" "0" "$EXIT_CODE"
|
||||||
|
|
||||||
|
PHP_LIST=$(find "$PHP_DIR" -name 'www.conf' -type f)
|
||||||
while IFS= read -r pool; do
|
while IFS= read -r pool; do
|
||||||
if [[ -n $pool ]]; then
|
if [[ -n $pool ]]; then
|
||||||
setupPool "$pool"
|
setupPool "$pool"
|
||||||
@ -76,17 +124,29 @@ setupPools() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNumberOfPHPVersions() {
|
getNumberOfPHPVersions() {
|
||||||
PHP_COUNT=$(find /etc/php/ -name 'www.conf' -type f | wc -l)
|
PHP_DIR=$(getEtcPHPDirectory)
|
||||||
|
EXIT_CODE=$?
|
||||||
|
assertEquals "Failed to find PHP directory" "0" "$EXIT_CODE"
|
||||||
|
|
||||||
|
PHP_COUNT=$(find "$PHP_DIR" -name 'www.conf' -type f | wc -l)
|
||||||
echo "$PHP_COUNT"
|
echo "$PHP_COUNT"
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnySocket() {
|
getAnySocket() {
|
||||||
|
PHP_DIR=$(getEtcPHPDirectory)
|
||||||
|
EXIT_CODE=$?
|
||||||
|
assertEquals "Failed to find PHP directory" "0" "$EXIT_CODE"
|
||||||
|
|
||||||
|
PHP_RUN_DIR=$(getRunPHPDirectory)
|
||||||
|
EXIT_CODE=$?
|
||||||
|
assertEquals "Failed to find PHP run directory" "0" "$EXIT_CODE"
|
||||||
|
|
||||||
#Get any socket of PHP-FPM:
|
#Get any socket of PHP-FPM:
|
||||||
PHP_FIRST=$(find /etc/php/ -name 'www.conf' -type f | head -n1)
|
PHP_FIRST=$(find "$PHP_DIR" -name 'www.conf' -type f | sort | head -n1)
|
||||||
assertNotNull "Failed to get PHP conf" "$PHP_FIRST"
|
assertNotNull "Failed to get PHP conf" "$PHP_FIRST"
|
||||||
PHP_VERSION=$(echo "$PHP_FIRST" | grep -oP "(\d\.\d)")
|
PHP_VERSION=$(getPHPVersion "$PHP_FIRST")
|
||||||
assertNotNull "Failed to get PHP version" "$PHP_VERSION"
|
assertNotNull "Failed to get PHP version for $PHP_FIRST" "$PHP_VERSION"
|
||||||
PHP_POOL=$(find /run/php/ -name "php${PHP_VERSION}*.sock" -type s | head -n1)
|
PHP_POOL=$(find "$PHP_RUN_DIR" -name "php${PHP_VERSION}*.sock" -type s 2>/dev/null | sort | head -n1)
|
||||||
assertNotNull "Failed to get PHP${PHP_VERSION} socket" "$PHP_POOL"
|
assertNotNull "Failed to get PHP${PHP_VERSION} socket" "$PHP_POOL"
|
||||||
echo "$PHP_POOL"
|
echo "$PHP_POOL"
|
||||||
}
|
}
|
||||||
@ -107,7 +167,7 @@ oneTimeSetUp() {
|
|||||||
#Install files:
|
#Install files:
|
||||||
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_discovery.sh" "/etc/zabbix"
|
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_discovery.sh" "/etc/zabbix"
|
||||||
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_status.sh" "/etc/zabbix"
|
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_status.sh" "/etc/zabbix"
|
||||||
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d | head -n1)"
|
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d | sort | head -n1)"
|
||||||
sudo chmod +x /etc/zabbix/zabbix_php_fpm_discovery.sh
|
sudo chmod +x /etc/zabbix/zabbix_php_fpm_discovery.sh
|
||||||
sudo chmod +x /etc/zabbix/zabbix_php_fpm_status.sh
|
sudo chmod +x /etc/zabbix/zabbix_php_fpm_status.sh
|
||||||
|
|
||||||
|
@ -71,6 +71,11 @@ if [[ ! -f ${S_WHOAMI} ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
||||||
|
${S_ECHO} "This script requires bash version 4.x or newer. Older version detected."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
STATUS_PATH="/php-fpm-status"
|
STATUS_PATH="/php-fpm-status"
|
||||||
DEBUG_MODE=""
|
DEBUG_MODE=""
|
||||||
ACTIVE_USER=$(${S_WHOAMI})
|
ACTIVE_USER=$(${S_WHOAMI})
|
||||||
|
Loading…
Reference in New Issue
Block a user