- Best practice
- This article explains how to leverage Monitoring Studio to obtain the number of files stored in a specific directory.
- File Monitoring
Monitoring Studio: Counting the Number of Files in a Specific Directory
KB1028 - Feb 15, 2010
The objective is to precisely collect the number of files stored in a given directory by using Monitoring Studio.
With Monitoring Studio KM for PATROL v8.x
First, make sure that Monitoring Studio KM for PATROL is properly installed and running in your PATROL environment. Then, follow the instructions below:
- Right click on the Monitoring Studio KM, then go to [KM Commands] [New] [Folder Monitoring] and enter the path of the folder to monitor.
Note: For example, to count only the “*.exe” files, enter a mask in the second text box. Leave the field empty to count all the files. In the example below our application instance is named after the path we are monitoring: C:\tmp.
- Then set a folder monitoring with these options: FileCount, FolderSize and eventually LastModifiedElapsedTime.
You will obtain the following monitoring configuration:
As you can see the number of files reported present in that folder is indicated on the graph and corresponds to the actual number of files stored in the folder.
With BMC Performance Manager Express Monitoring Studio
The folder monitoring option is not yet implemented within BMC Performance Manager Express for Monitoring Studio. Therefore, the following workaround works best with the version 2.5.07. We strongly advise you to upgrade to BMC Performance Manager Express Monitoring Studio 2.5.07 if running an older PM version (P1064: BPM-Express-MonitoringStudio-2.5.07.par.zip).
We’ve attached some screenshots to assist you with the configuration of this workaround solution (Folder_1.jpg to Folder_4.jpg).
To monitor a folder in PORTAL, you must first add the class “Studio – Remote Command Execution and Analysis” to the monitored element/server. Then use the command line below (or any other command of your choice) to check the size of a given folder.
With C:\tmp on a Windows machine for instance :
With /tmp on a Linux/Unix machine. The first column contains the number of files, so you will have to set a numerical extraction on it :
ls /tmp | wc
Same as above, but list hidden files as well :
ls –a /tmp | wc
Note that PORTAL replaces empty spaces with “ÿ”, thus you must use the “-c” option (in red) to disable the separator.
Expected output for a windows machine:
Finally, set a numerical extraction (child class) and edit its properties. Make sure that the expected format matches the command output by running the command at least once on the machine. So you can choose the appropriate format, as the output might differ on your server.
The picture below shows the monitoring and the expected display output.
- Log File Monitoring: Searching for a String and Triggering Alarm for each Occurrence
- Monitoring Studio: Extracting Values from a Multiple-Line File
- Monitoring Studio: File Monitoring on Dynamic Files
- Monitoring Studio: Getting Automatically Notified by Email for an Error in a Log File
- Monitoring Studio: Increasing Maximum File Size Limit
- Monitoring Studio: Monitoring Remote Log/Flat Files
- Monitoring Studio: Unexpected Output for a String Search