Hello all (unfortunatly I cannot post in the Nagios core forum - so have had to post here)
I am trying to cat a log file held in /var/logs/ e.g /var/log/messages.
I appreciate this is likely to be a large file but bare with me! I can create any other file by doing a touch file1 put some random stuff init.
When I run the command ./check_nrpe -H 00.00.00.001-c check_log it will return the contents of the file i created. (Brilliant)
If i move the file i created in to /var/log/ it works (again brilliant)
If i try and access /var/log/messages it complains saying no output from nrpe. I have played around with permissions (etc/sudoers) created a group and tried adding the user nrpe to that group.
If anybody has any ideas as to what can be done to access files in /var that would be great!
Thanks
Unable to access /var/log files
Unable to access /var/log files
Last edited by djs on Wed Jan 07, 2015 9:25 am, edited 1 time in total.
Re: Help with Nagios
/var/log/messages is usually owned by root. You will need a sudoers rule to allow the nagios user to read the file. Can you post your additions to the sudoers file?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Help with Nagios
Hi,
The only edit i added to the /etc/sudoers file was:
nrpe ALL=NOPASSWD: ALL
The only edit i added to the /etc/sudoers file was:
nrpe ALL=NOPASSWD: ALL
Re: Help with Nagios
Just an update.
I can run the script to cat the file when i am logged into nagios (su nrpe -s /bin/bash) however on the webpage this displays nothing to me. Well it displays a '\n'
The script I am running consists of:
This is being called in /etc/nagios/object/commands.cfg
Any help would be great.
Thanks
I can run the script to cat the file when i am logged into nagios (su nrpe -s /bin/bash) however on the webpage this displays nothing to me. Well it displays a '\n'
The script I am running consists of:
Code: Select all
#!/bin/bash
echo $(pwd)
echo $(whoami)
#echo $(hostname)
echo $(ls -l /var/log/messages)
echo $(cat /var/log/messages)
echo $(head /var/log/messages)
Code: Select all
define command{
command_name view_log_messages
command_line sh /etc/nagios/plugins/viewmessages
}
Thanks
Re: Unable to access /var/log files
I am a bit confused about your use of check_nrpe... You are using:
This implies you are running a check against a remote box (this is what check_nrpe is used for). On the other hand, you have a command, defined locally (on the nagios server):
The command "check_log" should be defined on the client and on the nagios box, you should have a service defined with the following directive:
Can you elaborate? Where are you actually running the check - locally or on the remote box?
Code: Select all
./check_nrpe -H 00.00.00.001-c check_logCode: Select all
define command{
command_name view_log_messages
command_line sh /etc/nagios/plugins/viewmessages
}Code: Select all
check_command check_nrpe!check_log!Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Unable to access /var/log files
Sorry i forgot to edit my original post. Ive been trying all sorts to get it working.
The script is located locally on the same box and i can log into the user nrpe/nagios shell and run it (again locally) however on the nagios website/dashboard this does not display the information i was previosulay able to get from logging into the nrpe/nagios user.
Basically it works fine from the shell however as soon as it goes on the gui it fails
The script is located locally on the same box and i can log into the user nrpe/nagios shell and run it (again locally) however on the nagios website/dashboard this does not display the information i was previosulay able to get from logging into the nrpe/nagios user.
Basically it works fine from the shell however as soon as it goes on the gui it fails
Re: Unable to access /var/log files
I sent you a PM. Let me know if this worked for you so that I can lock the post. Thanks!
Update: Issue resolved after disabling SELinux.
Update: Issue resolved after disabling SELinux.
Be sure to check out our Knowledgebase for helpful articles and solutions!