Ad Widget

Collapse

File discovery based on a pattern

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    File discovery based on a pattern

    I need to monitor some files that are dynamically generated everyday.
    They all have a dynamic timestamp prefix and a constant suffix.
    Something like this:
    20220709101112_file_name.txt

    With that, I can write a simple script to find and list all the new files.
    I could use Zabbix Agent key vfs.file.get to collect the file data, but that key can only check for a single file.
    I was wondering if there is a kind of vfs.file.discovery key that uses a pattern to find files.

    Is there a key to find files based on regular expressions?
    Does anyone else needs something like that?
  • vladimir_lv
    Senior Member
    • May 2022
    • 240

    #2
    Hi!
    You can try to use features User parameters on the agent side together with some Powershell script.

    Comment

    • Semiadmin
      Senior Member
      • Oct 2014
      • 1625

      #3
      vfs.dir.get, agent 6.*

      Comment


      • markfree
        markfree commented
        Editing a comment
        Great! I'll check how deep I can go with this key. Thanks.
    • jtnfoley
      Member
      • Mar 2022
      • 76

      #4
      Any traction on this? I have this exact requirement, hoping to get time to work on this task after some higher priority project work.

      Comment

      • 3sMoney
        Junior Member
        • Jul 2023
        • 1

        #5
        we use discovery:
        system.run[find /data/logs/logname_* -maxdepth 0 -type f]


        Javascript preprocessing:
        var lld = [];
        var lines = value.split("\n");
        var lines_num = lines.length;
        for (i = 0; i < lines_num; i++)
        {
        var row = {};
        row["{#FILE}"] = lines[i]
        lld.push(row);
        }
        return JSON.stringify(lld);



        And finall item prototype:
        Name: Duration of {#FILE}
        Key: logrt[{#FILE}]

        ​system.run should be enabled on agent.

        Comment

        Working...