Files
claudetools/tmp/site-scan.sh
Mike Swanson c3eb709dd5 scc: NWTOC v5.0 - fix test exe deployment, session log
- Added EXE copy from Ate\ProdSW to C:\ATE in NWTOC.BAT
- Added /Y overwrite flag to all COPY commands
- Removed cyclic DATA folder copies from NWTOC
- Session log for 2026-03-16 DF DOS troubleshooting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 18:55:48 -07:00

123 lines
4.5 KiB
Bash

#!/bin/bash
# Scan all WordPress sites for performance/stability issues
for user in $(ls /var/cpanel/users/ | grep -v system | sort); do
domain=$(grep "^DNS=" /var/cpanel/users/$user 2>/dev/null | head -1 | cut -d= -f2)
pubhtml="/home/$user/public_html"
echo "===SITE_START==="
echo "ACCOUNT: $user"
echo "DOMAIN: $domain"
if [ ! -d "$pubhtml" ]; then
echo "STATUS: no_public_html"
echo "===SITE_END==="
continue
fi
du_size=$(du -sh "$pubhtml" 2>/dev/null | cut -f1)
echo "DISK: $du_size"
errlog_main=$(stat -c%s "$pubhtml/error_log" 2>/dev/null || echo "0")
echo "ERRORLOG_SIZE: $errlog_main"
if [ -f "$pubhtml/error_log" ] && [ "$errlog_main" -gt 0 ] 2>/dev/null; then
echo "ERRORLOG_TAIL:"
tail -3 "$pubhtml/error_log" 2>/dev/null
echo "ERRORLOG_END"
fi
if [ ! -f "$pubhtml/wp-config.php" ]; then
echo "WORDPRESS: no"
if [ -f "$pubhtml/index.html" ]; then
echo "TYPE: static_html"
elif [ -f "$pubhtml/index.php" ]; then
echo "TYPE: php"
else
echo "TYPE: empty_or_other"
fi
echo "===SITE_END==="
continue
fi
echo "WORDPRESS: yes"
wp_ver=$(grep "wp_version = " "$pubhtml/wp-includes/version.php" 2>/dev/null | cut -d"'" -f2)
echo "WP_VERSION: $wp_ver"
wp_debug=$(grep -c "WP_DEBUG.*true" "$pubhtml/wp-config.php" 2>/dev/null)
echo "WP_DEBUG: $wp_debug"
debuglog=$(stat -c%s "$pubhtml/wp-content/debug.log" 2>/dev/null || echo "0")
echo "DEBUGLOG_SIZE: $debuglog"
db_name=$(grep "DB_NAME" "$pubhtml/wp-config.php" 2>/dev/null | grep define | head -1 | cut -d"'" -f4)
echo "DB_NAME: $db_name"
tbl_prefix=$(grep 'table_prefix' "$pubhtml/wp-config.php" 2>/dev/null | head -1 | cut -d"'" -f2)
if [ -z "$tbl_prefix" ]; then
tbl_prefix="wp_"
fi
echo "TABLE_PREFIX: $tbl_prefix"
if [ -n "$db_name" ]; then
db_size=$(mysql -N -e "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) FROM information_schema.tables WHERE table_schema='$db_name'" 2>/dev/null)
echo "DB_SIZE_MB: $db_size"
autoload_size=$(mysql -N -e "SELECT ROUND(SUM(LENGTH(option_value))/1024/1024, 2) FROM ${db_name}.${tbl_prefix}options WHERE autoload='yes'" 2>/dev/null)
echo "AUTOLOAD_MB: $autoload_size"
transients=$(mysql -N -e "SELECT COUNT(*) FROM ${db_name}.${tbl_prefix}options WHERE option_name LIKE '%_transient_%'" 2>/dev/null)
echo "TRANSIENTS: $transients"
revisions=$(mysql -N -e "SELECT COUNT(*) FROM ${db_name}.${tbl_prefix}posts WHERE post_type='revision'" 2>/dev/null)
echo "REVISIONS: $revisions"
spam_comments=$(mysql -N -e "SELECT COUNT(*) FROM ${db_name}.${tbl_prefix}comments WHERE comment_approved='spam' OR comment_approved='trash'" 2>/dev/null)
echo "SPAM_COMMENTS: $spam_comments"
fi
plugin_count=$(ls -d "$pubhtml/wp-content/plugins"/*/ 2>/dev/null | wc -l)
echo "PLUGIN_COUNT: $plugin_count"
if [ -n "$db_name" ]; then
active_plugins=$(mysql -N -e "SELECT option_value FROM ${db_name}.${tbl_prefix}options WHERE option_name='active_plugins'" 2>/dev/null)
active_count=$(echo "$active_plugins" | grep -oP '"[^"]*\/[^"]*"' | wc -l)
echo "ACTIVE_PLUGIN_COUNT: $active_count"
inactive=$((plugin_count - active_count))
echo "INACTIVE_PLUGINS: $inactive"
fi
for heavy in wordfence jetpack elementor wpbakery revslider LayerSlider updraftplus all-in-one-wp-migration broken-link-checker; do
if [ -d "$pubhtml/wp-content/plugins/$heavy" ]; then
echo "HEAVY_PLUGIN: $heavy"
fi
done
htaccess_size=$(stat -c%s "$pubhtml/.htaccess" 2>/dev/null || echo "0")
echo "HTACCESS_SIZE: $htaccess_size"
cron_disabled=$(grep -c "DISABLE_WP_CRON.*true" "$pubhtml/wp-config.php" 2>/dev/null)
echo "CRON_DISABLED: $cron_disabled"
wp_memory=$(grep "WP_MEMORY_LIMIT" "$pubhtml/wp-config.php" 2>/dev/null | grep define | head -1 | cut -d"'" -f4)
echo "WP_MEMORY: $wp_memory"
if [ -f "$pubhtml/wp-content/object-cache.php" ]; then
echo "OBJECT_CACHE: yes"
else
echo "OBJECT_CACHE: no"
fi
if [ -f "$pubhtml/wp-content/advanced-cache.php" ]; then
echo "PAGE_CACHE: yes"
else
echo "PAGE_CACHE: no"
fi
uploads_size=$(du -sh "$pubhtml/wp-content/uploads" 2>/dev/null | cut -f1)
echo "UPLOADS_SIZE: $uploads_size"
echo "===SITE_END==="
done