Middle English Lyrics : New Readings of Short Poems

#!/bin/bash # Icinga Probe Script for WordPress Performance Metrics # Usage: ./icinga-probe.sh [url] # Configuration URL="${1:-https://wp.unil.ch/}" SECRET="M4iov6OfDNnw6dMXGh2abq5s" # Must match performance-probe.php TARGET_URL="${URL%/}/performance-status" # performance-probe.php endpoint. Must be installed as a mu-plugin. # Thresholds (in ms) WARN_MS=2000 CRIT_MS=10000 # Fetch the probe data using a Request Header instead of query param (cleaner logs) RESPONSE=$(curl -s -H "X-WP-Performance-Probe: ${SECRET}" "$TARGET_URL") # Check if curl succeeded and the response contains JSON if [ $? -ne 0 ] || [[ ! "$RESPONSE" =~ "total_ms" ]]; then echo "CRITICAL - Could not reach the WordPress performance probe at ${URL}" exit 2 fi TOTAL_MS=$(echo "$RESPONSE" | grep -o '"total_ms":[0-9.]*' | cut -d: -f2) QUERIES=$(echo "$RESPONSE" | grep -o '"queries":[0-9]*' | cut -d: -f2) MEMORY=$(echo "$RESPONSE" | grep -o '"memory_mb":[0-9.]*' | cut -d: -f2) # Determine Icinga status STATUS="OK" EXIT_CODE=0 # awk-based comparison for floating point numbers IS_CRIT=$(awk -v total="$TOTAL_MS" -v crit="$CRIT_MS" 'BEGIN {print (total > crit) ? 1 : 0}') IS_WARN=$(awk -v total="$TOTAL_MS" -v warn="$WARN_MS" 'BEGIN {print (total > warn) ? 1 : 0}') if [ "$IS_CRIT" -eq 1 ]; then STATUS="CRITICAL" EXIT_CODE=2 elif [ "$IS_WARN" -eq 1 ]; then STATUS="WARNING" EXIT_CODE=1 fi # Format Icinga/Nagios: STATUS - Message | label=value[UOM];[warn];[crit];[min];[max] echo "${STATUS} - WP Bootstrap: ${TOTAL_MS}ms (${QUERIES} queries, ${MEMORY}MB) | wp_total_ms=${TOTAL_MS}ms;${WARN_MS};${CRIT_MS};0; wp_queries=${QUERIES};;;0; wp_memory_mb=${MEMORY}MB;;;0;" exit $EXIT_CODE
