Automatically deleting files on a given location if the size limit is exceeded

Discussion created by Antoine_Sauteron_1266 on Aug 2, 2016
You may want to monitor disk space at a given location, and delete files or trigger alerts if the size limit has been exceeded.
This can be done quite simply with a file event (EVNT.FILE) and a bit of scripting.

1) Create a file event


2) Adjust its settings

  • Host: the agent on which the file storage should be checked.
  • Login:login objectthat contains credentials to connect to this agent.
  • Path: the location that should be monitored. You can choose to include sub-directories.
  • Event > Check : Choose "PATH_SPACE_USED" ">" and define the size limit. The event will trigger the script contained in the post-process (!Process) tab if the condition is verified.

3) Define actions that should be triggered in the !Process tab

Example 1 : Trigger a notification (which will need to be created separately) with ACTIVATE_UC_OBJECT.
Example 2 : trigger an OS command with PREP_PROCESS. Here, we want to delete all .txt files.
:SET &HND#=PREP_PROCESS("NB120003_WS112_WX6_01_SAA","WINCMD",,"CMD=del c:\temp\*.txt","UC_LOGIN=@LOGIN.SAA")