How to obtain system status information such as system asp usage in a program
AS/400 system administrators are very concerned about the growth of ASP space in the system.
When the space is full, security issues such as system down will occur. The system asp space is not exactly the same as the hard disk space. If the system only configures one ASP partition, the system asp space and the hard disk space are empty.
Is equivalent. If multiple ASP partitions are configured, ASP is only a partition of ASP 1. % System ASP viewed by the wrksyssts command
Used indicates the ASP space usage of the system.
There are two system values related to system asp space usage: qstglowlmt and qstglowacn. The qstglowlmt system value sets the minimum percentage of Hard Disk Space warning lines. For example, if it is set to 5, it indicates that the ASP usage of the system has reached 95%, which causes security actions. The security actions are set by the system value qstglowacn.
Can you automatically obtain the system asp usage in the program, so that when the hard disk space reaches a dangerous value, the program will issue an alert in advance? Or are some security actions automatically executed in the program, such as automatically clearing outdated files or stopping some programs to reduce the ASP usage of the system?
OS/400
The system provides an API function called qwcrssts. This function can extract the system status information seen by the wrksyssts command and extract more
Some other system information that the wrkstssts command cannot see. You can call this API in RPG, C, Cl, and other programs to obtain system information. For detailed instructions on using this function, see
System api reference.
Next I will use a Cl program that actually gets the ASP usage of the system as an example to see how to use qwcrssts.
Qwcrssts
There are five entry parameters. The first parameter is the output parameter that receives the system status information and stores the returned system status information block. The system status information block stores various system status information according to a certain structure.
. The second parameter is the input parameter, which specifies the length of the first block variable that accepts system status information. The type is binary. The third parameter indicates that the system information in the first parameter system status information block is stored.
Structure name. There are three optional structures: ssts0100, ssts0200, and ssts0300. The fourth parameter indicates whether to reset the status statistics.
* Yes. The fifth parameter is the error code.
In the CL program in this example, specify the ssts0200 system status information structure. The 53-57 characters in this structure are %
System ASP
Used. This value is the normal percentage except the upper 10000. In the program, first extract the qstglowlmt system value and specify 100-qstglowlmt-2 as the program warning line, for example
If qstglowlmt is set to 5, the program sends a message to the user when the system asp to 93%. Set the ASP status return value to 1 for other programs to call.
When the program determines that ASP status returns 1, it will know that ASP space utilization has reached the warning line, and some security actions need to be performed.
/* ===================================================== ===================================== */
/**/
/* Optional /*-----------------------------------------------------------------------------------------------------------------*/
/* Program name: monasp */
/* Created by: blog Liou */
/* Created Date: 2003.11.11 */
/* Description: monitor ASP used */
/* Monaspper: (100-stglowlmt)-2 */
/* ===================================================== ===================================== */
PGM parm (& aspflag)
Dcl var (& aspflag) type (* char) Len (1)
Dcl var (& format) type (* char) Len (+
Value ('ss0200 ')
Dcl var (& lencript) type (* char) Len (4) +
Value (x' 00000044 ')
Dcl var (& sysnam) type (* char) Len (
Dcl var (& sysusec) type (* char) Len (4)
Dcl var (& sysuse) type (* dec) Len (9 2)
Dcl var (& sysinfo) type (* char) Len (6
Dcl var (& errcode) type (* char) Len (+
Value (x' 0000000000000000 ')
Dcl var (& resetsy) type (* char) Len (10) value (* yes)
Dcl var (& qmnper) type (* dec) Len (9 2) value (1000000)
Dcl var (& qalarm) type (* dec) Len (9 2) value (20000)
Dcl var (& stglowlmt) type (* dec) Len (9 2)
Dcl var (& sndmsg) type (* char) Len (10)
Chgvar VAR (& aspflag) value ('0 ')
Rtvsysval sysval (qstglowlmt) rtnvar (& stglowlmt)
Chgvar VAR (& stglowlmt) value (& stglowlmt * 10000)
Chgvar VAR (& qmnper) value (& qmnper-& stglowlmt)
Chgvar VAR (& qmnper) value (& qmnper-& qalarm)
Call PGM (qwcrssts) parm (& sysinfo & lename & format +
& Resetsy & errcode)
Monmsg msgid (cpf0000) exec (goto cmdlbl (errend ))
Chgvar VAR (& sysusec) value (% SST (& sysinfo 53 4 ))
Chgvar VAR (& sysuse) value (% binary (& sysusec ))
Chgvar VAR (& sysnam) value (% SST (& sysinfo 17)
If cond (& sysuse> & qmnper) Then (DO)
Chgvar VAR (& sndmsg) value (& sysuse)
Sndpgmmsg MSG (& sysnam * bcat '-(ASP used +
Percent) * 10000 = '* bcat & sndmsg) +
Tomsgq (smdob)
Sndpgmmsg MSG ('***** system over monasp !!! ') +
Tomsgq (myuser) msgtype (* info)
Chgvar VAR (& aspflag) value ('1 ')
Enddo
Goto cmdlbl (end)
Errend: sndpgmmsg MSG ('error on qwcrssts call') +
Tomsgq (myuser) msgtype (* info)
End: endpgm
This program can also be used together with some alarm programs. For example, when the system asp space reaches the warning line, the program calls some dialing programs and sends short messages to the system administrator's mobile phone.
If another display file is designed, the system status information obtained by qwcrssts, such as the System ASP usage, CPU usage, and number of message processes displayed by the system, is displayed, we have implemented a monitoring tool for system status information.