Hej as completely noob in zabbix need help in creating a trigger for windows folder that checking if the newest file (random name) is not older than 30 if is older then send me alert.
Can someone check if trigger is ok ?
Powershell CheckFile.ps1
$dir = "C:\Test"
$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$filedate = $latest.name
$lastWrite = (Get-Item "C:\Test\$filedate").LastWriteTime
$timespan = new-timespan -Minutes 30
if (((Get-Date) - $lastWrite) -gt $timespan) {
Return 1
} else {
Return 0
}
Trigger
{TEST:system.run[powershell.exe -command c:\zabbix\CheckFile.ps1].regexp(1)}=1