Running Nagios XI 5.6.5. Need to check a directory on a windows server (example: C:\\Temp\ProblemFTP) and if any files are found, send alert.
Is there a good example for how to set this up using NCPA?
Check for any file in windows directory and alert
Re: Check for any file in windows directory and alert
I don't think you can check for files with NCPA, at least not yet. Having said that, you could use some kind of custom script, which you can call via check_ncpa.py. For example, you could use a powershell script like this one:
check_count.ps1
Place the script in the NCPA plugins directory, and call it via check_ncpa.py.
Note: When you run the "check_ncpa.py" plugin, you need to pass one argument (the path to your directory).
Example:
check_count.ps1
Code: Select all
param(
[string] $path
)
$count=(Get-ChildItem -Path "$path" | Measure-Object).Count
$ok = 0
$warning = 1
if ($count -gt 0){
write-host "Warning - $count files exists"
exit $warning
}
else{
write-host "OK - $count files exists"
exit $ok
}Note: When you run the "check_ncpa.py" plugin, you need to pass one argument (the path to your directory).
Example:
Code: Select all
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_count.ps1' -q 'args=C:\Temp\ProblemFTP'
OK - 0 files exists
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_count.ps1' -q 'args=C:\Temp\ProblemFTP'
Warning - 1 files existsBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check for any file in windows directory and alert
Thanks, This can be closed
Re: Check for any file in windows directory and alert
I am glad I could help!
Be sure to check out our Knowledgebase for helpful articles and solutions!