54 lines
1.8 KiB
Bash
Executable File
54 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Uhhhhhhhhhhhhhhhh
|
|
PHP_VERSION=$(dpkg -l | grep -Pe 'php[0-9.]+-fpm' | awk '{print $2}' | sed 's/php//;s/-fpm//')
|
|
PHP_VERSION=${PHP_VERSION-8.3}
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Post-installation script for zabbix-php-monitoring
|
|
|
|
# Create log directory with proper permissions
|
|
mkdir -p /var/log/zabbix
|
|
chown www-data:zabbix /var/log/zabbix
|
|
chmod 755 /var/log/zabbix
|
|
|
|
# Create log file with proper permissions if it doesn't exist
|
|
if [ ! -f /var/log/zabbix/php.log ]; then
|
|
touch /var/log/zabbix/php.exceptions.log
|
|
chown www-data:zabbix /var/log/zabbix/php.exceptions.log
|
|
chmod 644 /var/log/zabbix/php.exceptions.log
|
|
fi
|
|
|
|
# Set permissions on sudoers file
|
|
chown root:root /etc/sudoers.d/zabbix-php-user
|
|
chmod 440 /etc/sudoers.d/zabbix-php-user
|
|
|
|
# Unset previous empty prepend_file
|
|
# sed -i 's/^[[:space:]]*auto_prepend_file[[:space:]]*=[[:space:]]*$/; auto_prepend_file =/' /etc/php/*/fpm/php.ini
|
|
|
|
for cfg in /etc/php/$PHP_VERSION/fpm/pool.d/*.conf; do
|
|
grep -q auto_prepend_file $cfg && continue
|
|
read -p "$(echo -e "\e[3;31mZabbix monitor in $cfg einrichten? [\e[1;31mY\e[0m,n]: \e[0m")" ok
|
|
comment=''
|
|
[[ "$ok" =~ n|N ]] && comment='; Comment out to enable\n; '
|
|
echo -e "\n; Added by php$PHP_VERSION-zabbix-monitor\n${comment}php_admin_value[auto_prepend_file] = /usr/lib/zabbix-php.php" >> $cfg
|
|
done
|
|
|
|
# Restart services to apply configuration
|
|
systemctl reload php$PHP_VERSION-fpm.service || true
|
|
systemctl restart zabbix-agent.service || true
|
|
|
|
echo "Zabbix PHP monitoring has been installed successfully."
|
|
echo "Log file: /var/log/zabbix/php.exceptions.log"
|
|
echo "Template file: /usr/share/doc/zabbix-php-monitoring/zabbix_template_php_exceptions.yaml"
|
|
echo ""
|
|
echo "To complete setup:"
|
|
echo "1. Import the template into your Zabbix server"
|
|
echo "2. Assign the template to your hosts"
|
|
echo "3. Configure zabbix_agentd.conf with appropriate log monitoring"
|
|
|
|
exit 0
|