Ad Widget

Collapse

Monitor a directory, only a specific file should exists.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juanpablo
    Junior Member
    • Feb 2023
    • 2

    #1

    Monitor a directory, only a specific file should exists.

    Hi,

    I would like to monitor a directory, only file1.txt should exists, all other should give an error.
    Example.
    /tmp/dir/file1.txt

    I can do:
    vfs.dir.count[/tmp/dir/]
    if count is more than one, then give an error.

    Is there another way? like:
    1. Get the list of files inside the directory, then compare, if file is not equal to "file1.txt" then throw an error.
    2. Get the count of files in the directory other than "file1.txt", count should be zero.

    any help is appreciated.

    Thanks.​
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    The vfs.dir.count key accepts regular expressions as parameters describing which objects to consider and which not.

    vfs.dir.count[dir,<regex_incl>,<regex_excl>,<types_incl>,<types_ excl>,<max_depth>,<min_size>,<max_size>,<min_age>, <max_age>,<regex_excl_dir>]​

    You can configure your item to count other files by excluding file1.txt from the count.

    Comment

    Working...