$ bosh -e ENVIRONMENT -d pivotal-container-service/DEPLOYMENT-ID ssh pivotal-container-service/VM-ID7. Log in to the billing database using the following command:
$ mysql -h IP-ADDRESS -u billing -p billingWhen prompted by the command line, enter the MySQL billing database password you recorded earlier.
MariaDB [billing]> select * from pods;
To calculate total pod consumption in hours for a given time period, run the following query:
SET @beginning_of_period = '2018-11-26 00:00:00'; SET @end_of_period = '2018-11-27 00:00:00'; SELECT SUM(TIMESTAMPDIFF(HOUR, GREATEST(first_seen, @beginning_of_period), LEAST(last_seen, @end_of_period))) AS pod_hours FROM pods WHERE first_seen < @end_of_period AND last_seen > @beginning_of_period;
Modify the values for the beginning and end periods as needed. The pod hours calculated are rounded down to the nearest hour. For example, if a pod runs for 1 hour, 59 minutes, and 59 seconds, it is billed for 1 hour only.
SET @beginning_of_period = '2018-11-26 00:00:00'; SET @end_of_period = '2018-11-27 00:00:00'; SELECT id, @start_of_billing := GREATEST(first_seen, @beginning_of_period) AS start_of_billing, @end_of_billing := LEAST(last_seen, @end_of_period) AS end_of_billing, TIMESTAMPDIFF(HOUR, @start_of_billing, @end_of_billing) AS pod_hours FROM pods WHERE first_seen < @end_of_period AND last_seen > @beginning_of_period;
SET @beginning_of_period = '2018-11-26 00:00:00'; SET @end_of_period = '2018-11-27 00:00:00'; SELECT service_instance_id, namespace, SUM(TIMESTAMPDIFF(HOUR, GREATEST(first_seen, @beginning_of_period), LEAST(last_seen, @end_of_period))) AS pod_hours FROM pods WHERE first_seen < @end_of_period AND last_seen > @beginning_of_period GROUP BY service_instance_id, namespace