Skip to main content

Site Health & Monitoring

Overview

Healthy sites require monitoring of the WordPress version, PHP version, database state, active plugins, and server environment. WP-CLI provides commands to quickly surface all this information without logging into wp-admin.

Quick Health Check Script

#!/bin/bash
# wp-site-health.sh

echo "==============================="
echo " WordPress Site Health Report"
echo " $(wp option get siteurl)"
echo " $(date)"
echo "==============================="
echo ""

echo "--- WordPress ---"
wp core version
echo "Status: $(wp core is-installed && echo 'Installed ✓' || echo 'Not Installed ✗')"
echo ""

echo "--- Updates Available ---"
wp core check-update
wp plugin list --update=available --format=count | xargs echo "Plugins needing updates:"
wp theme list --update=available --format=count | xargs echo "Themes needing updates:"
echo ""

echo "--- PHP Environment ---"
php --version | head -1
echo "Memory limit: $(wp eval 'echo ini_get("memory_limit");')"
echo "Max execution: $(wp eval 'echo ini_get("max_execution_time");')s"
echo "Upload max: $(wp eval 'echo ini_get("upload_max_filesize");')"
echo ""

echo "--- Database ---"
wp db check > /dev/null 2>&1 && echo "DB Check: OK ✓" || echo "DB Check: ERROR ✗"
wp db size --human-readable 2>/dev/null || wp db query "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) FROM information_schema.TABLES WHERE table_schema = DATABASE();" --skip-column-names | xargs echo "DB Size (MB):"
echo ""

echo "--- Cache ---"
echo "Cache type: $(wp cache type)"
echo ""

echo "--- Active Plugins ---"
wp plugin list --status=active --format=count | xargs echo "Active plugins:"
echo ""

echo "--- Maintenance Mode ---"
wp maintenance-mode status
echo ""

echo "--- File Integrity ---"
wp core verify-checksums && echo "Core checksums: OK ✓" || echo "Core checksums: FAILED ✗"
echo ""

echo "==============================="
echo " Report complete"
echo "==============================="

Key Health Indicators

CheckCommandHealthy State
WP versionwp core versionLatest stable
Core integritywp core verify-checksumsNo mismatches
DB statuswp db checkAll tables OK
Pending updateswp plugin list --update=available0 plugins
Maintenance modewp maintenance-mode statusNot active
Cache backendwp cache typeRedis / Memcached
PHP memorywp eval 'echo ini_get("memory_limit");'256M or more

Automated Monitoring Cron

# Run health check daily at 6 AM and log results
0 6 * * * /opt/scripts/wp-site-health.sh >> /var/log/wp-health.log 2>&1

Multi-Site Health Overview

for url in $(wp site list --field=url); do
echo "--- $url ---"
wp core version --url="$url"
wp plugin list --update=available --format=count --url="$url" | xargs echo " Plugin updates:"
done

Next Steps