I need to be able to get logmon to check a directory for a specific file daily wiht the file containing that days date, e.g. test_20180717.log, and raise an alarm if the file contains 0 bytes. In this same directory there could be lots of other files with similar format name (though not the exact same date) and there could be numerous files with 0 bytes. How can this check be accomplished ?
To obtain the alarm, you would need to execute a batch file containing commands that provide the output you are interested in. A logmon watcher can then be setup to scan that output e.g.
1/ Create a batch file somewhere on the server where the file needs to be checked.
In that file add the following lines but change the second line to point to the directory where the test_yyyymmdd.log files are expected to be:
for /f "tokens=*" %%a in ('echo test_%date:~-4,4%%date:~-7,2%%date:~-10,2%.log') do set _CmdResult=%%a
Save the file.
2/ In the logmon probe, create a new profile, mode command and point it to the batch file (use encoding UTF-8).
Under that profile, create a Format rule with:
Next, create a watcher profile with:
and an appropriate message to send on match.
On the Advanced tab, select the previously created format definition in the Restrict to Format Defintion.
3/ Once done, Apply that but then ensure the probe is Deactivated/Activated.
Note: Check the format that the DATE command returns on your system and adjust the format in the batch file as required.
The batch command pulls todays date from the system and constructs a file name from that and saves that to a variable.
The dir command then lists that file in the directory.
The logmon format definition restricts the match expression search to between the Directory and free words in the output.
The match expression looks for the 0 bytes string and raises the alarm if a match is found.