File Monitoring - Linux mount point

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
RebeccaIlene
Posts: 164
Joined: Tue Apr 02, 2019 8:38 pm

Re: File Monitoring - Linux mount point

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: File Monitoring - Linux mount point

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
RebeccaIlene
Posts: 164
Joined: Tue Apr 02, 2019 8:38 pm

Re: File Monitoring - Linux mount point

Post by RebeccaIlene »

Thanks for that.

You can close this case.
RebeccaIlene
Posts: 164
Joined: Tue Apr 02, 2019 8:38 pm

Re: File Monitoring - Linux mount point

Post 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
}
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: File Monitoring - Linux mount point

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked