cPanel: Adding custom metrics to count for reseller use of packages
Overview
By default cPanel module for HostBill exposes "Reseller accounts" metered billing / metric variable, which can be used to bill for total number of account's reseller creates.
Since 2023-02-13 release module adds capability of defining own per-package metrics. Example: you can create metric which will count total number of packages reseller (his clients) created using package "default"
Adding json file for metrics storage
- Create new json file in includes/modules/Hosting/cpanel2/custommetrics directory
- Copy contents of includes/modules/Hosting/cpanel2/custommetrics/sample.json to your custom file to be used
- Update file contents to match your list of packages in cPanel installs
- Ensure your variable names (keys in json structure) are prefixed with "reselleraccounts_"
- If your cPanel package is named ie: "large", key should be: "reselleraccounts_large"
includes/modules/Hosting/cpanel2/custommetrics/sample.json file:
{ "reselleraccounts_default": { "name": "Reseller accounts default", "unit": "accounts", "description": "Count of reseller owned accounts using default package." }, "reselleraccounts_small": { "name": "Reseller accounts small", "unit": "accounts", "description": "Count of reseller owned accounts using small package." } }
Result of custom json metrics
When json file is valid, metrics from it will become available to be used in all products using cPanel2 module. Metrics/variables below were generated out of includes/modules/Hosting/cpanel2/custommetrics/sample.json file