Ad Widget

Collapse

Monitoring a txt file with changed name every day

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Delu
    Junior Member
    • Nov 2024
    • 1

    #1

    Monitoring a txt file with changed name every day

    Hey everyone,
    Im new here and at Zabbix and trying to grasp all of the information.

    At my work I need to monitor a text file for a certain line but the text file name change according the day it is made on with a date. as example EODPROCESS-20241120.log
    Ive been trying to do an item : vfs.file.contents[C:\Office\Log\EodProcess,EODPROCESS-,,,,,,,86400,]
    but as it seems its going for the oldest file and not just the one that have been made today and show an error of too much parameters.

    Any idea how should I write it so it will monitor the last file that has been made?
    Thanks in advance and to all the community here with all the information you give.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    vfs.file.contents only takes hardcoded filename as parameter. And returns whole file content.
    If you need to look for a specific line in a file, use logrt item, where you can use filename with regex and it will read the latest file, that matches that regex... If it changes everyday, it will read a new file every day...

    logrt[file_regexp,<regexp>,<encoding>,<maxlines>,<mode>, <output>,<maxdelay>,<options>,<persistent_dir>]
    logrt[C:\Office\Log\EodProcess\EODPROCESS-.*\.log,<your search pattern>]

    Comment

    • troffasky
      Senior Member
      • Jul 2008
      • 568

      #3
      It is a shame that {TIME} cannot be used in an item key, because you could have used macro formatting to craft the item key to match the filename.

      "Is there a file named like the current date?" seems like an obvious thing to want to do.

      Comment

      Working...