Ad Widget

Collapse

Check Newest file in folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lukasz1984
    Junior Member
    • Mar 2019
    • 4

    #1

    Check Newest file in folder

    Hi,

    How to create item and trigger to check if newest file in folder is older than 60 min? Do I have to use powershell script?

    $dir = "..."
    $latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
    $filedate = $latest.name
    $lastWrite = (Get-Item "...").LastWriteTime
    $timespan = new-timespan -Minutes 60
    if (((Get-Date) - $lastWrite) -gt $timespan) {
    Return 1
    } else {
    Return 0
    }

    and monitor result?



    Last edited by Lukasz1984; 16-06-2019, 18:07.
  • sancho
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2015
    • 295

    #2
    Hello Lukasz1984

    If you want to alert you when there is a file of more than 60 minutes.

    Since version 4.0 you have this item vfs.dir.count https://www.zabbix.com/documentation...s/zabbix_agent

    For example, something like this:
    Code:
    vfs.dir.count["folder path",,,file,,0,1,,3600,,]
    The trigger should create it to change to Problem when the result is greater than 0
    Code:
    {HOSTNAME:vfs.dir.count["folder path",,,file,,0,1,,3600,,].last(#1)}>0
    If you want to be notified when a folder has not been modified for more than 60 minutes, you can use the item vfs.file.time
    Code:
    vfs.file.time[folder path,modify]
    And create a trigger with the function fuzzytime
    Code:
    {HOSTNAME:vfs.file.time[folder path,modify].fuzzytime(3600)}=0
    Sorry for my google english, I hope I have understood you well

    Comment

    Working...