Ad Widget

Collapse

alert when file age more than 1 hour

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frankcheong
    Member
    • Oct 2009
    • 73

    #1

    alert when file age more than 1 hour

    I know I can obtain the file mtime using the function vfs.file.time with mode=change. But how can I create and email alert when a specific file has not been updated for more than 1 hour?
  • frankcheong
    Member
    • Oct 2009
    • 73

    #2
    Wow, What I coincident that someone did ask that one year before.

    And it is already on the first page. Perhaps I have overlooked. Sorry about that.

    Comment

    • ItaiGanot
      Junior Member
      • May 2014
      • 4

      #3
      I think you can use my solution:
      http://stackoverflow.com/questions/2...93639_23681923

      Comment

      • blackchair
        Junior Member
        • Aug 2020
        • 2

        #4
        Originally posted by ItaiGanot
        Thank you for this script. I had to modify to make it suit with UserParameter requirement. Below is my parameter in zabbix_agentd.conf. I used the flexibler user parameter concept, here the documentation - https://www.zabbix.com/documentation...userparameters

        Code:
        UserParameter=[B]rsync[/B]fileage[*],if [ -e "$1" ]; then now=$(date +%s) && was=$(stat -c%Y $1) && elapsed=$((now - was)) && echo $elapsed; else echo 0; fi
        Restart zabbix service;
        $ sudo systemctl restart zabbix-agent.service
        and do the test and here is the result;
        Code:
        $ zabbix_agentd -t rsyncfileage[/var/log/messages]
        rsyncfileage[/var/log/messages]               [t|42]

        Once all worked, Im heading to add the item to the monitoring dashboard by following this documentation - https://www.zabbix.com/documentation...xtending_agent

        Comment

        • blackchair
          Junior Member
          • Aug 2020
          • 2

          #5
          Originally posted by blackchair

          Thank you for this script. I had to modify to make it suit with UserParameter requirement. Below is my parameter in zabbix_agentd.conf. I used the flexibler user parameter concept, here the documentation - https://www.zabbix.com/documentation...userparameters

          Code:
          UserParameter=[B]rsync[/B]fileage[*],if [ -e "$1" ]; then now=$(date +%s) && was=$(stat -c%Y $1) && elapsed=$((now - was)) && echo $elapsed; else echo 0; fi
          Restart zabbix service;


          and do the test and here is the result;
          Code:
          $ zabbix_agentd -t rsyncfileage[/var/log/messages]
          rsyncfileage[/var/log/messages] [t|42]

          Once all worked, Im heading to add the item to the monitoring dashboard by following this documentation - https://www.zabbix.com/documentation...xtending_agent
          Update;

          Now I had explored second option which using vfs.file.age, this used unixtimestamp instead of second.
          Here is the documentation that I follow - https://www.zabbix.com/documentation...zabbix_agent?s[]=vfs&s[]=file

          Comment

          Working...