Usage Accounting

What is Usage Accounting?

Cloudmin checks the state of all virtual systems every 5 minutes and collects their status (up or down), assigned RAM, CPU limit, CPU load and disk space. Each sample is recorded in an internal database, and can be used to generate usage totals over an accounting period (such as a week or month). This can then be used to charge customers based on the actual resources used by their system or systems.

The accounting period over which usage is display is the same one used for bandwidth monitoring, set at Cloudmin Settings -> Bandwidth Monitoring. The default is the current month, but it can be changed to the current day, week, or any number of days in the past. In the latter case, the period is actually a sliding window of time instead of fixed non-overlapping blocks.

Usage Accounting Examples

Imagine a virtual system that has 512MB of RAM, 1 GB of disk and a CPU limit of 50%, which has been up for 1 hour a day over the last month, and used an average of 10% CPU during that time. Cloudmin would calculate its resource usage as follows :

  • System uptime : 30 hours
  • Memory used : 512MB x 30 hours = 15 GB hours
  • CPU allocated : 50% x 30 hours = 1500 percent hours
  • CPU used : 10% x 30 hours = 300 percent hours
  • Disk allocated : 1GB x 24 hours x 30 days = 720 GB hours

Note that disk use is still counted even when the system is down, as the space is still consumed on the host system. For Xen systems Cloudmin considers the disk space assigned and used to be the same, as free space on a disk image cannot be used by other systems. For OpenVZ containers it tracks the disk limit and disk usage separately.

Extracting Usage Information

The simplest place to see usage for a virtual system is on the Edit System page, in the Resource usage section. If you need to extract this for billing purposes, you can use the list-systems API call with the multiline parameter, which will include the current accounting period's usage in the output. To select a previous period, use the period-ago parameter following the a number of weeks or months in the past.

To get individual usage samples for a system, use the list-usage API command. For example, you could call this from the command line like so :

# cloudmin list-usage --host xencentos.home
xencentos.home
Start              End                Up?  Memory     CPU    Load   Disk
17/Oct/2009 23:50  18/Oct/2009 00:40  Yes  768 MB     100%   8%     11 GB
18/Oct/2009 00:40  18/Oct/2009 00:45  Yes  768.17 MB  100%   40%    11 GB
18/Oct/2009 00:45  18/Oct/2009 11:00  No   -          -      -      -
18/Oct/2009 11:00  18/Oct/2009 11:50  Yes  768 MB     100%   21%    11 GB

It takes start and end parameters to select a specific date range to display samples for. Sample are aggregated by Cloudmin where possible, so a long period of downtime or consistent CPU load will appear as a single row possibly spanning many hours.

Accounting and System Owners

Cloudmin combines the usage for all virtual systems each owner manages and computes a total usage for each owner. For example, if an owner had two systems with 512MB RAM and 1GB disk each that were up for 2 and 3 days respectively over the week and used 10% CPU on average, his usage would be :

  • Uptime : 2 x 24 + 3 x 24 = 125 hours
  • Memory used : 2 x 24 x 512MB + 3 x 24 x 512 = 62.5 GB hours
  • CPU used : 2 x 24 x 10% + 3 x 24 x 10% = 125 percent hours
  • Disk allocated : 2 x 24 x 7 = 336 GB hours

To see usage for an owner, click on his name in the System Owners list and open the Usage by all owned systems section. This is also available from the list-owners API command. How you use this information is up to you, but it could be used for usage-based billing for VPS hosting customers.