Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,69 +32,88 @@ If your users can access the [Sunstone ‘user’ view]({{% relref "fireedge_sun

## Calculate Monthly Reports

Before the cost reports can be seen by the users, the administrator has to generate them. To create the monthly cost reports use the `oneshowback` command or Sunstone:
Before the cost reports can be seen by the users, the administrator has to generate them. To create the monthly cost reports use Sunstone or the `oneshowback` command:

### Using oneshowback command
{{< tabpane text=true right=false >}}
{{% tab header="**Interfaces**:" disabled=true /%}}

```default
{{% tab header="Sunstone"%}}

Log into Sunstone as an administrator user and go to the Settings section. Select a start date and a end date and press Calculate showback button:

![sunstone_showback_calculate](/images/sunstone_showback_calculate.png)

{{% /tab %}}

{{% tab header="CLI"%}}

To calculate monthly reports, run the `oneshowbackp command`as the oneadmin user.

```bash
$ oneshowback calculate -h
Usage: oneshowback [options]
-s, --start TIME First month of the data
-e, --end TIME Last month of the data
```

When this command is executed, the OpenNebula core reads all the accounting records and calculates 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 is then stored in the database to be consumed with the `oneshowback list` command.

The monthly cost of each VM is calculated as the sum of:
Some examples:

* `CPU_COST` \* `CPU` \* `HOURS`
* `MEMORY_COST` \* `MEMORY` \* `HOURS`
* `DISK_COST` \* `DISK_SIZE` \* `HOURS`
* To calculate all records, starting from March up to today:

The number of hours is calculated as the total number of hours that a VM has been `active`. This accounts for every VM state that keeps Host resources secured, like `poweroff` or `suspended`, but not in `stopped` or `undeploy`.
```bash
$ oneshowback calculate --start "03/2016"
```

Optionally you can compute CPU and MEMORY cost only for VMs in `running` state, see `SHOWBACK_ONLY_RUNNING` in [oned.conf file]({{% relref "../../operation_references/opennebula_services_configuration/oned#oned-conf-default-showback" %}})
* To calculate only September:

If the time range includes the current month, OpenNebula will calculate the cost up to today’s date.
```bash
$ oneshowback calculate --start "09/2016" --end "09/2016"
```

{{< alert title="Note" color="success" >}}
There is a timer in the Front-end opennebula-showback.timer that automatically calculates the showback every day. You can check the status by running `systemctl status opennebula-showback.timer`.{{< /alert >}}
When you run this command, the OpenNebula core reads all the accounting records and calculates 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 is then stored in the database to be consumed with the `oneshowback list` command.

The `oneshowback` command can only be executed by the oneadmin user.
The monthly cost of each VM is calculated as the sum of:

Some examples:
* `CPU_COST` \* `CPU` \* `HOURS`
* `MEMORY_COST` \* `MEMORY` \* `HOURS`
* `DISK_COST` \* `DISK_SIZE` \* `HOURS`

To calculate all records, starting from March up to today:
The number of hours is calculated as the total number of hours that a VM has been `active`. This accounts for every VM state that keeps Host resources secured, like `poweroff` or `suspended`, but not in `stopped` or `undeploy`.

```default
$ oneshowback calculate --start "03/2016"
```
Optionally, compute CPU and MEMORY cost only for VMs in `running` state, see `SHOWBACK_ONLY_RUNNING` in [oned.conf file]({{% relref "../../operation_references/opennebula_services_configuration/oned#oned-conf-default-showback" %}})

To calculate only September:
Important considerations:

```default
$ oneshowback calculate --start "09/2016" --end "09/2016"
```
* If the time range includes the current month, OpenNebula will calculate the cost up to today’s date.
* There is a timer in the front-end, called `opennebula-showback.timer` that automatically calculates the showback every day. Check the status by running `systemctl status opennebula-showback.timer`
* Existing records can be re-calculated. 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 be also assigned to the new user.

{{< alert title="Note" color="success" >}}
This is a resource intensive operation. For big deployments, it is recommended to use the `--start` option to process only the last missing months.{{< /alert >}}
This is a resource intensive operation. For big deployments, add the `--start` option to process only the last missing months.{{< /alert >}}

{{< alert title="Note" color="success" >}}
Existing records can be re-calculated. 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 be also assigned to the new user.{{< /alert >}}
{{% /tab %}}
{{< /tabpane >}}

### Using Sunstone

Log into Sunstone as an administrator user and go to the Settings section. Select a start date and a end date and press Calculate showback button:
## Retrieve Monthly Reports

![sunstone_showback_calculate](/images/sunstone_showback_calculate.png)
View, as an administrator or a regular user, your monthly showback reports from Sunstone or the CLI:

## Retrieve Monthly Reports
{{< tabpane text=true right=false >}}
{{% tab header="**Interfaces**:" disabled=true /%}}

Any user or administrator can see their monthly showback reports from the CLI or Sunstone:
{{% tab header="Sunstone"%}}
1. Log into Sunstone.
2. Go to either **Users** or **Groups**.
3. Click on a user or a group.
4. Select the **Showback** tab.

### Using CLI
![showback_showback](/images/sunstone_showback.png)
{{% /tab %}}

{{% tab header="CLI"%}}

```default
```bash
## USAGE
list
Returns the showback records
Expand All @@ -118,11 +137,9 @@ list
--endpoint endpoint URL of OpenNebula xmlrpc frontend
```

### Using Sunstone
{{% /tab %}}

Log into Sunstone and go to the Users or Groups section. Click on a user or a group and select the Showback tab:

![showback_showback](/images/sunstone_showback.png)
{{< /tabpane >}}

## Disable Showback in Sunstone

Expand All @@ -135,11 +152,11 @@ info-tabs:
enabled: false
```

## Tuning & Extending
## Tuning and Extending

To integrate the showback reports with external tools, you can get the CLI output as **xml**, **json**, or **csv** data.

```default
```bash
$ oneshowback list -u cloud_user --list YEAR,MONTH,VM_ID,COST --csv
YEAR,MONTH,VM_ID,COST
2015,10,4258,1824279.62
Expand Down