Add Loadwatch Health Analyzer for system monitoring analysis

NEW FEATURE: Loadwatch Health Analyzer
- Comprehensive system health analysis from loadwatch monitoring logs
- Time-range analysis: 1h, 6h, 24h, 7d, 30d options
- Intelligent problem detection and trending

CAPABILITIES:
- Memory pressure detection (low available memory, high swap usage)
- CPU saturation analysis (idle %, iowait, steal time)
- Load average trending and threshold detection
- Process issue detection (zombie processes, high CPU/MEM consumers)
- MySQL performance monitoring (slow queries, thread counts)
- Network connection analysis
- Historical trending across snapshots (3-minute intervals)

IMPLEMENTATION:
- modules/diagnostics/loadwatch-analyzer.sh - Main analyzer script
- Handles symlinked loadwatch directories
- Parses 7 log sections: alerts, summary, memory, CPU, tasks, MySQL, network
- Generates detailed reports with actionable recommendations
- Saves reports to tmp/ directory for review

INTEGRATION:
- Added to Performance & Diagnostics menu (option 10)
- Time range selection submenu for user-friendly access
- Updated README.md with feature documentation and usage examples

ANALYSIS FEATURES:
- Swap threshold alerts (>= 50% usage)
- CPU saturation detection (< 10% idle)
- High I/O wait warnings (> 20%)
- Zombie process tracking
- Memory availability trending (avg/min/max)
- Top CPU consumers aggregated across period

Perfect for:
- Post-incident investigation
- Capacity planning
- Performance trending
- System health monitoring
- Identifying resource bottlenecks

Works with servers that have loadwatch monitoring enabled
(logs in /root/loadwatch or /var/log/loadwatch)
This commit is contained in:
cschantz
2025-11-20 20:35:16 -05:00
parent 6e092a5016
commit fc9a433503
3 changed files with 731 additions and 7 deletions
+38 -2
View File
@@ -539,7 +539,8 @@ show_performance_menu() {
echo ""
echo -e "${BOLD}Logs & Diagnostics:${NC}"
echo -e " ${MAGENTA}9)${NC} Log Analyzer - Parse and analyze system logs"
echo -e " ${MAGENTA}10)${NC} Email Queue Monitor - Mail queue analysis"
echo -e " ${MAGENTA}10)${NC} Loadwatch Health Analyzer - System health from monitoring logs"
echo -e " ${MAGENTA}11)${NC} Email Queue Monitor - Mail queue analysis"
echo ""
echo -e " ${RED}0)${NC} Back to Main Menu"
echo ""
@@ -1346,6 +1347,40 @@ handle_wp_security_menu() {
done
}
# Loadwatch analyzer handler with time range selection
handle_loadwatch_analyzer() {
show_banner
echo -e "${MAGENTA}${BOLD}📊 Loadwatch Health Analyzer${NC}"
echo ""
echo -e "Select time range for analysis:"
echo ""
echo -e " ${CYAN}1)${NC} Last 1 Hour - Recent system activity"
echo -e " ${CYAN}2)${NC} Last 6 Hours - Mid-term trending"
echo -e " ${CYAN}3)${NC} Last 24 Hours - Full day analysis"
echo -e " ${CYAN}4)${NC} Last 7 Days - Weekly patterns"
echo -e " ${CYAN}5)${NC} Last 30 Days - Monthly overview"
echo ""
echo -e " ${RED}0)${NC} Back"
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo -n "Select time range: "
read -r range_choice
case $range_choice in
1) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "1h" ;;
2) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "6h" ;;
3) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "24h" ;;
4) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "7d" ;;
5) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "30d" ;;
0) return ;;
*)
echo -e "${RED}Invalid option${NC}"
sleep 1
;;
esac
}
# Performance submenu handler
handle_performance_menu() {
while true; do
@@ -1362,7 +1397,8 @@ handle_performance_menu() {
7) run_module "performance" "apache-performance.sh" ;;
8) run_module "performance" "php-fpm-monitor.sh" ;;
9) run_module "performance" "log-analyzer.sh" ;;
10) run_module "performance" "email-queue-monitor.sh" ;;
10) handle_loadwatch_analyzer ;;
11) run_module "performance" "email-queue-monitor.sh" ;;
0) return ;;
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
esac