Top Banner
© 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
38

Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

Jun 04, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 2: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 3: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 4: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 5: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 6: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

• Working examples are built into ACS• LOTS of examples of various SQL Statements

6

Insert From Examples

Page 7: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

• Working examples are built into ACS• Many of the examples are focused on admin tasks

7

Insert From Examples

Page 8: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation8

Insert From Examples

Page 9: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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;

Page 10: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Sample Reports

Page 11: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 12: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 13: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 14: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Job Related Sample

Page 15: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

PTF Related Sample

PTF Group currency… for multiple systems

15

Page 16: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Sample: Monitor Temp Storage Usage

• Exploits QSYS2.SYSTMPSTG (View)• Top xx Temp Storage Consumers (Jobs)

Page 17: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Storage Related Sample

Temporary storage usage

visualization

17

Page 18: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 19: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Spool Files

Reverse Engineer Spool file into PDF or Excel

19

Page 20: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

System Related

System Status… across multiple systems

20

Page 21: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 22: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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)

Page 23: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 24: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

System Related – Self Refreshing CPU Utilization

Page 25: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

System Related - Limits

System Limits by category • With drilldown to detail

25

Page 26: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

Utilities Folder

See what IBM i Services are available!

26

Page 27: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 28: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 2016 IBM Corporation

How Did We (and how could YOU) Build These?

Page 29: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 30: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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!

Page 31: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 32: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 33: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 34: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 35: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 36: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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

Page 37: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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]

Page 38: Using Sample DB2 Web Query Reports and Charts built over ...€¦ · 2 Recommended Ways to Bring an SQL Statement into Db2 Web Query •Db2 Web Query provides a GUI SQL Generator,

© 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/