diff --git a/seqs/snmp.sh b/seqs/snmp.sh index b714072..3674623 100755 --- a/seqs/snmp.sh +++ b/seqs/snmp.sh @@ -144,18 +144,19 @@ step_25() { ;; esac } +phpVersionStr="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')" phpFpmStatusNginx="# Provide php-fpm status location ~ ^/(status|ping)\$ { access_log off; allow 127.0.0.1; +allow ::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; +fastcgi_pass unix:/var/run/php/php${phpVersionStr}-fpm.sock; }" - step_26_info() { echo "Prepare php config for php-fpm status"; } step_26_alias() { ALIAS="phpfpm_config"; } step_26() { @@ -165,7 +166,6 @@ step_26() { 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" @@ -187,12 +187,60 @@ step_27() { } 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 #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() { # adding dry run output for clarification