Added steps to configure nginx status

Todo: enhancement for automatic nginx configuration
This commit is contained in:
2019-12-14 21:10:47 +01:00
parent c01371a21c
commit 53d51f8cee

View File

@@ -144,18 +144,19 @@ step_25() {
;; ;;
esac esac
} }
phpVersionStr="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')"
phpFpmStatusNginx="# Provide php-fpm status phpFpmStatusNginx="# Provide php-fpm status
location ~ ^/(status|ping)\$ { location ~ ^/(status|ping)\$ {
access_log off; access_log off;
allow 127.0.0.1; allow 127.0.0.1;
allow ::1;
deny all; deny all;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000; #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; fastcgi_pass unix:/var/run/php/php${phpVersionStr}-fpm.sock;
}" }"
step_26_info() { echo "Prepare php config for php-fpm status"; } step_26_info() { echo "Prepare php config for php-fpm status"; }
step_26_alias() { ALIAS="phpfpm_config"; } step_26_alias() { ALIAS="phpfpm_config"; }
step_26() { step_26() {
@@ -165,7 +166,6 @@ step_26() {
service php${phpVersionStr}-fpm restart service php${phpVersionStr}-fpm restart
} }
phpVersionStr="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')"
phpConfigDir="/etc/php/${phpVersionStr}" phpConfigDir="/etc/php/${phpVersionStr}"
phpPoolConfigLoc="${phpConfigDir}/fpm/pool.d/www.conf" phpPoolConfigLoc="${phpConfigDir}/fpm/pool.d/www.conf"
@@ -187,12 +187,60 @@ step_27() {
} }
phpfpmExtendLoc="${toolConfigLoc}/phpfpmsp" phpfpmExtendLoc="${toolConfigLoc}/phpfpmsp"
step_29_info() { echo "Prepare nginx to provide status to $toolName"; }
step_29_alias() { ALIAS="nginx"; }
step_29() {
echo -e "\n [!] Please add the following to your default server:\n"
echo "$nginxStatus"
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
}
nginxStatus="# Provide nginx status
location /nginx-status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow ::1;
deny all;
}
"
step_30_info() { echo "Extend $toolName with parsing of nginx status"; }
step_30_alias() { ALIAS="nginx_extend"; }
step_30() {
checkExtend nginx
if [ "$?" != "0" ]; then
return 1
fi
exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O "${nginxExtendLoc}"
endReturn -o $? "Download failed"
exe chmod +x "$nginxExtendLoc"
addConf -a "extend nginx ${nginxExtendLoc}" "$toolConfig"
exe service snmpd restart
}
nginxExtendLoc="${toolConfigLoc}/nginx"
#fail2ban #fail2ban
#exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/fail2ban -O "${toolConfig}/fail2ban" #exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/fail2ban -O "${toolConfig}/fail2ban"
# nginx
#exe wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O "${toolConfig}/nginx"
# php-fpm
#exe wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O "${toolConfig}/phpfpmsp"
checkExtend() { checkExtend() {
# adding dry run output for clarification # adding dry run output for clarification