Linux-Unix File Count

This template returns the number of files on the target computer.

Prerequisites: SSH and Perl installed on the target server.

Credentials: Root user on target server.


Monitored Components

Linux-Unix File Count

This monitor returns the number of files on the target computer.

Note: Before using this monitor, the correct arguments should be set. This monitor requires the following arguments:


perl ${SCRIPT} path_to_file1 [path_to_file2] ...
where
path_to_file1
This is full path to the target file or files. Regular expressions are allowed.
[path_to_file2] ...

Additional arguments allow the monitor to get statistics for additional target files. The resulting statistics will be shown as the total number of all files in all arguments.

Following is an example using the Scripts Arguments field:

perl ${SCRIPT}  /tmp/prod*.log
perl ${SCRIPT}  /tmp/prod*.log /tmp/prod*.err /var/log/status*

Last updated 12/2/2014

  • Two notes:

    1. I was able to run this script as a non-root user with no issues. You probably shouldn't say you require root if you don't actualy require root. You just need permission to run perl and read access to the folder you're taking inventory from.

    2. I'm trying to monitor a very large directory that temporarily holds files in queue to be processed so I gave the argument /path/to/queue/* and it worked great, until my queue went over 20,000 or so, then the component returned "sh: /usr/bin/perl: Argument list too long" and the application went into Unknown status. This is because the kernel limits the shell argument string length, and passing the name of every file in a large directory as an argument string can easily blow past that limit (see: perl: Argument list too long​, linux - Argument list too long error for rm, cp, mv commands - Stack Overflow ). I tried using this monitor instead, which required me to hard-code the path I want to monitor in the script (not a huge issue for my use case), and it worked fine: AIX-Unix Directory File Count Monitoring

  • I believe the macros you are looking for are listed below.

    ${N=SwisEntity;M=ComponentAlert.ComponentMessage}

    ${N=SwisEntity;M=MultipleStatisticData.NumericData}

    ${N=SwisEntity;M=MultipleStatisticData.Label}

    ${N=SwisEntity;M=MultipleStatisticData.StringData}

    ${N=SwisEntity;M=MultipleStatisticData.Name}

    ${N=SwisEntity;M=ComponentAlert.StatisticData}

  • I'd like to display the statistic data this script gathers in outbound alerts via the Alert Manager and outbound email. I'm not sure which variable to select when using the Insert Variable option in the edit Email Action dialog. Based on what I see in the UI this would be "Statistic" or "Statistic Message". Can anyone tell me where to find this value or what SQL Variable I need to use to define it? Thanks!