Showback
The showback toolset reports resource usage cost, and allows the integration of chargeback and billing platforms. The toolset generates reports using the information gathered from HyperCloud.
Setting the cost
Each VM Template can optionally define a cost (see table below for attribute syntax descriptions). The cost is defined as cost per CPU per hour, and cost per memory MB per hour. The cost units are abstract and their equivalence to monetary units or other cost metrics require definition on a per deployment case.
Attribute | Description | Mandatory |
---|---|---|
MEMORY_COST | Cost of each memory MB (or GB) per hour | NO |
CPU_COST | Cost of each CPU per hour | NO |
DISK_COST | Cost of each disk GB per hour | NO |
#*******************************************************************************
# Default showback cost
#-------------------------------------------------------------------------------
# The following attributes define the default cost for Virtual Machines that
# don't have a CPU, MEMORY or DISK cost. This is used by the oneshowback
# calculate method.
#*******************************************************************************
DEFAULT_COST = [
CPU_COST = 0,
MEMORY_COST = 0,
DISK_COST = 0
]
# Should showback calculation count only running VMs.
# If 'no' showback will include also reserved CPU and MEMORY, e.g. VM states
# POWEROFF or SUSPENDED
SHOWBACK_ONLY_RUNNING = "no"
Calculate monthly reports
If order for standard users to view the cost reports, an administrator will need to generate them. To create the monthly cost reports, use the hypercloud showback
command:
$ hypercloud showback calculate -h
Usage: hypercloud showback [options]
-s, --start TIME First month of the data
-e, --end TIME Last month of the data
Once the command is executed, the HyperCloud core will read all the accounting records, and calculate the total cost for each month. The records include the total cost of the month, and basic information about the VM and its owner. This information will be stored in the database and can be accessed via the hypercloud showback list
command.
The monthly cost of each VM is calculated as the sum of:
- CPU_COST * CPU * HOURS
- MEMORY_COST * MEMORY * HOURS
- DISK_COST * DISK_SIZE * HOURS
The number of hours is calculated as the total number of hours that a VM has been running. The time a VM occupies another state; such as, pending, poweroff, or stopped does not count towards the cost calculus.
If the time range includes the current month, HyperCloud will calculate the cost up to today's date. Depending on your reporting requirements, administrators may choose to leave the current month out of the showback records, or to update it daily, or hourly. Either way, the records will need to be recalculated when the month ends, in order to display that month's total costs. This operation can be performed easily via a cron job.
The hypercloud showback
command can only be executed by the oneadmin
user.
A few examples of using the command:
To calculate all records, starting from March up to today:
To calculate only the month of August:
Warning
This operation is resource intensive. For larger deployments, it is recommended to use the --start
option to process only the last missing months.
Existing records can be recalculated. This can be useful to update old records when a VM is renamed, or the owner is changed. In this case, the cost of previous months will also be assigned to the new user.
Retrieve monthly reports
Administrator and standard user accounts have access to view their monthly showback reports via the dashboard CLI or web GUI.
## USAGE
list
Returns the showback records
valid options: start_time, end_time, userfilter, group, xml, json, verbose, help, version, describe, list, csv, user, password, endpoint
## OPTIONS
-s, --start TIME First month of the data
-e, --end TIME Last month of the data
-u, --userfilter user User name or id to filter the results
-g, --group group Group name or id to filter the results
-x, --xml Show the resource in xml format
-j, --json Show the resource in json format
-v, --verbose Verbose mode
-h, --help Show this message
-V, --version Show version and copyright information
--describe Describe list columns
-l, --list x,y,z Selects columns to display with list command
--csv Write table in csv format
--user name User name used to connect to HyperCloud
--password password Password to authenticate with HyperCloud
--endpoint endpoint URL of HyperCloud API frontend
Disable showback in dashboard GUI
Showback reports can be disabled in any of the dashboard web GUI views by modifying the yaml
file of those views. These files can be found on the path /etc/one/sunstone-views
. Simply set the showback feature to false, as seen in the snippet below:
Tuning and extending
In order to easily integrate the showback results with external tools, the formatting of the CLI output can be requested as xml
, json
, or csv
.