Added steps to configure php-fpm status
Todo: enhancement for automatic nginx configuration
This commit is contained in:
84
seqs/snmp.sh
84
seqs/snmp.sh
@@ -119,6 +119,74 @@ step_23() {
|
||||
osUpdateCron="/etc/cron.d/aptUpdate"
|
||||
osUpdateCronContent="22 */6 * * * root /usr/bin/apt-get -qq update"
|
||||
|
||||
step_25_info() { echo "Prepare nginx to provide php-fpm status to $toolName"; }
|
||||
step_25_alias() { ALIAS="phpfpm"; }
|
||||
step_25() {
|
||||
echo -e "\n [!] Please add the following to your default server:\n"
|
||||
echo "$phpFpmStatusNginx"
|
||||
echo
|
||||
if [ $QUIET -ne 0 ] ; then
|
||||
answer=n
|
||||
else
|
||||
exe read -p "Open new shell to configure y/[n]? " answer
|
||||
fi
|
||||
case $answer in
|
||||
[yY])
|
||||
echo " [I] Opening interactive shell. Type \"exit\" to return to this script."
|
||||
exe bash -i
|
||||
echo " [I] Interactive shell ended. Continuing with $0."
|
||||
exe nginx -t
|
||||
endReturn -o $? "Nginx configuration error"
|
||||
|
||||
exe service nginx restart
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
phpFpmStatusNginx="# Provide php-fpm status
|
||||
location ~ ^/(status|ping)\$ {
|
||||
access_log off;
|
||||
allow 127.0.0.1;
|
||||
deny all;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
||||
#fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_pass unix:/var/run/php/php$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')-fpm.sock;
|
||||
}"
|
||||
|
||||
|
||||
step_26_info() { echo "Prepare php config for php-fpm status"; }
|
||||
step_26_alias() { ALIAS="phpfpm_config"; }
|
||||
step_26() {
|
||||
exe sed -i "s/^;\(pm\.status_path\)/\1/" "$phpPoolConfigLoc"
|
||||
exe php-fpm${phpVersionStr} -t
|
||||
endReturn -o $? "Invalid php configuration"
|
||||
|
||||
service php${phpVersionStr}-fpm restart
|
||||
}
|
||||
phpVersionStr="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')"
|
||||
phpConfigDir="/etc/php/${phpVersionStr}"
|
||||
phpPoolConfigLoc="${phpConfigDir}/fpm/pool.d/www.conf"
|
||||
|
||||
step_27_info() { echo "Extend $toolName with parsing of php-fpm status"; }
|
||||
step_27_alias() { ALIAS="phpfpm_extend"; }
|
||||
step_27() {
|
||||
checkExtend phpfpmsp
|
||||
if [ "$?" != "0" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O "${phpfpmExtendLoc}"
|
||||
endReturn -o $? "Download failed"
|
||||
exe chmod +x "$phpfpmExtendLoc"
|
||||
|
||||
addConf -a "extend phpfpmsp ${phpfpmExtendLoc}" "$toolConfig"
|
||||
|
||||
exe service snmpd restart
|
||||
}
|
||||
phpfpmExtendLoc="${toolConfigLoc}/phpfpmsp"
|
||||
|
||||
#fail2ban
|
||||
#exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/fail2ban -O "${toolConfig}/fail2ban"
|
||||
# nginx
|
||||
@@ -127,20 +195,20 @@ osUpdateCronContent="22 */6 * * * root /usr/bin/apt-get -qq update"
|
||||
#exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O "${toolConfig}/phpfpmsp"
|
||||
|
||||
checkExtend() {
|
||||
# adding dry run output for clarification
|
||||
if [ "$DRY" != "0" ] ; then
|
||||
echo " [I] check if \"extend ${1}\" exists..dry-run"
|
||||
fi
|
||||
|
||||
exep "cat \"$toolConfig\" | grep -e '^\s*extend\s\+${1}' >>/dev/null 2>&1"
|
||||
# Only warn if entry exists and dry-run is not seleted
|
||||
if [ "$?" == "0" ] && [ "$DRY" == "0" ] ; then
|
||||
echo "[WARN] Extend for ${1} exists"
|
||||
echoerr " [W] Extend for ${1} exists"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# adding dry run output for clarification
|
||||
if [ "$DRY" != "0" ] ; then
|
||||
echo "-- check if \"extend ${1}\" exists..dry-run"
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
VERSION_SEQREV=7
|
||||
VERSION_SEQREV=8
|
||||
. sequencer.sh
|
||||
|
Reference in New Issue
Block a user