I have written a
SCRI-EXEC VARA-JOBS combo for checking file system space on our AE server hosts.
UC4.CHECK_FILESYSTEM_SPACE.SCRI:SET &Filesystem# = "/var"
:SET &VarHnd# = PREP_PROCESS_VAR(UC4.AE_SERVER_FILESYSTEM_INFO.VARA_EXEC)
:PROCESS &VarHnd#
: SET &Line# = GET_PROCESS_LINE(&VarHnd#)
: SET &FreeSpace# = GET_PROCESS_LINE(&VarHnd#,4)
: SET &FreePrecent# = GET_PROCESS_LINE(&VarHnd#,5)
:ENDPROCESS
:CLOSE_PROCESS &VarHnd#
:PRINT "File system &Filesystem# has &FreeSpace# (&FreePrecent#%) free space."
OutputU00007000 'UC4.AE_SERVER_FILESYSTEM_INFO.JOBS' activated with RunID '0267982522'.
U00020408 File system /var has 552M (8.9G%) free space.
How does it work? Well, the VARA is an EXEC VARA that passes along the
&Filesystem#
variable to a JOBS object.
UC4.AE_SERVER_FILESYSTEM_INFO.VARA_EXEC
https://us.v-cdn.net/5019921/uploads/editor/r8/xti39yx0pz4e.png" width="441">
The
UC4.AE_SERVER_FILESYSTEM_INFO.JOBS job performs three steps:
- Pre-process: Read the
&Filesystem#
variable - Process: Run the
df
command on the file system specified in the&Filesystem#
variable, and convert the output to a format that is easily parsed by PREP_PROCESS_REP. - Post-process: Parse the output and create a new data sequence with the results, passing along this data sequence to the calling EXEC VARA.
Pre-process:READ &Filesystem#,,
Process df -h &Filesystem# | grep -v Mounted | sed 's/ \+/;/g'
Post-process!Verify that the job ran successfully.
:SET &RC# = GET_UC_OBJECT_STATUS(, , "RETCODE")
:PRINT "Job RC: &RC#"
:SET &Output_Delimiter# = ";"
:IF &RC# = 0
: SET &PPR_ReportType# = "REP"
: SET &PPR_Filter# = "*&Filesystem#*"
: SET &PPR_Def1# = "COL=DELIMITER"
: SET &PPR_Def2# = "DELIMITER=@;
: INCLUDE UC4.EXEC_VARA_TOOL.CREATE_DATA_SEQUENCE_FROM_JOB_OUTPUT.JOBI
:ELSE
: PRINT
Job ended in error."
: INCLUDE UC4.EXEC_VARA_TOOL.CREATE_DATA_SEQUENCE_WITH_ERROR_MESSAGE.JOBI
:ENDIF
The JOBIs do most of the work. I’ll include all of the objects in an XML attachment.
The
original genesis of this was my frustration at the fact that when we
enable AE tracing the trace file can quickly fill up the target file
system, and the Automation Engine is not clever enough to stop writing
traces before this happens. Now that I have a general-purpose VARA for
checking the available space in a file system, I can insert periodic
checks into the scripts that we use to capture traces. If the target
file system is beginning to get full, we can automatically disable
tracing.
Ideas for further generalizing this approach:
- Pass the target agent or agent group name as parameter.
- Pass the command to run as as a parameter.
- Pass the arguments for PREP_PROCESS_VAR as parameters