A comprehensive monitoring and diagnostics tool for web servers running RunCloud with OpenLiteSpeed or Nginx, and MySQL/MariaDB. This script automatically detects your web server, supports multiple languages (English/Spanish), and provides actionable recommendations.
- Automatic Web Server Detection: Detects OpenLiteSpeed or Nginx automatically
- System Resource Monitoring: CPU, memory, swap, and load average tracking
- Web Server Analysis:
- OpenLiteSpeed: Process monitoring, LSPHP tracking, and error log analysis
- Nginx: Process monitoring, PHP-FPM tracking, and error log analysis
- PHP Process Tracking: Identify long-running PHP processes
- LSPHP for OpenLiteSpeed
- PHP-FPM for Nginx
- MySQL/MariaDB Diagnostics:
- Automatic detection of MySQL or MariaDB
- Active connections and queries
- InnoDB status and configuration
- Slow query log analysis
- Network Statistics: Connection states (ESTABLISHED, TIME_WAIT, CLOSE_WAIT)
- Disk Space Monitoring: Storage usage alerts
- System Logs: Recent database logs and OOM killer messages
- Context-Aware Alerts: Each section provides specific recommendations based on actual findings
- Severity Levels: Critical warnings, warnings, and success indicators
- Actionable Guidance: Specific commands and configuration suggestions for each issue
- Interactive Menu: User-friendly menu for selecting specific checks
- Shows detected web server
- Displays author information
- Command-Line Mode: Non-interactive operation for automation and scripting
- Selective Checks: Run only the checks you need
- Optional Logging: Enable/disable log file creation as needed
- Detailed Logging: Timestamped logs for historical analysis when enabled
- English and Spanish: Full interface translation
- Automatic Detection: Uses system language by default
- Language Toggle: Switch languages in interactive mode (option 'i')
- Complete Coverage: All menus, checks, and messages translated
- OS: Linux (Ubuntu/Debian recommended)
- Privileges: Root access (sudo)
- Stack: RunCloud + OpenLiteSpeed + MySQL/MariaDB
- Dependencies:
bash(version 4.0+)mysql-clientormariadb-client(auto-detected)net-tools(for netstat)systemd(for journalctl)
# Download and run the installer
curl -fsSL https://raw.githubusercontent.com/dcarrero/check-runcloud/main/install.sh | sudo bashOr download and inspect first:
# Download installer
curl -O https://raw.githubusercontent.com/dcarrero/check-runcloud/main/install.sh
# Review the installer
cat install.sh
# Run it
sudo bash install.shThe installer will:
- Check and install dependencies (mysql-client or mariadb-client, net-tools)
- Install the script to
/usr/local/bin/server-analysis - Create log directory
/home/logs - Optionally set up cron jobs for automated monitoring
# Download the script
curl -O https://raw.githubusercontent.com/dcarrero/check-runcloud/main/server_analysis.sh
# Make it executable
chmod +x server_analysis.sh
# Run it
sudo ./server_analysis.sh# Copy to system binaries
sudo cp server_analysis.sh /usr/local/bin/server-analysis
# Make executable
sudo chmod +x /usr/local/bin/server-analysis
# Run from anywhere
sudo server-analysis# Clone the repository
git clone https://github.com/dcarrero/check-runcloud.git
cd check-runcloud
# Run installer
sudo bash install.sh
# Or run directly
sudo bash server_analysis.shRun the script without arguments to access the interactive menu:
sudo ./server_analysis.shThe interactive menu allows you to:
- Select specific checks to run (1-10)
- Run all checks (option 0)
- Toggle logging on/off (option l)
- Quit (option q)
You can select multiple checks at once by separating them with commas or spaces:
Enter your choice(s): 1,5,10
# or
Enter your choice(s): 1 5 10
Run specific checks directly from the command line:
# Show help
./server_analysis.sh --help
# Run all checks
sudo ./server_analysis.sh --all
# Run all checks without logging
sudo ./server_analysis.sh --all --no-log
# Run specific checks only
sudo ./server_analysis.sh -1 -5 -10
# Run system resources and database checks without logging
sudo ./server_analysis.sh -1 -5 --no-logAvailable command-line options:
-h, --help: Show help message (doesn't require sudo)-a, --all: Run all checks--no-log: Disable log file creation-1to-10: Run specific checks (see list below)
- System Resources (CPU, Memory, Swap)
- OpenLiteSpeed Processes
- LSPHP CPU Usage (Top 15)
- Long-Running PHP Processes
- MySQL/MariaDB Analysis
- Slow Query Log
- OpenLiteSpeed Logs
- System Logs
- Network Statistics
- Disk Space
- Advanced PHP Analysis
The script generates:
- Console output: Real-time colored output with specific recommendations for each section
- Log file: By default, saved in
/home/logs/server_analysis_YYYYMMDD_HHMMSS.log(can be disabled with--no-logor in interactive mode)
========================================
SERVER ANALYSIS TOOL v3.0.0
========================================
Author: David Carrero
GitHub: https://github.com/dcarrero/check-runcloud
========================================
Web Server: OpenLiteSpeed
Select checks to run:
1) System Resources (CPU, Memory, Swap)
2) Web Server Processes (OpenLiteSpeed)
3) PHP CPU Usage (Top 15)
4) Long-Running PHP Processes
5) MySQL/MariaDB Analysis
6) Slow Query Log
7) Web Server Logs (OpenLiteSpeed)
8) System Logs
9) Network Statistics
10) Disk Space
0) Run ALL checks
Options:
l) Toggle Logging [Current: ON]
i) Change Language [Current: English]
q) Quit
Enter your choice(s): 1,5
========== SERVER ANALYSIS: RUNCLOUD + OPENLITESPEED + MYSQL/MARIADB ==========
Script Version: 3.0.0
Timestamp: 2025-11-12 10:30:45
Logging: ENABLED (/home/logs/server_analysis_20251112_103045.log)
[1. SYSTEM RESOURCES]
=====================================
CPU, Memory and Swap Usage:
total used free shared buff/cache available
Mem: 15Gi 8.2Gi 2.1Gi 324Mi 5.4Gi 6.8Gi
Swap: 2.0Gi 512Mi 1.5Gi
System Load Average: 2.15, 1.89, 1.56
CPU Cores: 8
Recommendations:
✓ Memory usage is healthy (54%)
✓ Load average is normal
[5. MYSQL/MARIADB ANALYSIS]
=====================================
Database Type: MariaDB
Client: mariadb
Socket: /run/mysqld/mysqld.sock
...
Recommendations:
✓ No slow queries detected
âš Connection usage is 85% (170 / 200)
- Increase max_connections in MySQL/MariaDB config
- Review connection pooling in applications
Monitor your server automatically at regular intervals:
# Edit crontab
sudo crontab -e
# Run every 30 minutes (during troubleshooting)
*/30 * * * * /usr/local/bin/server-analysis > /dev/null 2>&1
# Or run every hour (for regular monitoring)
0 * * * * /usr/local/bin/server-analysis > /dev/null 2>&1
# Or run daily at 3 AM
0 3 * * * /usr/local/bin/server-analysis > /dev/null 2>&1Automatically receive email notifications when critical issues are detected.
# Copy the email alert example
cp examples/email_alerts.sh /usr/local/bin/server-analysis-alert
# Edit configuration
sudo nano /usr/local/bin/server-analysis-alert
# Change EMAIL_TO to your email address
# Make executable
sudo chmod +x /usr/local/bin/server-analysis-alert
# Add to crontab instead of regular analysis
sudo crontab -e
# Add: 0 * * * * /usr/local/bin/server-analysis-alertFeatures of the email alert wrapper:
- Only sends emails when thresholds are exceeded
- Includes memory, disk, and process monitoring
- Detects OOM killer activity
- Includes full analysis in email body
# Install mailutils
sudo apt-get install mailutils
# Modify cron job to send email
0 * * * * /usr/local/bin/server-analysis && mail -s "Server Analysis Report" your@email.com < $(ls -t /home/logs/server_analysis_*.log | head -1)For Gmail or other SMTP servers, see examples/email_alerts.sh for detailed configuration.
- Memory > 85%: Consider upgrading RAM or optimizing applications
- High Load Average: Should be less than CPU core count
- Long-running processes (> 60s): Indicates slow PHP code or database queries
- High CPU usage: May need code optimization or caching
- Database type: Shows whether MySQL or MariaDB is detected
- Active queries > 5s: Likely needs query optimization or indexes
- Max connections: Ensure limit is not being reached
- InnoDB buffer pool: Should be ~70% of available RAM
- Identifies specific queries that need optimization
- Add indexes or refactor problem queries
| Issue | Possible Cause | Solution |
|---|---|---|
| Memory > 90% | Insufficient RAM | Upgrade server or optimize apps |
| LSPHP > 60s | Slow queries/code | Check slow query log, profile PHP |
| High disk usage | Logs or uploads | Clean old files, rotate logs |
| Many TIME_WAIT | High traffic | Normal, but ensure keep-alive is configured |
| OOM killer active | Memory exhausted | Increase RAM or reduce app memory |
Edit the script to adjust alert thresholds:
# Line ~15-17
readonly MEMORY_THRESHOLD=85 # Change to 90 for less sensitive alerts
readonly DISK_THRESHOLD=90
readonly LONG_PROCESS_THRESHOLD=60 # PHP processes in seconds# Line ~13
readonly LOG_DIR="/home/logs" # Change to your preferred location# Ensure you're running as root
sudo ./server_analysis.sh# Manually check socket location
find /run /var/run -name "mysqld.sock"
# The script auto-detects the socket, but you can verify it's accessible
ls -la /run/mysqld/mysqld.sock
# or
ls -la /var/run/mysqld/mysqld.sock# Install the appropriate client
# For MariaDB:
sudo apt-get install mariadb-client
# For MySQL:
sudo apt-get install mysql-client
# The script will automatically detect which one is available# Check your OpenLiteSpeed installation path
ls -la /usr/local/lsws/logs/
# Update paths in script (line ~268)Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/improvement) - Open a Pull Request
- Maintain POSIX compliance where possible
- Add comments for complex logic
- Test on Ubuntu 20.04/22.04 and Debian 11/12
- Update README for new features
This project is licensed under the MIT License - see the LICENSE file for details.
David Carrero
- Website: carrero.es
- GitHub: @dcarrero
- Designed for servers managed with RunCloud
- Optimized for OpenLiteSpeed
- MySQL/MariaDB diagnostics based on best practices
- Compatible with both MySQL and MariaDB databases
If you find this script helpful, please:
- Star the repository
- Report issues on GitHub
- Share with others who might benefit
- Interactive Menu: User-friendly interactive menu for selecting checks
- Command-Line Mode: Non-interactive operation with flags (-1 to -10, --all, --no-log)
- Smart Recommendations: Context-aware recommendations for each check
- Optional Logging: Toggle logging on/off (default: enabled)
- Selective Checks: Run individual checks or all checks
- Help System: Comprehensive help accessible without root privileges
- Initial release
- Basic system resource monitoring
- OpenLiteSpeed process analysis
- MySQL/MariaDB diagnostics
- Automated alerting system
Q: Can I use this on cPanel/Plesk servers? A: This script is specifically designed for RunCloud + OpenLiteSpeed. For other control panels, modifications will be needed.
Q: How much disk space do logs consume? A: Each analysis generates ~100-500KB. For hourly runs, expect ~10-50MB per month.
Q: Is this safe to run on production servers?
A: Yes, the script only reads data and doesn't modify any configurations. It uses set -euo pipefail for safety.
Q: Can I run this without RunCloud? A: Yes, it works with any OpenLiteSpeed + MySQL/MariaDB setup. RunCloud-specific features are minimal.
Q: Does it work with MySQL or only MariaDB? A: It works with both! The script automatically detects whether you have MySQL or MariaDB installed and uses the appropriate client.
Special thanks to:
- Stackscale - For providing private cloud infrastructure to deploy and test RunCloud environments
- Color Vivo - For providing access to their RunCloud servers and WordPress installations for script testing
Made with care for the web hosting community 🚀