Ad Widget

Collapse

Trigger for file not being generated on the first of the month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matt.envsys
    Junior Member
    • Jul 2021
    • 10

    #1

    Trigger for file not being generated on the first of the month

    Hi there,

    We have a host running Ubuntu server that should be generating a file on the first of each month and we would like Zabbix to alert us if the file is older than one month. Annoyingly, months don't have a consistent number of days so I am struggling to build a trigger to alert us if there is a problem.

    We are running Zabbix 7.0.4 and the item in question is:

    Code:
    vfs.file.time[/home/pathto/file.txt]
    For example if the file is generated on the 1st of February and on the 1st of March if the creation time is still the 1st of February then Zabbix should alert us that something has gone wrong.

    I've looked at the docs and see information for time shift in the trigger expression but it contains a warning that "time shift specified in months (M) and years (y) is only supported for trend functions" and I don't think that this is item is using a trend.

    Is anyone able to provide advice on building a trigger or is there a more appropriate item key to use in this case other than the unixtime age of the file?

    Thank you
  • kyus
    Senior Member
    • Feb 2024
    • 172

    #2
    Hey!

    I think you could use a custom interval of the type "scheduling" in your item and set it to "md1" so the item will only collect data at the first day of the month (you can define an specific hour or minutes aswell, check it here https://www.zabbix.com/documentation...stom_intervals).

    This way you could use the following expression in your trigger:
    Code:
    dayofmonth()=1 and (now()-last(//vfs.file.time[/home/pathto/file.txt]))/86400>20
    It will alert if today is the first day of the month and the file is older than 20 days. You could theorically use something like, older than 2 days since you would be collecting data only one time per month anyways...

    Maybe there's a better way to accomplish what you desire, but that's what I could think of...

    If you need to collect data from this item more often, I would suggest creating a script on your server that checks this condition and send the result to a trapper item. Then you could create a way simpler trigger to evaluate it.

    Hope this helps you
    Last edited by kyus; 12-11-2024, 20:13.

    Comment

    • matt.envsys
      Junior Member
      • Jul 2021
      • 10

      #3
      Hi kyus, thanks for that. I'll set it up and see what happens

      Comment

      Working...