Xymon Mailing List Archive search

How to verify DIR content with wildcards on a Windows host?

4 messages in this thread

list Anaïs Rabinoit · Tue, 17 Apr 2018 09:27:30 +0000 ·
Hi everyone,


I have to check if a directory on a windows host contains files with a specific extension.


If it was a Unix/Linux host, i just have to write something like that i guess :

client-local.cfg :

    file:`find /path/mydir/*.tst`

analysis.cfg :

    FILE    %(/path/mydir/*.tst)    noexist


But how to do it for a Windows host? Is this possible ?


I tried this for example :


client-local.cfg :

    file:`cmd /c "dir /b /s C:\path\mydir\*.tst"`

or

    file:`cmd /c "dir /b /s \path\mydir\*.tst"`


analysis.cfg :

    FILE    "%C:\path\mydir\*.tst"    noexist


But it doesn't work :(


Regards,


Anaïs
list Zep · Tue, 17 Apr 2018 11:12:27 -0400 ·
quoted from Anaïs Rabinoit
On 04/17/2018 05:27 AM, Anaïs RABINOIT wrote:
Hi everyone,


I have to check if a directory on a windows host contains files with
a specific extension.


If it was a Unix/Linux host, i just have to write something like that
i guess :

client-local.cfg :

    file:`find /path/mydir/*.tst`

analysis.cfg :

    FILE    %(/path/mydir/*.tst)    noexist


But how to do it for a Windows host? Is this possible ?


I tried this for example :


client-local.cfg :

    file:`cmd /c "dir /b /s C:\path\mydir\*.tst"`

or

    file:`cmd /c "dir /b /s \path\mydir\*.tst"`


analysis.cfg :

    FILE    "%C:\path\mydir\*.tst"    noexist


But it doesn't work :(


Regards,


Anaïs
I'm not sure how viable it might be for your environment, but I'd
consider either installing the cygwin utilities to create a more unix
like environment or doing the heavy work with python or (for me, more
likely) perl.   either way would likely require some additional/external
tools which may have different implications for different people/groups.


C:\Users\a959784>c:\cygwin64\bin\bash.exe -c "/bin/ls /cygdrive/c/tmp/*.txt"
/cygdrive/c/tmp/snip.txt
/cygdrive/c/tmp/greenfelder.txt
/cygdrive/c/tmp/typescript.txt
/cygdrive/c/tmp/key.txt

-- 
public gpg key id: 0x5B8147CB
list Zak Beck · Tue, 17 Apr 2018 15:52:04 +0000 ·
Hi

You don't say which Windows client you're using (BBWin or XymonPSClient) but I don't think either of them will understand your backtick syntax (certainly XymonPSClient does not support the use of backticks).

XymonPSClient will understand wildcards and will enter subfolders if you specify a wildcard in a directory position. Unfortunately it will not recurse so you would need an entry for each level of subfolder you may encounter.

So you may need several entries in client-local.cfg:

file:c:\temp\test\*.txt
file:c:\temp\test\*\*.txt
file:c:\temp\test\*\*\*.txt
and so on...

It may be simpler to use an external script - the external script approach can be used in either BBWin or XymonPSClient.

Zak
quoted from Anaïs Rabinoit

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Anaïs RABINOIT
Sent: Tuesday, 17 April 2018 10:28
To: xymon at xymon.com
Subject: [External] [Xymon] How to verify DIR content with wildcards on a Windows host?


Hi everyone,


I have to check if a directory on a windows host contains files with a specific extension.


If it was a Unix/Linux host, i just have to write something like that i guess :

client-local.cfg :

    file:`find /path/mydir/*.tst`

analysis.cfg :

    FILE    %(/path/mydir/*.tst)    noexist


But how to do it for a Windows host? Is this possible ?


I tried this for example :


client-local.cfg :

    file:`cmd /c "dir /b /s C:\path\mydir\*.tst"`

or

    file:`cmd /c "dir /b /s \path\mydir\*.tst"`


analysis.cfg :

    FILE    "%C:\path\mydir\*.tst"    noexist


But it doesn't work :(


Regards,


Anaïs


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com
list Anaïs Rabinoit · Thu, 3 May 2018 08:29:10 +0000 ·
Hi,


Thanks for your time,


I use BBWin as Windows client, but here the host is in central mode, so the configuration come from the Xymon server itself. I try to keep it that way, without adding an external script on each windows hosts or modify the BBWin config on each, since it hasn't only one host concerned ...


I tried the wildcard version first, it didn't work, then i saw this on the manpage client-local.cfg:


FILE CONFIGURATION ENTRIES
A file monitoring entry is used to watch the meta-data of a file: Owner, group, size, permissions, checksum etc. It looks like this:

    file:/var/log/messages[:HASH]

The file:FILENAME line defines the filename of the file to monitor. As with the "log:" entries, a filename enclosed in backticks means a command which will generate the filenames dynamically. The optional [:HASH] setting defines what type of hash to compute for the file: md5, rmd160, sha1, or sha256, sha512, sha224, or sha384. By default, no hash is calculated.
NOTE: If you want to check multiple files using a wildcard, you must use a command to generate the filenames. Putting wildcards directly into the file: entry will not work.


with this example with directories :


dir:`find /var/log -maxdepth 1 -type d`


So, since i've searched what command i have to use with a Windows host ...


Anaïs
quoted from Zak Beck


De : Beck, Zak <user-aada0fa38bf8@xymon.invalid>
Envoyé : mardi 17 avril 2018 17:52
À : Anaïs RABINOIT; xymon at xymon.com
Objet : RE: How to verify DIR content with wildcards on a Windows host?

Hi

You don’t say which Windows client you’re using (BBWin or XymonPSClient) but I don’t think either of them will understand your backtick syntax (certainly XymonPSClient does not support the use of backticks).

XymonPSClient will understand wildcards and will enter subfolders if you specify a wildcard in a directory position. Unfortunately it will not recurse so you would need an entry for each level of subfolder you may encounter.

So you may need several entries in client-local.cfg:

file:c:\temp\test\*.txt
file:c:\temp\test\*\*.txt
file:c:\temp\test\*\*\*.txt
and so on…

It may be simpler to use an external script – the external script approach can be used in either BBWin or XymonPSClient.

Zak

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Anaïs RABINOIT
Sent: Tuesday, 17 April 2018 10:28
To: xymon at xymon.com
Subject: [External] [Xymon] How to verify DIR content with wildcards on a Windows host?


Hi everyone,


I have to check if a directory on a windows host contains files with a specific extension.


If it was a Unix/Linux host, i just have to write something like that i guess :

client-local.cfg :

    file:`find /path/mydir/*.tst`

analysis.cfg :

    FILE    %(/path/mydir/*.tst)    noexist


But how to do it for a Windows host? Is this possible ?


I tried this for example :


client-local.cfg :

    file:`cmd /c "dir /b /s C:\path\mydir\*.tst"`

or

    file:`cmd /c "dir /b /s \path\mydir\*.tst"`


analysis.cfg :

    FILE    "%C:\path\mydir\*.tst"    noexist


But it doesn't work :(


Regards,


Anaïs


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com