In addition to the standard resource metrics offered by Abiquo, you can define your own custom accounting resource metrics. These metrics can be defined from existing data in the Abiquo database or from another source. For example, if you have access of OpenFlow or NetFlow network data for your Abiquo environment, you can import consolidated network data into a table/schema that is accessible to the Abiquo database. Then you can create a custom resource definition so that Abiquo will reference the network data and create network usage records in the Abiquo accounting_event_detail table. This will extend the current accounting system to account for network bandwidth usage.
Any custom resources defined are processed when the above ‘core’ resources have been processed for a given account period. At that point, the accounting process looks for a well-known custom stored procedure, which if found, is invoked with details of the account period being processed.
The CUSTOM_GENERATE_ACCOUNTING_DATA_V1 stored procedure is the entry point for
generating custom accounting data. The procedure should be defined as follows:
Note that there is a template version of the CUSTOM_GENERATE_ACCOUNTING_DATA_TEMPLATE_V1 procedure defined within the kinton_accounting schema, which can be used as the basis of any custom procedure.
When invoked, the custom stored procedure has access to the temporary accounting_event_... tables, and also to the (empty) tmp_accounting_event_detail table which holds unconsolidated temporary data. The custom stored procedure may access any Abiquo database data that it likes (as it is running in the context of the Abiquo system) and use it populate the unconsolidated temporary table. Subject to availability and configuration, it can also be used to access non-Abiquo DBMS data too. Finally, as the last thing it does, the custom procedure should call the accounting procedure used to flush the data from the temporary table into the main accounting table, which will automatically consolidate data in the process.
Any custom accounting resources must be uniquely identifiable by their resource name and resource ID. Therefore, in order to identify custom usages and to avoid clashes with any further extensions to the core Abiquo accounting resources, custom resource IDs MUST be allocated an ID in the numeric range -1 through -127.
Additionally, note that resource name is stored in the accounting_event_detail table (and its temporary equivalent table) using a name ID rather than the resource name itself. Therefore, you should ensure that the resource name is correctly added to the name table using the ‘ABQ_OBJECT_NAME_TO_ID’ function (please see the example below to see how the function can be used).
Finally, you should ensure that the names of any referenced VMs, VApps, VDCs, and Enterprises exist in the accounting name tables - this should not be a problem if all of the ‘core’ accounting resources are active, since they will populate the name tables for you - but if they are disable then be sure to add the names to the appropriate name tables.
The accounting process now facilitates flexible accounting periods and granularities of resource usage. Clearly, with custom accounting metrics, resource usage can be accounted in an appropriate mechanism for that resource.
Since the accounting granularity is never smaller than one hour, internally, Abiquo represents the granularity in hours, and this can provide an easy way to calculate a count of resource usage for a resource, assuming that the resource has been in use for the entire accounting period. For example, to count the number of CPUs used by a given VM over the account period, you can perform the following simple calculation:
The Abiquo product will never overwrite or update any existing copy of a custom stored procedure during an upgrade. However, in the case that the existing procedure is known to be no longer compatible with the newer version of Abiquo, then the expected version of the stored procedure will be incremented and the old procedure will no longer be called - the old procedure will need to be adjusted to the required format of the new stored procedure before it will be invoked by the accounting procedure.
This section defines a simple customer accounting stored procedure, which should demonstrate how to use existing Abiquo DBMS data to generate additional accounting usage metrics. The example below shows how the data in the acccounting_event_vm table can be used to generate an accounting metric to count which indicates the number of VMs hosted in an Abiquo HA enabled environment (which may require a premium charge). The example procedure is given below: