File Monitoring - Linux mount point
-
RebeccaIlene
- Posts: 164
- Joined: Tue Apr 02, 2019 8:38 pm
File Monitoring - Linux mount point
Hi Team,
We have some linux mount points that are mapped as windows shares using DFS namespaces.
We want to monitor this path to check if a file *.dat exists in the path everyday at 6 AM.
If the file does not exist it should throw a critical error.
We have this monitoring setup for windows shares where the monitoring is set to check on a drive on the server but haven't been able to set this up for a linux mount point.
Can you please suggest how we can proceed with monitoring this?
We have some linux mount points that are mapped as windows shares using DFS namespaces.
We want to monitor this path to check if a file *.dat exists in the path everyday at 6 AM.
If the file does not exist it should throw a critical error.
We have this monitoring setup for windows shares where the monitoring is set to check on a drive on the server but haven't been able to set this up for a linux mount point.
Can you please suggest how we can proceed with monitoring this?
Re: File Monitoring - Linux mount point
You could put together a little plugin script to run via nrpe:
and it works like so:
The part about having it only do its thing at 6am is a bit tricky; Nagios kind of thinks of things as running constantly, rather than just once or at a specific time.
However, you could have the script check the hour itself when it runs:
This is super-hacky and more or less just a proof of concept that you can improve upon.
But you can give it a try and see if it works. As it is, it will find any file that has a .dat at the end of the filename, in the directory you pass as an argument. If you need it to calculate a specific date or something, like that case you had a few months ago, that would be a bit more code.
Oh, and I have this command defined on the client-side nrpe.cfg:
--Jeffrey
Code: Select all
[root@jpd-cent-nrpe-one libexec]# cat check_datfile
#!/bin/sh
cd $1
ls *.dat > /dev/null
if [ $? -eq 0 ]; then
echo "OK: dat file found as expected"
exit 0
else
echo "CRIT: dat file not found in $1"
exit 2
fi
[root@jpd-cent-nrpe-one libexec]#
Code: Select all
[root@jpd-cent-nrpe-one libexec]# ./check_nrpe -H 192.168.1.10 -c 'DAT Check' -a /tmp/data
OK: dat file found as expected
[root@jpd-cent-nrpe-one libexec]# rm /tmp/data/sdf.dat
rm: remove regular empty file `/tmp/data/sdf.dat'? y
[root@jpd-cent-nrpe-one libexec]# ./check_nrpe -H 192.168.1.10 -c 'DAT Check' -a /tmp/data
CRIT: dat file not found in /tmp/data
However, you could have the script check the hour itself when it runs:
Code: Select all
#!/bin/sh
date +%H | grep -q 06 || echo "OK: not 6am"
date +%H | grep -q 06 || exit 0
cd $1
ls *.dat > /dev/null
if [ $? -eq 0 ]; then
echo "OK: dat file found as expected"
exit 0
else
echo "CRIT: dat file not found in $1"
exit 2
fiBut you can give it a try and see if it works. As it is, it will find any file that has a .dat at the end of the filename, in the directory you pass as an argument. If you need it to calculate a specific date or something, like that case you had a few months ago, that would be a bit more code.
Oh, and I have this command defined on the client-side nrpe.cfg:
Code: Select all
command[DAT Check]=/usr/local/nagios/libexec/check_datfile $ARG1$As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
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
Thanks for the suggestion.
However, the linux host is not managed by us. It's managed by the vendor and we can't install NRPE on the host.
Is there another way to monitor this?
However, the linux host is not managed by us. It's managed by the vendor and we can't install NRPE on the host.
Is there another way to monitor this?
Re: File Monitoring - Linux mount point
What ways into the machine do you have? SSH? Another agent like NCPA?
--Jeffrey
--Jeffrey
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
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
Hi Jeffrey,
We will raise a case with the vendor to check if it's possible to install the Nagios client.
Will update the ticket once we get an update from them.
We will raise a case with the vendor to check if it's possible to install the Nagios client.
Will update the ticket once we get an update from them.
Re: File Monitoring - Linux mount point
Hi Rebecca,
Do you need any help from our end on this one, or are you still in the process of getting something going with your vendor?
Let us know if we can help.
Thanks!
--Jeffrey
Do you need any help from our end on this one, or are you still in the process of getting something going with your vendor?
Let us know if we can help.
Thanks!
--Jeffrey
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
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
The vendor provided us with a custom plugin for Nagios to monitor the devices but we are still unsure how we can monitor shares using this.
Can you please help us?
Here the link provided by the vendor.
https://www.cohesity.com/blog/backup-an ... th-nagios/
Can you please help us?
Here the link provided by the vendor.
https://www.cohesity.com/blog/backup-an ... th-nagios/
Re: File Monitoring - Linux mount point
We don't provide support for custom plugins, however you could follow the instructions, shown here:
https://github.com/cohesity/cohesity-nagios-plugin
If you have any further questions, I would recommend that you contact your vendor.
Once you make sure your custom plugin works from the command line, you could add a new command and a service by following the document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://github.com/cohesity/cohesity-nagios-plugin
If you have any further questions, I would recommend that you contact your vendor.
Once you make sure your custom plugin works from the command line, you could add a new command and a service by following the document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
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
Thanks for the suggestion.
However, we are looking to monitor file shares to see if a *.dat file comes in at 6AM.
These custom plugins are for monitoring other services.
We had a call with the vendor and they said that SSH can't be enabled and the Nagios client can't be installed either.
Can you please suggest another way to monitor this?
The suggestion provided by the vendor is to provide access to a service account on the share and then run a powershell script that uses the credentials of the service account to check if the file exists.
Can you please suggest if we have a custom powershell script for such monitoring?
However, we are looking to monitor file shares to see if a *.dat file comes in at 6AM.
These custom plugins are for monitoring other services.
We had a call with the vendor and they said that SSH can't be enabled and the Nagios client can't be installed either.
Can you please suggest another way to monitor this?
The suggestion provided by the vendor is to provide access to a service account on the share and then run a powershell script that uses the credentials of the service account to check if the file exists.
Can you please suggest if we have a custom powershell script for such monitoring?
Re: File Monitoring - Linux mount point
Writing custom scripts is out of scope of Nagios support, however here's a simple PS script that can get you started:
Here's an example of the output, when testing the script in the PS terminal:
There was no file with an extension *.dat in the D:\TEMP directory
I added test.dat file to D:\TEMP directoty
You can modify the script by setting the path to the directory, where the .dat files should/should not show up at 6 am. You can change when to get "ok" or "warning", etc. You can run your check at around 6:00 am every day, and get the results back.
Again, this is out of scope, and it is on you to set this up. I hope these notes can help you out and get you started. Thanks!
Code: Select all
# PowerShell Checks If a *.dat File Exists
$WantFile = "D:\TEMP\*.dat"
$ok = 0
$warning = 1
$FileExists = Test-Path $WantFile
if ($FileExists -eq $True) {
Write-Host "WARNING: File with extension *.dat exists"
exit $warning
} else {
Write-Host "OK: No file at this location"
exit $ok
}There was no file with an extension *.dat in the D:\TEMP directory
Code: Select all
PS C:\Program Files\NSClient++\scripts> .\check_dat_file.ps1
OK: No file at this locationCode: Select all
PS C:\Program Files\NSClient++\scripts> .\check_dat_file.ps1
WARNING: File with extension *.dat existsAgain, this is out of scope, and it is on you to set this up. I hope these notes can help you out and get you started. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!