Quantcast
Viewing all articles
Browse latest Browse all 20490

Count of files matching a filename pattern.

We have a request from a server owner to monitor for the count of files matching a specific filename pattern, and to generate an alert when that count is exceeded. Currently that group is handling this via batch file, and would prefer to handle it through SAM for obvious reasons.


We need to generate alerts for the following file name patterns:

  1. For XML49 files the share used:  \\servermame\path\to\file\49*OUT.*
    For XML81 files the share used: \\servermame\path\to\file\81*OUT.*
  2. XML49 file threshold is 10 and for XML81 the threshold is 50.
  3. They have been monitoring every 10 minutes but this can be changed.

 

The batch file they are currently using is as follows:

 

@ECHO OFF

REM J. Rissmiller Monitor XML49/81 Files in Specified Directory

REM v1.0: 140626 - Initial Release of Monitoring

REM v1.1: 140703 - Split output to separate text files, reformat date/time and add Tab character for Excel

 

SETLOCAL

SETLOCAL ENABLEDELAYEDEXPANSION

 

REM COUNT XML49 FILES

SET count49=0

for %%o IN (\\servermame\path\to\file\49*OUT.*) DO (

                REM echo %%o

                SET /A count49=count49 + 1

)

 

 

 

REM COUNT XML81 FILES

SET count81=0

for %%o IN (\\servermame\path\to\file\81*OUT.*) DO (

                REM echo %%o

                SET /A count81=count81 + 1

)

 

REM Calculate Timestamp and Send Counts to Monitor49.txt & Monitor81.txt

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)

For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a:%%b)

 

 

 

echo %mydate% %mytime% %count49% >> monitor49.txt

echo %mydate% %mytime% %count81% >> monitor81.txt

ENDLOCAL ENABLEDELAYEDEXPANSION

ENDLOCAL

 

Is anyone doing something similar? If so, would you be able to share a script with me and/or tell me how I might go about accomplishing this? I've posted this in the SAM forum; we also have NPM and LEM at our disposal if either of those help.


Any guidance is greatly appreciated. Thanks.


Viewing all articles
Browse latest Browse all 20490

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>