Ad Widget

Collapse

Monitoring of the txt file (modification time) and changing the file name every month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nolaan
    Junior Member
    • Mar 2018
    • 17

    #1

    Monitoring of the txt file (modification time) and changing the file name every month

    Hello,

    I monitor the log file last modification time.
    Everything works fine, I have the item key:
    vfs.file.time[/var/log/external/2021/billing,modify]


    And trigger expression:
    fuzzytime(/Logserver/vfs.file.time[/var/log/external/2021/billing,modify],2820)=0


    But I would like to make some modification
    in syslog-ng I would like to set the file name to be changed every month and year
    Currently I have this:
    Code:
    source ttyS0 { file ("/dev/ttyS0"); };
    destination ttyS0 { file("/var/log/external/2021/billing"); };
    log { source(ttyS0); destination(ttyS0); };
    I want to have this:
    Code:
    source ttyS0 { file ("/dev/ttyS0"); };
    #destination ttyS0 { file("/var/log/external/$YEAR/billing-$YEAR-$MONTH"); };
    log { source(ttyS0); destination(ttyS0); };

    But I have no idea how to monitor it in Zabbix
  • Nolaan
    Junior Member
    • Mar 2018
    • 17

    #2
    Originally posted by Nolaan


    I want to have this:
    Code:
    source ttyS0 { file ("/dev/ttyS0"); };
    #destination ttyS0 { file("/var/log/external/$YEAR/billing-$YEAR-$MONTH"); };
    log { source(ttyS0); destination(ttyS0); };

    I tried
    vfs.file.time[/var/log/external/{{TIME}.fmttime(%Y)}/billing-{{TIME}.fmttime(%Y-%m)},modify]
    but it doesn't work

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #3
      If you look into docs, then it might save your testing time ..
      Do you see here "Item key parameters"? No...


      {TIME} → Trigger-based notifications and commands
      → Problem update notifications and commands
      → Discovery notifications and commands
      → Autoregistration notifications and commands
      → Internal notifications
      Current time in hh:mm:ss.

      Unfortunately, vfs.file.time only accepts full paths. so you cannot even use regex here.. Find a way to keep "year" and "month" in user macros and update them every month. That's pretty much your only option here...

      Comment

      • jankowalski
        Junior Member
        • May 2022
        • 2

        #4
        You may want to use discovery rules to get current year and month.

        Comment

        Working...