3
0
mirror of https://github.com/rvalitov/zabbix-php-fpm.git synced 2023-11-05 03:30:27 +01:00

[fix] discover checks

This commit is contained in:
Ramil Valitov 2020-07-07 05:25:12 +03:00
parent c474b4c6c5
commit 56c7251842
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914

View File

@ -193,7 +193,7 @@ testDiscoverScriptDebug() {
DATA=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "nosleep" "/php-fpm-status") DATA=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "nosleep" "/php-fpm-status")
NUMBER_OF_ERRORS=$(echo "$DATA" | grep -o -F 'Error:' | wc -l) NUMBER_OF_ERRORS=$(echo "$DATA" | grep -o -F 'Error:' | wc -l)
PHP_COUNT=$(getNumberOfPHPVersions) PHP_COUNT=$(getNumberOfPHPVersions)
if [[ $PHP_COUNT != $NUMBER_OF_ERRORS ]]; then if [[ $PHP_COUNT != "$NUMBER_OF_ERRORS" ]]; then
ERRORS_LIST=$(echo "$DATA" | grep -F 'Error:') ERRORS_LIST=$(echo "$DATA" | grep -F 'Error:')
echo "Errors list:" echo "Errors list:"
echo "$ERRORS_LIST" echo "$ERRORS_LIST"
@ -209,15 +209,31 @@ testZabbixDiscoverReturnsData() {
assertNotNull "Discover script failed: $DATA" "$IS_OK" assertNotNull "Discover script failed: $DATA" "$IS_OK"
} }
testZabbixDiscoverNumberOfStaticPools() { function discoverAll() {
OLD_DATA="" DATA_OLD=$1
DATA="1" DATA_COUNT=$2
while if [[ -z $DATA_COUNT ]]; then
[[ $OLD_DATA != "$DATA" ]] DATA_COUNT=0
OLD_DATA="$DATA" fi
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
do true; done DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
if [[ $DATA_OLD == "$DATA" ]]; then
echo "$DATA"
return 0
else
DATA_COUNT=$(echo "$DATA_COUNT + 1" | bc)
if [[ $DATA_COUNT -gt 10 ]]; then
return 1
fi
discoverAll "$DATA" "$DATA_COUNT"
fi
}
testZabbixDiscoverNumberOfStaticPools() {
DATA=$(discoverAll)
STATUS=$?
assertEquals "Failed to discover all data" "0" "$STATUS"
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"static' | wc -l) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"static' | wc -l)
PHP_COUNT=$(getNumberOfPHPVersions) PHP_COUNT=$(getNumberOfPHPVersions)
@ -226,14 +242,9 @@ testZabbixDiscoverNumberOfStaticPools() {
} }
testZabbixDiscoverNumberOfDynamicPools() { testZabbixDiscoverNumberOfDynamicPools() {
OLD_DATA="" DATA=$(discoverAll)
DATA="1" STATUS=$?
assertEquals "Failed to discover all data" "0" "$STATUS"
while
[[ $OLD_DATA != "$DATA" ]]
OLD_DATA="$DATA"
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
do true; done
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"dynamic' | wc -l) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"dynamic' | wc -l)
PHP_COUNT=$(getNumberOfPHPVersions) PHP_COUNT=$(getNumberOfPHPVersions)
@ -242,14 +253,9 @@ testZabbixDiscoverNumberOfDynamicPools() {
} }
testZabbixDiscoverNumberOfOndemandPoolsCold() { testZabbixDiscoverNumberOfOndemandPoolsCold() {
OLD_DATA="" DATA=$(discoverAll)
DATA="1" STATUS=$?
assertEquals "Failed to discover all data" "0" "$STATUS"
while
[[ $OLD_DATA != "$DATA" ]]
OLD_DATA="$DATA"
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
do true; done
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"ondemand' | wc -l) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"ondemand' | wc -l)
#If the pools are not started then we have 0 here: #If the pools are not started then we have 0 here:
@ -296,14 +302,9 @@ testZabbixDiscoverNumberOfOndemandPoolsHot() {
} }
testZabbixDiscoverNumberOfIPPools() { testZabbixDiscoverNumberOfIPPools() {
OLD_DATA="" DATA=$(discoverAll)
DATA="1" STATUS=$?
assertEquals "Failed to discover all data" "0" "$STATUS"
while
[[ $OLD_DATA != "$DATA" ]]
OLD_DATA="$DATA"
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
do true; done
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"localhost",' | wc -l) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"localhost",' | wc -l)
PHP_COUNT=$(getNumberOfPHPVersions) PHP_COUNT=$(getNumberOfPHPVersions)
@ -312,14 +313,9 @@ testZabbixDiscoverNumberOfIPPools() {
} }
testZabbixDiscoverNumberOfPortPools() { testZabbixDiscoverNumberOfPortPools() {
OLD_DATA="" DATA=$(discoverAll)
DATA="1" STATUS=$?
assertEquals "Failed to discover all data" "0" "$STATUS"
while
[[ $OLD_DATA != "$DATA" ]]
OLD_DATA="$DATA"
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
do true; done
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"port' | wc -l) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"port' | wc -l)
PHP_COUNT=$(getNumberOfPHPVersions) PHP_COUNT=$(getNumberOfPHPVersions)