Directory Monitoring
Directory Monitoring
I need to monitor a directory to ensure a new file gets created every 24 hours? I have a job that creates a new folder at \\cinfszl01p\vol1\SiteCore every morning around 3:00 AM. I’d like to have it check at around 5:00 AM to make sure a new folder exists. If it does not, it should throw an alert to the appropriate group. Any thoughts?
I see several plugins to alert on files but nothing really on directories and at a specific time.
Actually, it creates a timestamped folder with the SiteCore directory and does not remove anything. See attachment.
They care if a new folder does not get created (like on the 14th).
The files seem to usually be ready by 3:05 AM but it will probably begin to take longer over time. They suggested 5 AM as that seemed like a safe buffer. What is the best way to accomplish this?
I see several plugins to alert on files but nothing really on directories and at a specific time.
Actually, it creates a timestamped folder with the SiteCore directory and does not remove anything. See attachment.
They care if a new folder does not get created (like on the 14th).
The files seem to usually be ready by 3:05 AM but it will probably begin to take longer over time. They suggested 5 AM as that seemed like a safe buffer. What is the best way to accomplish this?
You do not have the required permissions to view the files attached to this post.
-
kyang
Re: Directory Monitoring
You are right most of the plugins I see only do it for files.
This will probably fall into creating your own plugin to do this.
I'm still digging around when I can to see what I am able to find.
This will probably fall into creating your own plugin to do this.
I'm still digging around when I can to see what I am able to find.
Re: Directory Monitoring
Any other suggestions to monitor directories? I am currently stuck and need to get this resolved but have no way of monitoring directories and dates?
Is there a way to have Nagios check for a directory date and the look inside the directory for files? These directories have several files inside of them. Each of them should at the very least have an index.html file inside.
Thinking if I look for this index.html file within the dated directory maybe that would work.
Is there a way to have Nagios check for a directory date and the look inside the directory for files? These directories have several files inside of them. Each of them should at the very least have an index.html file inside.
Thinking if I look for this index.html file within the dated directory maybe that would work.
Re: Directory Monitoring
I have used the check_winfile plugin in the past to monitor files within a directory on Windows.
https://www.itefix.net/check_winfile
You could use check_nrpe with NSClient++ or NCPA to run the plugin on the remote machine. With check_winfile, you could check the timestamps of the files inside your target directory. I don't believe you could check the timestamp of the directory itself.
This is a 3rd party plugin. It's not developed/maintained by Nagios, however it is not difficult to set up. You can give it a try to see if this is something that you may use. Let us know if you get stuck on something. We are here to help. Thank you!
https://www.itefix.net/check_winfile
You could use check_nrpe with NSClient++ or NCPA to run the plugin on the remote machine. With check_winfile, you could check the timestamps of the files inside your target directory. I don't believe you could check the timestamp of the directory itself.
This is a 3rd party plugin. It's not developed/maintained by Nagios, however it is not difficult to set up. You can give it a try to see if this is something that you may use. Let us know if you get stuck on something. We are here to help. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Directory Monitoring
Does that plugin need to be ran from the host you want to check? I don't see an argument to pass the host information from the Nagios server.
Re: Directory Monitoring
Place the check_winfile.exe into the NSClient++ scripts directory. Define a command in nsclient.ini file under the [/settings/external scripts/scripts] section as such:
and call it from your Nagios XI server via check_nrpe.
Example:
From the command line
In the GUI
Of cause, you will need to use the options that fit your needs. This is only an example.
Let us know if you have any more questions.
Code: Select all
check_winfile = scripts\check_winfile.exe //T:30 //NoLogo $ARG1$Example:
From the command line
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_winfile -a '--target c:\TEMP --filter "age gt -24 hours" --warning 2 --critical 5'
FILE OK - 1 files out of 6 to consider |'selected files'=1;2;5 'all files'=6 'deleted files'=0Let us know if you have any more questions.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Directory Monitoring
Well, that was worth a try. Each day a new directory is created with that index file I was going to check. I didn't see anything about create a date formatted directory so it checks the latest directory for that file. So, it would always be OK even if the dated directory was never created and therefore that defeats my monitoring check.
Maybe I am overthinking this. It shouldn't be too difficult to monitor a directory to make sure it has a valid date timestamp.
Maybe I am overthinking this. It shouldn't be too difficult to monitor a directory to make sure it has a valid date timestamp.
Re: Directory Monitoring
I am NOT a developer, and don't know powershell...
I am sure though, that if you had a custom PS script that checked for the timestamp on a directory, you could call it from the Nagios XI server via check_nrpe and NSClient++ or via NCPA.
The script could be something like this:
There are probably million flaws in this code but it can be improved... or rewritten from scratch.
You could add parameters, and pass them via check_nrpe, instead of having them hard-coded. You can use "AddHours" instead of "AddDays" if needed. Hopefully, this will help you get started.
The script could be something like this:
Code: Select all
$LastExitCode = 0
$output = ""
$warn = (Get-Date).AddDays(-1)
$crit = (Get-Date).AddDays(-2)
$MyTimeStamp = Get-Item c:\TEMP | Foreach {$_.LastWriteTime}
if ($MyTimeStamp -gt $crit)
{
$LastExitCode = 2
}
elseif ($MyTimeStamp -gt $warn)
{
$LastExitCode = 1
}
else
{
$LastExitCode = 0
}
$output = $LastExitCode
echo "The timestamp on my folder is: $MyTimeStamp"You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Directory Monitoring
You can close this. I got a PowerShell script that is working.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Directory Monitoring
Glad to hear you got something working.