diff --git a/mbadmin.jps b/mbadmin.jps index ee75111..af3891c 100644 --- a/mbadmin.jps +++ b/mbadmin.jps @@ -753,7 +753,7 @@ actions: message: "${response.out}" litespeed_metrics: - cmd[cp]: - user: root + user: litespeed commands: - bash /home/litespeed/mbmanager/scripts/litespeed_metrics.sh - return: diff --git a/scripts/litespeed_metrics.sh b/scripts/litespeed_metrics.sh index 53bde9e..b57ac1a 100644 --- a/scripts/litespeed_metrics.sh +++ b/scripts/litespeed_metrics.sh @@ -3,15 +3,20 @@ # LiteSpeed Cache Critical Metrics Monitor # Captures the 4 most important performance metrics -# Check if WP-CLI is available -if [ ! -f "/home/litespeed/bin/wp" ]; then - echo '{"error": "WP-CLI not found at /home/litespeed/bin/wp"}' +# Find WP-CLI location +WP_CLI_PATH="" +if [ -f "/home/litespeed/bin/wp" ]; then + WP_CLI_PATH="/home/litespeed/bin/wp" +elif command -v wp >/dev/null 2>&1; then + WP_CLI_PATH="wp" +else + echo '{"error": "WP-CLI not found. Please ensure WP-CLI is installed and accessible."}' exit 1 fi # Function to run WP-CLI commands run_wp_command() { - /home/litespeed/bin/wp --path=/var/www/webroot/ROOT "$@" 2>/dev/null + $WP_CLI_PATH --path=/var/www/webroot/ROOT "$@" 2>/dev/null } # Initialize JSON output