The following question was posed on Twitter last week:
For the life of me I can't figure how to get an IBM i machine type programmatically. Suggestions?
While I was looking in all the places I could think of ex-IBM-er Dawn May provided an answer I could not better:
SELECT DOSNAM,DOSTYP,DOSMOD FROM QPFRDATA.QAPMHDWR FETCH FIRST ROW ONLY |
The columns are:
- DOSNAM Server (partition) name
- DOSTYP Machine
- DOSMOD Model number
This returns the following results:
DOSNAM DOSTYP DOSMOD ------ ------ ------ DEV730 8286 41A |
The same can be achieved in a less elegant two step process:
- Use the Display Hardware Resources command, DSPHDWRSC, to generate an outfile
- SQL Select over the outfile
DSPHDWRSC TYPE(*PRC) OUTPUT(*OUTFILE) OUTFILE(QTEMP/@DSPHDWRSC) SELECT POSNAM,POSTYP,POSMOD,PRCFCD FROM QTEMP.@DSPHDWRSC LIMIT 1 POSNAM POSTYP POSMOD ------ ------ ------ DEV730 8286 41A |
I think you'll agree that is not as neat as Dawn's solution.
Looking on all of the IBM i partitions I have access to on some I found the library QPFRDATA did not exist. The file QAPMHDWR could be found in other libraries. And on two QPFRDATA library was empty, and there was no QAPMHDWR file.
I came up with another method that uses no outfile. It uses the QLZARCAPI API to write machine type to the job log, then the JOBLOG_INFO table function to retrieve what was written to the job log.
When I call the QLZARCAPI API I can go to the job's job log to see all the information I ever wanted to know about this partition, including the machine type in the "SYSTEM INFO" row:
> CALL QSYS/QLZARCAPI SYSTEM INFO -> SYSTEM SERIAL NUMBER: XX-XXXXX. SYSTEM TYPE- MODEL: 8286- 41A. PROCESSOR FEATURE CODE: EPXK. PROCESSOR GROUP: P05. MAX PHYSICAL PROCS IN SYSTEM: 4. CONFIGURABLE PROCS IN SYSTEM: 4. PARTITION INFO -> NETWORK NAME: DEV730. PARTITION NAME: DEV730. PARTITION ID: 2. SHARING TYPE: SHARED. SHARING MODE: CAPPED. MIN PROCESSING CAPACITY: 0.10. DESIRED PROCESSING UNITS: 0.40. MAX PROCESSING CAPACITY: 2.00. ENTITLED PROCESSING CAPACITY: 0.40. MIN VIRTUAL PROCESSORS: 1. DESIRED VIRTUAL PROCESSORS: 1. MAX VIRTUAL PROCESSORS: 4. ONLINE VIRTUAL PROCESSORS: 1 PROCESSOR POOL INFO -> NUMBER OF VIRTUAL PROCESSOR POOLS CONFIGURED: 1. CURRENT PROCESSOR POOL ID: 0. MAXIMUM PROCESSING UNITS FOR PROCESSOR POOL 0: 4. |
If I go to the JOBLOG_INFO table function I can see the same results:
SELECT ORDINAL_POSITION AS "OP", MESSAGE_TEXT FROM TABLE(QSYS2.JOBLOG_INFO('448996/SIMON/QPADEV0001')) A WHERE ORDINAL_POSITION >= 118 OP MESSAGE_TEXT --- --------------------- 118 CALL QSYS/QLZARCAPI 119 SYSTEM INFO -> SYSTEM SERIAL NUMBER: XX-XXXXX . SYSTEM... 120 PARTITION INFO -> NETWORK NAME: DEV730. PARTITION NAME ... 121 PROCESSOR POOL INFO -> NUMBER OF VIRTUAL PROCESSOR POOL... |
Note: In the example above I have only listed the rows generated by the QLZARCAPI API.
Looking at the row that starts with "SYSTEM INFO" I can see that the machine and model number start at position 69, and is nine characters long.
If I put that all together I get the following in a source member I can execute using the Run SQL Statement command, RUNSQLSTM:
01 CALL QSYS2.QCMDEXC('CALL QSYS/QLZARCAPI') ; 02 CREATE TABLE QTEMP.MACHINE 03 (SYSTEM_TYPE_MODEL) 04 AS 05 (SELECT 06 CAST(SUBSTR(MESSAGE_TEXT,69,9) AS CHAR(9) CCSID 37) 07 FROM TABLE(QSYS2.JOBLOG_INFO('*')) A 08 WHERE SUBSTR(MESSAGE_TEXT,1,11) = 'SYSTEM INFO' 09 ORDER BY ORDINAL_POSITION DESC 10 LIMIT 1) 11 WITH DATA ; |
Line 1: Call QLZARCAPI.
Line 2: I am going to put my result in a table.
Line 3: The table will contain just one row.
Lines 5 – 10: The SQL Select to get the information from the joblog.
Line 6: I am substring-ing the machine and model number from the MESSAGE_TEXT column. I need to cast it to CCSID 37, to convert it from CCSID 1200 to something I can read.
Line 7: As I am retrieving from this job's joblog I can give the job name in the table function as "*".
Line 8: I need to find the row that starts with "SYSTEM INFO".
Line 9: I need to sort the results from the table function in descending order so I will find the most recent row first.
Line 10: I only want one row, the most recent returned.
Line 11: Without this there will be no data in the table.
The result:
SYSTEM_TYPE_MODEL ----------------- 8286- 41A |
Again this is not as elegent as Dawn's solution. But when you cannot find the QAPMHDWR you need an alternative way to get to the information you desire.
This article was written for IBM i 7.3, and should work for some earlier releases too.
Great article. I've used the "CALL QSYS/QLZARCAPI" for years to help various IBM i support have info on hand at a moments notice. While a bit ugly format wise, I would copy the output from it to a word doc and quickly format it.
ReplyDeletei use also CALL PGM(QSYS/QLZAVXFR) PARM(5051) in order to have OS 400 number active cores.
DeleteFor those of us lucky enough to have TAATOOL, RTVSYSD is hard to beat. System name, type, model, serial number, number of processors, proc feature, OS version and other info is returned in one invocation.
ReplyDeleteHi Simon, not necessarily any easier that what you have shown, but just for completeness, you can get the machine type and model (and a whole lot more) from the _MATMATR1 API.
ReplyDeleteBruce Vining provided some info on the API in: https://www.mcpressonline.com/programming/apis/the-api-corner-accessing-system-information
You can even use this API to determine if the partition is in 'Normal' or 'Manual' mode.
Hi Simon,
ReplyDeleteIf QPFRDATA does not exist, check to see if QMPGDATA does. For complicated reasons, sometimes the Collection Services library is QMPGDATA. Alternatively, prompt on the CFGPFRCOL command which will show the configured library for Collection Services - it can be changed to something else. Finally, if Collection Services has been turned off (and thus, no QAPM* files), it needs to be turned back on; CFGPFRCOL followed by STRPFRCOL.