© 2016 IBM Corporation Using Sample DB2 Web Query Reports and Charts built over IBM i (SQL) Services – for System Administrators For those customers with DB2 Web Query Version 2.2.1
© 2016 IBM Corporation
Using Sample DB2 Web Query Reports and Charts built over IBM i (SQL) Services – for System Administrators
For those customers with DB2 Web Query Version 2.2.1
© 2016 IBM Corporation
Table of Contents
1. IBM i Services
2. Sample Reports
3. How you can build DB2 Web Query reports/charts over these services
© 2016 IBM Corporation
• What: Use SQL, SQL DDL and SQE to provide alternatives to IBM i APIs and CL Commands
• Dawn of the 1st IBM i Service (2013) – QSYS2.PTF_INFO
o Alternative to the DISPLAY PTF (DSPPTF) command
o Proof of concept that SQL Views paired with SQL UDTFs provide significant value, for low cost
• IBM i Services take root (2015)
o Enhancements delivered with every Technology Refresh
• IBM i Services begin to be used as a modernization technology (2017)
o Brings the power of SQL to SQL Based Reporting or Monitoring Tools
• IBM i Services consist of 13 topical categories (2019)
o And they keep on coming!
IBM i Services – A Brief History
3
© 2016 IBM Corporation
Services in 4Q/2017:
• Syslog detail returned from DISPLAY_JOURNAL & HISTORY_LOG_INFO
• ASP_INFO
• ASP_VARY_INFO
• JOB_QUEUE_INFO
• STACK_INFO
• And more…
http://ibm.biz/Db2foriServices
Services in 3Q/2018:
• JOB_DESCRIPTION_INFO
• ACTIVE_JOB_INFO enhancements
• NETSTAT_INFO & NETSTAT_JOB_INFOenhancements
• And more…
SF99703 Level 16SF99704 Level 1
7.3 – TR67.4 – GA2018 2019
Services in 2Q/2019:
• DATA_AREA_INFO
• ASP_JOB_INFO
• MESSAGE_FILE_DATA
• SYSTOOLS.FIRMWARE_CURRENCY
• SYSTOOLS.SPLIT
• SYSTOOLS.SPOOLED_FILE_DATA
• IBM i 7.4 only services
• And many enhanced services
SF99702 Level 20SF99703 Level 8
7.2 – TR87.3 – TR4
7.2 – TR97.3 – TR5
SF99702 Level 23SF99703 Level 11
IBM i Services Timeline
4
© 2016 IBM Corporation
• Strategic solution for Accessing and Managing your IBM i • Runs on:
• Windows• Mac • Linux – All distributions
• Database tools• The “best” 5250 Emulator• Integrated File System• Print
❑Download it here:
5
Access Client Solutions – Don’t have it?
http://ibm.biz/IBMi_ACS
© 2016 IBM Corporation
• Working examples are built into ACS• LOTS of examples of various SQL Statements
6
Insert From Examples
© 2016 IBM Corporation
• Working examples are built into ACS• Many of the examples are focused on admin tasks
7
Insert From Examples
© 2016 IBM Corporation8
Insert From Examples
© 2016 IBM Corporation9
Insert From Examples
SELECT USER_NAME, SUM(SIZE) AS TOTAL_SPOOL_SPACE
FROM TABLE(QSYS2.OBJECT_STATISTICS('QSYS ', '*LIB')) AS a,
TABLE(QSYS2.OBJECT_STATISTICS(a.objname, 'OUTQ')) AS b,
TABLE(QSYS2.OUTPUT_QUEUE_ENTRIES(a.objname, b.objname,
'*NO')) AS c WHERE USER_NAME NOT LIKE 'Q%'
GROUP BY USER_NAME
ORDER BY TOTAL_SPOOL_SPACE DESC LIMIT 10;
© 2016 IBM Corporation
Sample Reports
© 2016 IBM Corporation
The A-HA Moment!
• If IBM i Services are delivered as SQL Views, User Defined Table Functions, or
Stored Procedures and SAMPLE SQL is provided in ACS…..
AND
• If Db2 Web Query can consume results from SQL Views, SQL Scripts or Stored
Procedures
© 2016 IBM Corporation
Sample Reports can Answer Questions Like This
• Are you current with PTF Groups?
• Query the audit journal
– Is QSECOFR being over used?
• How close are you getting to database/system limits (thresholds)?
• How much temp storage are we using and who is using it ?
• Do I have impending license expiration issues?
• Which network connections are sending the most data?
• How can I get a spoolfile into a PDF or Excel format?
12
© 2016 IBM Corporation
What Do You Get?
• IBM i Administration Samples folder
– Use as is
– Modify as you like
– Learn how you can build your own
• Updated EZ-Install TEST DRIVE walks
you through these and MORE
© 2016 IBM Corporation
Job Related Sample
© 2016 IBM Corporation
PTF Related Sample
PTF Group currency… for multiple systems
15
© 2016 IBM Corporation
Sample: Monitor Temp Storage Usage
• Exploits QSYS2.SYSTMPSTG (View)• Top xx Temp Storage Consumers (Jobs)
© 2016 IBM Corporation
Storage Related Sample
Temporary storage usage
visualization
17
© 2016 IBM Corporation
Sample: Monitoring Output Queues and Spool Files
• Exploits QSYS2.OUTPUT_QUEUE_ENTRIES Service (View)• Create top xx reports by output queue or user name
Top 10 output
queues by #
of spool files
Top 10
users by #
of spool
files
© 2016 IBM Corporation
Spool Files
Reverse Engineer Spool file into PDF or Excel
19
© 2016 IBM Corporation
System Related
System Status… across multiple systems
20
© 2016 IBM Corporation
Sample: System(s) Status
• Can support multiple LPARs/Servers
– System Status
– Top 10 Reports per LPAR
• Exploits
QSYS2.SYSTEM_STATUS_INFO view to
get information about your system
• Uses an SQL Procedure to assemble
information gathered from various LPARs
via DRDA and present them together
• Stored Procedure for this provided
• Exception Reporting highlighted in RED
• Could add to an HTML Dashboard and
enable Auto Refresh
© 2016 IBM Corporation
Remote LPAR/Server Access
Note: For the System(s) status report/dashboard to pull in utilization metrics from other systems
or LPARs in your network, you must:
• Ensure that those systems are identified in the Remote Database Directory Entry in IBM i (CL
Command WRKRDBDIRE
• Users must have a server authentication entry that will work for them. Use CL Command
DSPSVRAUTE to check and ADDSVRAUTE to add a server authentication entry for a set of
users that will work for those user profiles via parameter USRPRF(*CURRENT)
© 2016 IBM Corporation
• Exploits QSYS2.ACTIVE_JOB_INFO (User Defined Table Function) • Auto Refresh
Summary info
by subsystem
Top xx Jobs by:
• CPU time
• I/O count
• Temp.
Storage
Sample: Subsystem Status and Top 10 Jobs by CPU, I/O, and Temp Storage
© 2016 IBM Corporation
System Related – Self Refreshing CPU Utilization
© 2016 IBM Corporation
System Related - Limits
System Limits by category • With drilldown to detail
25
© 2016 IBM Corporation
Utilities Folder
See what IBM i Services are available!
26
© 2016 IBM Corporation
Utilities Folder: Create Date Dimension Table
Db2 Web Query EZ-Install Utilities
SUCCESS!
For More Info on this, view COMMON Webinar: Speed Dating with the Db2 Web Query Date Dimension
Table or refer to the Db2 Web Query Nuts and Bolts Redbook
© 2016 IBM Corporation
How Did We (and how could YOU) Build These?
© 2016 IBM Corporation
Learning Point: Db2 Web Query Meta Data (Synonyms)
SYNONYMS
Files/TablesSQL Views
SQL Scripts Aggregated Data
(EVIs, MQTs)Programs (defined
as Stored Procs)
Date AttributesUser Defined
Functions
SQL Functions
Non Db2 for i
Data Sources
Excel
Calculated Fields
DATA SOURCES
Single
Version
of the
TRUTH
Reports/Dashboards/Visualizations or even a Data Warehouse
Data Warehouse
BIETL
Query/400
© 2016 IBM Corporation
Starting Point: ACS Insert From Examples
• Run it! But you may want to consider….
• This example only returns two columns
– If you’re doing this for a report or
dashboard maybe you want more
information
• The example groups by USER_NAME
– Probably OK
• Th example leaves out ‘Q%” users
– May be ok, may not
• Orders by TOTAL_SPOOL_SPACE
– Probably Ok, but you may want the ability
to columns to sort in your report!
30THE TAKE AWAY: Don’t let your SQL limit what you can do in your app using it!
© 2016 IBM Corporation
2 Recommended Ways to Bring an SQL Statement into Db2 Web Query
• Db2 Web Query provides a GUI SQL Generator, however, there are times
(like this) where the SQL statement is already built and you just want to
leverage that
1. Create an SQL View object in Db2, build “synonym” over the view, build
report over synonym
– NOTE: Many IBM i Services are already delivered as a VIEW !!!
2. Upload the SQL Script into Db2 Web Query and build synonym over the
script, build report over the synonym
© 2016 IBM Corporation
What is the process?
• If Service is shipped as a VIEW, use it as is
– Just build a synonym over the view
• If shipped as a UDTF, you can use the sample
SQL to:
– Create an SQL view or place the SQL in a
text file then
– Create your synonym
• If shipped as a stored procedure, just make
sure the stored procedure can return a result
set
– Then build your synonym over the Stored
Procedure
© 2016 IBM Corporation
Building a Synonym (meta data representation of data source)
• Create (one time) a DB2 Web Query
Synonym (meta data) over the
prepared service
– View or SP or uploaded SQL Script
o A two minute (if that) exercise
© 2016 IBM Corporation
What is the process?
• The Synonym is a representation of the underlying file (or view/SQL in this
case). It does not contain data, but is a layer in between report authoring tool
and the data in the tables/files to simplify report authoring
• You could:
– Add additional calculated fields
– Change field names/data types
– Join this file to another in the same synonym
– Add date attributes (e.g., Day of week)
• “Sample Data” allows you to see the results
© 2016 IBM Corporation
Once the Synonym is in Place, Start Building your Report
• Start building your report over the new
Synonym
– Standard report or chart, or other
visualizations
– Output could be HTML, Excel, Active
Reports (good for mobile devices),
PDF, PowerPoint
– Could schedule the reports to run in
the background and email or send to
network drive (or IFS)
– Add desired reports to dashboard
o Could even set up a timed refresh
for an interactive dashboard
© 2016 IBM Corporation
Learn More about Creating Synonyms
• When you install or upgrade with EZ-Install, it includes 2 tutorials:
– TEST DRIVE
o Build your first report, build your first synonym
– InfoAssist +
o Learn more about report building
• Interested in getting some assistance?
– http://ibm.biz/db2ilabservices
© 2016 IBM Corporation
What about History and Trending?
• Today, the reports are strictly point in time (exception being the self refreshing CPU
Utilization dashboard)
• If you’re at 7.3, it would be very easy to set up a timed job to collect data via IBM i
Services and leverage a temporal table if desired
Or….
• No matter what release you’re at, use DB2 Web Query’s DataMigrator to automate
that process of collecting and loading a history table
• Reports/dashboards could be updated then to include trending information based on
timestamps in collections
• If you’d like some help with this, let us know: [email protected]
© 2016 IBM Corporation
Additional Links
• Db2 Web Query for i Website
– Ibm.biz/db2webqueryi
• Db2 Web Query for i Wiki
– Ibm.co/db2wqwiki
• Db2 Web Query Getting Started Enablement:
– https://ibm.biz/db2wqconsulting
• Db2 Web Query Version 2.2.1
– http://ibm.biz/db2wqv221blog
– Videos: http://ibm.biz/db2wq-221-videos
• EZ-Install
– http://Ibm.biz/db2wqezinstall-info
• Recent Webinars
– New Version 2.2.1 Visualizations: http://ibm.biz/db2wq-221-videos
– COMMON Advanced Reporting Tips Virtual Conference
http://www.common.org/virtualcommunity
Follow Db2 Web Query guy Doug Mack
on twitter at @mckdrmoly or blog
http://db2webqueryi.blogspot.com/