Skip to content

Instantly share code, notes, and snippets.

@forstie
Created February 11, 2022 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forstie/2110dd70bd82ef3320e163c98b059677 to your computer and use it in GitHub Desktop.
Save forstie/2110dd70bd82ef3320e163c98b059677 to your computer and use it in GitHub Desktop.
The request... return a simple to understand dashboard showing the basic storage detail, by database, with a percentage of storage used.
--
-- Subject: Dashboard the storage capacity, including percentage used
-- Author: Scott Forstie
-- Date : February 11, 2022
-- Features Used : This Gist uses asp_info
--
--
-- Capacity numbers are in MB units.
-- https://www.ibm.com/docs/en/i/7.4?topic=services-asp-info-view
--
select RDB_NAME, TOTAL_CAPACITY,
TOTAL_CAPACITY_AVAILABLE,
TOTAL_CAPACITY - TOTAL_CAPACITY_AVAILABLE as storage_used,
decimal((decimal(TOTAL_CAPACITY - TOTAL_CAPACITY_AVAILABLE, 63,2)) /
decimal(TOTAL_CAPACITY, 63,2),5,2) as percent_capacity_used
from qsys2.asp_info where asp_number = 1 or asp_state = 'AVAILABLE';
@sriedmue79
Copy link

I'm getting PERCENT_CAPACITY_USED 0.00 with that query. Below seems to work, although I can't quite follow how/why:
select RDB_NAME,
TOTAL_CAPACITY,
TOTAL_CAPACITY_AVAILABLE,
TOTAL_CAPACITY - TOTAL_CAPACITY_AVAILABLE as storage_used,
decimal((decimal(total_capacity - total_capacity_available, 63, 4) /
decimal(total_capacity))
* 100, 5, 2) as percent_capacity_used
from qsys2.asp_info where asp_number = 1 or asp_state = 'AVAILABLE';

@forstie
Copy link
Author

forstie commented Feb 11, 2022

My colleague had the same problem. :)
Look under your JDBC configuration and make sure that the divide scale isn't set to zero.

@sriedmue79
Copy link

Hmm, indeed it was set to zero but I changed it and reconnected, and still have the same issue!

@forstie
Copy link
Author

forstie commented Feb 12, 2022

Did you save the JDBC configuration?
You might have more than one, so also take care to look at the bottom of your Run SQL Scripts window to see which one is currently in use.
Lastly, if your ACS isn't at 1.8.8.0, update it to be current.
I tried changing my precision from 5 to 0 and saw the same thing you noted above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment