Open Source for IBM Z and LinuxONE

Open Source for IBM Z and LinuxONE

Open Source for IBM Z and LinuxONE

Your one-stop destination to share, collaborate and learn about the latest innovations in open source software for s390x processor architecture (IBM Z and LinuxONE)

 View Only

Mainframe Automation with IBM ZOAU and IBM OEF's jq

By Igor Todorovski posted Mon March 17, 2025 09:55 AM

  

For far too long, using z/OS often felt like stepping back in time.

Then came IBM Z Open Automation Utilities (ZOAU), which modernized z/OS with easy to use UNIX commands and JSON output.

Next up was IBM Open Enterprise Foundation for z/OS (OEF) which delivered 11 very popular open source tools, including bash, git, curl, vim and most recently jq.

Now, you can combine the power of ZOAU and efficiency of jq to process JSON data directly on z/OS UNIX!

Why JSON and why jq?

JSON (JavaScript Object Notation) has become the de-facto standard for data exchange in modern applications. ZOAU leverages JSON to represent z/OS resources, making it easier to work with data programmatically. However, raw JSON output can be verbose and difficult to parse. That's where jq comes in.

jq is a lightweight and flexible command-line JSON processor. It allows you to slice, filter, map, and transform JSON data with ease. By combining ZOAU's JSON output with jq's processing capabilities, you can unlock a new level of efficiency and flexibility when interacting with z/OS.

Why is this important?

ZOAU was created to bridge the gap between traditional z/OS automation methods and modern scripting practices. Historically, automating tasks on the mainframe often required specialized languages like REXX and CLIST. ZOAU provides a set of command-line utilities and Python APIs that allow you to interact with z/OS resources using familiar scripting techniques within z/OS UNIX System Services. A key feature of ZOAU is its ability to output data in JSON format, making it easily consumable by modern tools.

IBM Open Enterprise Foundation for z/OS further enhances this by bringing a curated collection of popular open-source tools and runtime environments to z/OS UNIX. This includes essential utilities and languages that developers expect in modern environments, such as jq, bash, curl, git and others. These tools are supported and maintained by IBM.

The inclusion of jq in Open Enterprise Foundation allows us to leverage ZOAU's JSON output and process it with a powerful and widely-used JSON processor directly on z/OS.

Extending IBM ZOAU with jq

Datasets are the fundamental unit of data storage on z/OS, similar to files on other operating systems. Let’s look at common tasks that are made simpler with jq and ZOAU.

  1. Filtering Datasets:

    Imagine you need to find all partitioned datasets (PO) within a specific high-level qualifier. Partitioned datasets (PDS or PO) are a type of dataset that contains members, similarly to directories that contain files. Previously, you might have written a complex REXX or CLIST script to accomplish this. Now with ZOAU and jq, a simple one-liner can achieve the same result:

    dls -j -l IBMUSER.* | jq -r '.data.datasets[] | select(.dsorg == "PO") | .name'

    Output:

    IBMUSER.USER.C
    IBMUSER.USER.CNTL
    IBMUSER.USER.HLASM
    IBMUSER.USER.JCL
    IBMUSER.USER.OBJ
    IBMUSER.USER.TEXT
  2. Extracting Dataset Attributes:

    Do you quickly need to retrieve the record format (RECFM) of a specific dataset? The record format describes the structure of records within a dataset, like fixed or variable length records. jq makes it easy:

    dinfo -j -l 'IBMUSER.USER.C' Z2B08A | jq -r '.data.datasets[0] | .recfm'

    Output:

    FB
  3. Finding the IPL parmlib dataset

    Imagine you need to quickly identify the parmlib dataset your z/OS system was IPLed from. It’s a simple one-liner with ZOAU and jq. This command directly extracts the IPL parmlib dataset name:

    zinfo -t ipl -j json | jq -r '.data.ipl_info.load_param_dsn'

    Output:

    SYS1.IPLPARM
  4. Getting the CPC Model and Type

    Do you need to know the model and type of the machine your z/OS system is running on? In the past, obtaining this detail might have involved system programming calls or parsing complex system messages. With ZOAU and jq you can get it with a single command:

    zinfo -t cpu -j json | jq -r '.data.cpu_info | "CPC Model: \(.cpc_nd_model), Type: \(.cpc_nd_type)"'

    Output:

    CPC Model: T01, Type: 008561
  5. Finding the z/OS Product Version and Release

    Want to quickly determine the precise version and release of z/OS your system is running? You can use this command:

    zinfo -t sys -j json | jq -r '.data.sys_info | "z/OS Version: \(.product_version), Release: \(.product_release)"'

    Output:

    z/OS Version: 03, Release: 01
  6. Displaying System Time

    opercmd -j "d t" | jq -r ' "Command: \"\(.command)\", Output: \(.data.output)"'

    Output:

    Command: "D T", Output: IEE136I LOCAL: TIME=21.27.45 DATE=2025.065 UTC: TIME=02.27.45 DATE=2025.066

Conclusion

The integration of IBM Z Open Automation Utilities (ZOAU) with IBM OEF's jq JSON processor allows users to easily interact with and process z/OS data using familiar UNIX commands with the versatile jq tool, streamlining automation tasks and enhancing productivity.

This article was written by Igor Todorovski, Sachin T, and Anthony Giorgio.

1 comment
32 views

Permalink

Comments

Mon March 17, 2025 10:49 AM

Really nice story!

I particularly like "JSON (JavaScript Object Notation) has become the de-facto standard for data exchange in modern applications" - but this is also an opportunity to emphasize the difference between JSON and YAML, JSON is for machine-to-machine (application-to-application) exchange, but as soon as people are involved then it has to be YAML, not least so that we can leave clues to future selves in the comments!