Page 2 of 2

Re: File Monitoring - Linux mount point

Posted: Wed Sep 23, 2020 4:08 am
by RebeccaIlene
Thanks! :) I have tested this and it works.

Is it possible to add another command that checks the creation and written time as well?

There are going to be multiple files with *.dat but we want to make sure that the script checks for a file that was a created and written an hour before. ( As the check happens at 6 am so the file should be created and written in between 5 am and 6 am)

Hope that makes sense.

Thanks again for all your help.

Re: File Monitoring - Linux mount point

Posted: Wed Sep 23, 2020 9:02 am
by lmiltchev
This falls under the "custom development" realm, and it is out of scope of Nagios support.

Having said that, it is possible to check the timestamps of the .dat files via PowerShell. I would recommend that you review the Microsoft's documentation on the Get-Date module here:

https://docs.microsoft.com/en-us/powers ... wershell-7

Re: File Monitoring - Linux mount point

Posted: Wed Sep 23, 2020 10:26 pm
by RebeccaIlene
Thanks for that.

You can close this case.

Re: File Monitoring - Linux mount point

Posted: Thu Sep 24, 2020 12:10 am
by RebeccaIlene
I have modified the script this way and it worked! :)

Thanks again for your help.

$file = Get-ChildItem C:\temp\File_test\*.dat | Where{$_.LastWriteTime -gt (Get-Date).AddHours(-1)} | foreach { $_.Name }

$ok = 0
$warning = 1

if ($file -eq $null) {
Write-Host "Warning: No file at this location"
exit $warning
} else {
Write-Host "OK: File with extension *.dat exists"
exit $ok
}

Re: File Monitoring - Linux mount point

Posted: Thu Sep 24, 2020 7:28 am
by scottwilkerson
RebeccaIlene wrote:I have modified the script this way and it worked! :)

Thanks again for your help.

$file = Get-ChildItem C:\temp\File_test\*.dat | Where{$_.LastWriteTime -gt (Get-Date).AddHours(-1)} | foreach { $_.Name }

$ok = 0
$warning = 1

if ($file -eq $null) {
Write-Host "Warning: No file at this location"
exit $warning
} else {
Write-Host "OK: File with extension *.dat exists"
exit $ok
}
Great!

Locking thread