Monitor Website Resource Usage with website-usage v2

Managing server resources effectively is crucial, especially when hosting multiple websites. If your customers are experiencing slowdowns or encountering "Service Unavailable" errors, you need a way to monitor CPU, RAM, and I/O usage per website. To solve this, we built website-usage, a lightweight Bash script that provides real-time resource usage insights per website as CPU/RAM/IO usage is not currently available in the dashboard.

Features

✅ Monitor CPU, Memory, and I/O usage per website
✅ Interactive website selection mode - no need to remember website IDs
✅ Real-time monitoring with watch mode
✅ JSON output format for integration with monitoring systems
✅ Color-coded output for better readability
✅ Process count monitoring
✅ Website owner information display
✅ Simple installation and usage

Installation

Setting up website-usage is quick and easy. Run the following command to install it on your server:

bash <(curl -fsSL https://tools.webgee.com/enhance/usage/installer.sh)

If curl is unavailable, you can use:

bash <(wget -qO- https://tools.webgee.com/enhance/usage/installer.sh)

This command downloads and installs the script to /usr/bin/website-usage, making it accessible system-wide.

Usage

The tool now supports multiple usage modes:

1. Interactive Mode

Simply run the command without any arguments to see a list of available websites:

website-usage
root@pluto:~# website-usage
Available Websites:
	1.	12ab34cd-56ef-78gh-90ij-klmn12345678 (Owner: user1234)
	2.	23bc45de-67fg-89hi-01jk-lmno23456789 (Owner: demo5678)
	3.	34cd56ef-78gh-90ij-12kl-mnop34567890 (Owner: testweb1)
	4.	45de67fg-89hi-01jk-23lm-nopq45678901 (Owner: sample9876)
	5.	56ef78gh-90ij-12kl-34mn-opqr56789012 (Owner: siteowner9)
Select a website number (1-5) or 'q' to quit:

Select a website number (1-15) or ‘q’ to quit:

This will show you a numbered list of websites with their owners, making it easy to select the one you want to monitor.

2. Direct Mode

Check a specific website using its ID:

website-usage <website_id>

3. Watch Mode

Monitor a website in real-time with continuous updates:

website-usage --watch <website_id>

4. JSON Mode

Get machine-readable output for integration with other tools:

website-usage --json <website_id>

Example Outputs

Standard Output

Website Information:

ID: abc123
Owner: webuser
CPU Usage: 45.23% (4 cores)
Memory Usage: 256 MB / 1024 MB (25.00%)
IO Usage:
Read: 1.23 MB/s
Write: 0.45 MB/s
Total: 1.68 MB/s
Processes: 12 / 50

Contributors

We're proud to announce that this version includes valuable contributions from:

@WebGee

  • Added interactive website selection mode
  • Implemented JSON output format
  • Added watch mode for real-time monitoring
  • Enhanced metrics and formatting

@8Dweb

  • Enhanced the original script
  • Added color-coded output
  • Created the new siteinfo.sh script
  • Improved error handling

@cPFence

Special thanks to cPFence for sharing valuable systemd-cgtop commands and monitoring tips that helped improve our understanding of system resource monitoring. Their insights about monitoring system services and identifying resource-intensive applications have been particularly helpful.

You can find the commands here:
https://community.enhance.com/d/2601-monitor-website-resource-usage-with-website-usage-tool/26
https://community.enhance.com/d/2601-monitor-website-resource-usage-with-website-usage-tool/28

Contribute to the Project

We believe in open-source collaboration! The website-usage tool is available on GitHub:

🔗 GitHub Repository

If you'd like to contribute, feel free to submit issues, or open pull requests with improvements and new features.

Conclusion

The website-usage v2 tool is an essential addition for any hosting provider looking to gain better insights into website resource consumption. With its new interactive mode, real-time monitoring, and JSON output, it's now more powerful and user-friendly than ever. Install it today and take control of your server's performance!

For any questions, feel free to reply to this thread or contribute to our GitHub repository. Happy monitoring! 🚀

    WebGee

    1. It'd be nice if only allocated CPU cores utilization could displayed instead of all cores of the server,
      (@cPFence yours use this implementation, right? I tested it already)

    2. Also IO read write remains 0 MB/s always (its working)

    1. --watch seems have some glitch, it isn't staying consistent like native watch command, --watch makes it blink every 2 seconds like full blanking out and reappears (every 2 seconds), where native watch command refreshes proper

      WebGee Good job! thanks for the initial idea, and the updated version.

        pratik_asabe
        We resolved the mentioned issues by v2.1 now

        Version 2.1

        • Fixed CPU usage calculation to show percentage based on allocated quota instead of total system CPU
        • Fixed CPU cores display to show allocated cores instead of total system cores
        • Improved watch mode functionality using native watch command for smoother updates
        • Enhanced header display with bold yellow formatting and arrow indicators
        • Fixed permission issues in watch mode by explicitly using bash
        • Fixed script path resolution in watch mode
        • Added proper error handling for watch mode execution

        8Dweb Thank you for your inspiration 😉

          WebGee made a few pull requests, no big deal, but might be useful. Cheers! I am out of here for the day!

            WebGee

            Is the utilization % like following?

            if vCPU is 2 then 100% utilization means all 2 cores are being utilized

            or

            200% means all 2 cores are being utilized

            which one is true?

              8Dweb Thank you!
              I merged two PRs and please check the other one has a comment and the other has a conflict.

              Write a Reply...
              Follow @enhancecp