Ad Widget

Collapse

Get age of latest file in folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bacteria666
    Junior Member
    • Oct 2019
    • 9

    #16
    I tried to solve and reproduce in one line over userparameter:

    Code:
    UserParameter=check.folder_age[*], CUR_TIME=$(stat --printf=%Y $1/$(ls -t $1 | head -1)) && FILE_AGE=$(($(date +%s) - $CUR_TIME)) && echo $(($FILE_AGE / 3600))
    This line return how many hours since last file modification in a given path.

    and tested by zabbix_get:
    Code:
    /var/lib/zabbix # zabbix_get -s 192.168.1.1 -k check.folder_age[/mnt/current/backup/db]
    352
    I hope I have helped someone here.

    Thanks
    Last edited by bacteria666; 21-01-2020, 21:50.

    Comment

    • frater
      Senior Member
      • Oct 2010
      • 340

      #17
      Over time (10 years) I noticed that I really need all the parameters I can give my function of latestfileage and latestfilename.
      Recently I have created an LLD that can create these items automatically by making use of discovery.
      Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

      Comment

      Working...