This windows vbs script obtains the number of files in a directory and the age of the oldest (or youngest) file. This template was originally developed to monitor FTP folders to verify that files were being transferred out of the source directory. It has since been used repeatedly in our environment for numerous purposes.
It returns two statistical values:
- AGE - this is the age of the oldest/youngest file in MINUTES
- COUNT - this is the number of files in the folder
It returns two messages:
- AGE - "Oldest file is ${FILENAME} and was last modified on: ${DATETIME}"
- COUNT - "${COUNT} ${EXT} files were found in the directory."
- If the File Extension input is not used the value will not appear in the message.
- If the File Extension input is not used the value will not appear in the message.
The script takes 5 input values.
- ${IP} - This Solarwinds variable will use the IP Address of the node being polled.
- "\D$\Folder" - This is the network path to the folder. Use a single '\' at the beginning and do not use an ending '\'
- ${USER} - This Solarwinds variable will use the username of the selected monitoring credential for the component.
- ${PASSWORD} - This Solarwinds variable will use the password of the selected monitoring credential for the component
- "TXT" - This is the file extension to limit the script to. This value is case sensitive. Use CAPS if unsure.
With in the script are two commented lines that mark code that can be commented out to ignore the file extension check and use all files in the folder. There is also a comment to mark where and how to change this script to find the youngest file in the folder.
((IMPROVEMENT LIST: 1) Build IF ${EXT} is blank logic to prevent the need to comment code. 2) build oldest/youngest logic into script input value ))