This is a handy tool for administrators keeping an eye on managed and semi-managed cPanel hosting servers. It currently does the following:
- Enumerates all accounts and domains on a list of cPanel servers
- Skips any domains that don't resolve in DNS to the that particular server
- Retrieves the text content of the web site and logs it into a file
- Saves a screenshot of the site
- Compare the contents of each web site with its previous snapshot
It will eventually be extended to:
- If a significant difference is encountered, generate an email that contains an alert, as well as the before and after screenshots
Strategies for evaluating differences might include:
- Comparison of first 1KB only
- Percentage difference of entire page
- Scanning for warning/error messages, e.g. PHP notices
In order to make operation of the tool as automatic as possible, I'd prefer not to have to configure the strategy on a per-domain basis - hopefully I'll come up with something that is generic enough to apply to all of the sites I look after.
It's intended to be run periodically from cron, but you may also wish to invoke it after server-wide PHP or Apache upgrades, WordPress core and plugin upgrades, account moves between servers, and so on.
- Create an API Token in WHM - not entirely sure which permissions are needed yet
- Copy servers.yml.sample to servers.yml file and fill in the blanks
The application logs all check results to a SQLite database in addition to the text file output. This enables future web interface functionality for viewing changes over time.
The database file location can be configured in servers.yml:
:config:
:database: site_checker.db # defaults to site_checker.db if not specifiedThe database contains a check_results table with the following columns:
timestamp- ISO 8601 timestamp of the checkhost- WHM server hostnameuser- cPanel usernamedomain- Domain namecode- HTTP status code or error messagelocation- Final URL after redirectsdigest- SHA256 hash of page contenttxt_status- Text comparison status (different/deleted_duplicate)txt_previous_run- Previous run date serialscreenshot_hash_distance- Perceptual hash distance between screenshotsscreenshot_status- Screenshot comparison status (different/deleted_identical)screenshot_previous_run- Previous run date serial for screenshot
Run the script:
uv run site-checker.pyOr make it executable and run directly:
chmod +x site-checker.py
./site-checker.py