Monitor File Contents
Monitor File Contents
Hi
I have tried the check_log and the check_log3.pl plugins but these seem to on monitor local files on the nagios server itself
I am looking to monitor a file on a remote server for 1 word "Critical" and then send a notification if that word is present
Can you tell me of any plugin that can complete this task
At present we are running NagiosXI 5.2.7
Thanks
I have tried the check_log and the check_log3.pl plugins but these seem to on monitor local files on the nagios server itself
I am looking to monitor a file on a remote server for 1 word "Critical" and then send a notification if that word is present
Can you tell me of any plugin that can complete this task
At present we are running NagiosXI 5.2.7
Thanks
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Monitor File Contents
Hello,
To run the checks on a local server you can either install an agent such as NCPA or use ssh to log into the remote server and run the plugin. I posted a few links below with documentation to help get you started.
NCPA Agent Installation Instructions
Using Scripts Plugins with NCPA
Monitoring Hosts Using SSH
To run the checks on a local server you can either install an agent such as NCPA or use ssh to log into the remote server and run the plugin. I posted a few links below with documentation to help get you started.
NCPA Agent Installation Instructions
Using Scripts Plugins with NCPA
Monitoring Hosts Using SSH
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!
Re: Monitor File Contents
Hi Benjamin
Thanks but I am trying to monitor the contents of a file on a Remote Server
I should also mention this is on a Linux Server
Thanks but I am trying to monitor the contents of a file on a Remote Server
I should also mention this is on a Linux Server
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Monitor File Contents
Hi,
For Linux systems, you can use NRPE as well to execute plugin checks. The following instructions will install NRPE as well as the nagios plugins. You might find that easier since you'll have check_log on the remote host.
https://support.nagios.com/kb/article/n ... rpe-8.html
Then on the remote host you'll set up your commands and call them from the XI server.
NRPE - Configuring NRPE Commands To Accept Arguments
For Linux systems, you can use NRPE as well to execute plugin checks. The following instructions will install NRPE as well as the nagios plugins. You might find that easier since you'll have check_log on the remote host.
https://support.nagios.com/kb/article/n ... rpe-8.html
Then on the remote host you'll set up your commands and call them from the XI server.
NRPE - Configuring NRPE Commands To Accept Arguments
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!
Re: Monitor File Contents
Cheers Benjamin
I looked at the links you sent which got me looking at other pages as well
This is how I stand at the moment
When I run the command locally on the server I get back results
nagiosscreenshot1
on the local server I create a check_file_content.cfg file in the /etc/nrpe.d directory
with content of
nagiosscreenshot2
So now I configure the nagios GUI with the details as such
nagiosscreenshot3
But the Results are
nagiosscreenshot4
Can you see where I am going wrong or is it just not possible to run this check_file_content remotley
Thanks
I looked at the links you sent which got me looking at other pages as well
This is how I stand at the moment
When I run the command locally on the server I get back results
nagiosscreenshot1
on the local server I create a check_file_content.cfg file in the /etc/nrpe.d directory
with content of
nagiosscreenshot2
So now I configure the nagios GUI with the details as such
nagiosscreenshot3
But the Results are
nagiosscreenshot4
Can you see where I am going wrong or is it just not possible to run this check_file_content remotley
Thanks
You do not have the required permissions to view the files attached to this post.
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Monitor File Contents
Hello,
Looks good and thanks for sending the screenshots. I noticed when running the command, you are logged as root and the command requires sudo to run. When Nagios is connects over NRPE it will run the plugin as the nagios user, so you'll need to edit the sudoers file to grant permissions.
The following guide has step-by-step instructions for adding this to the /etc/sudoers file.
NRPE - NRPE: Unable To Read Output
To verify this working locally, log in as nagios user and run the plugin.
Let me know if this resolves the issue for you.
Looks good and thanks for sending the screenshots. I noticed when running the command, you are logged as root and the command requires sudo to run. When Nagios is connects over NRPE it will run the plugin as the nagios user, so you'll need to edit the sudoers file to grant permissions.
The following guide has step-by-step instructions for adding this to the /etc/sudoers file.
NRPE - NRPE: Unable To Read Output
To verify this working locally, log in as nagios user and run the plugin.
Code: Select all
su - nagios
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!
Re: Monitor File Contents
Hi Benjamin
Thanks for the information, I'm still not getting the correct return but I am making progress
I add the following line to the sudoers file on the server running the file
nagios ALL = NOPASSWD:/usr/lib64/nagios/plugins/check_file_content.pl
now I can switch to the nagios user and when I run the command as nagios user
sudo /usr/lib64/nagios/plugins/check_file_content.pl -f /opt/IBM_app_users/TestFolder/lastbackuptest.txt
I get the return of
OK for /opt/IBM_app_users/TestFolder/lastbackuptest.txt
Which is exactly what I am looking for
So looks like the nagios user is able to access the text file and read the output
But when I try and run if from the GUI I still get
NRPE: Unable to read output
Attached is the makeup of the monitor again incase I am configuring that incorrectly
When I click on Test Check Command, it asks me for the server name which I input and then it returns the NRPE: Unable to Read Output
Thanks
Thanks for the information, I'm still not getting the correct return but I am making progress
I add the following line to the sudoers file on the server running the file
nagios ALL = NOPASSWD:/usr/lib64/nagios/plugins/check_file_content.pl
now I can switch to the nagios user and when I run the command as nagios user
sudo /usr/lib64/nagios/plugins/check_file_content.pl -f /opt/IBM_app_users/TestFolder/lastbackuptest.txt
I get the return of
OK for /opt/IBM_app_users/TestFolder/lastbackuptest.txt
Which is exactly what I am looking for
So looks like the nagios user is able to access the text file and read the output
But when I try and run if from the GUI I still get
NRPE: Unable to read output
Attached is the makeup of the monitor again incase I am configuring that incorrectly
When I click on Test Check Command, it asks me for the server name which I input and then it returns the NRPE: Unable to Read Output
Thanks
You do not have the required permissions to view the files attached to this post.
Re: Monitor File Contents
In addition to testing it as root (via sudo, as you did), can you also test the command as the nagios user, without sudo?
Also, can you post your nrpe.cfg file from your remote machine? Feel free to redact any secret information before posting.
Thanks!
Code: Select all
nagios$ /usr/lib64/nagios/plugins/check_file_content.pl -f /opt/IBM_app_users/TestFolder/lastbackuptest.txt
Thanks!
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!
Re: Monitor File Contents
Hi
I have run the command without sudo but just to be sure I have attached a screenshot
The first run is as root and then I switched to the nagios user and ran the command again and both times I got the same result
also find attached a copy of the nrpe.cfg file
I have run the command without sudo but just to be sure I have attached a screenshot
The first run is as root and then I switched to the nagios user and ran the command again and both times I got the same result
also find attached a copy of the nrpe.cfg file
You do not have the required permissions to view the files attached to this post.
Re: Monitor File Contents
I don't see the check_file_content command defined in your nrpe.cfg file...
Try adding the command, for example:
save, exit, and restart nrpe on the client.
Test your check from the command line on the Nagios XI server:
Try adding the command, for example:
Code: Select all
command[check_file_content]=/usr/lib64/nagios/plugins/check_file_content.pl -f /opt/IBM/app_users/TestFolder/lastbackuptest.txt -i Successful -n 0Test your check from the command line on the Nagios XI server:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_file_contentBe sure to check out our Knowledgebase for helpful articles and solutions!