Solved

Nagios

Posted on 2009-07-16
63
1,461 Views
Last Modified: 2012-05-07
Hi,
I just installed nagios and this is the error message I get when doing the pre-flight check

Error: Cannot open config file '/usr/local/nagios/etc/objects/commands.cfg' for reading: Permission denied
Error processing object config files!
I tried to put 777 permissions on the file but still get the same error
Thanks for the help
0
Comment
Question by:Lionel35
  • 34
  • 17
  • 11
  • +1
63 Comments
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
do you have selinux enabled ??

and did you give permisison to nagios user ??
0
 

Author Comment

by:Lionel35
Comment Utility
Selinux is disabled as far as i can tell i gave the permissions advised from the nagios tutorial
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
ok
what the output of this command

ps aux | grep -v grep  | grep  nagios



you said, pre flight check, is this your own script ??
0
 

Author Comment

by:Lionel35
Comment Utility
here is what i got

root@dev4 selinux]# ps aux | grep -v grep  | grep  nagios
nagios   32685  0.0  0.0  12768  1004 ?        Ssl  Jul15   0:09 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
[1]+  Exit 1                  /usr/sbin/selinuxenabled

preflight check is called from
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
omm why this line ??

[1]+  Exit 1                  /usr/sbin/selinuxenabled

whts the output of
sestatus  
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
can you copy the ls -l output of  /usr/local/nagios
0
 

Author Comment

by:Lionel35
Comment Utility
Sorry it was the result of another command here is what i have
SELinux status:                 disabled
0
 

Author Comment

by:Lionel35
Comment Utility
[root@dev4 selinux]# ls -l /usr/local/nagios
total 24
drwxrwxr-x  2 nagios nagios 4096 Jul 13 15:22 bin
drwxrwxr-x  3 nagios nagios 4096 Jul 16 13:34 etc
drwxrwxr-x  2 nagios nagios 4096 Jul 13 15:26 libexec
drwxrwxr-x  2 nagios nagios 4096 Jul 16 11:00 sbin
drwxrwxr-x 10 nagios nagios 4096 Jul 13 15:26 share
drwxrwxr-x  5 nagios nagios 4096 Jul 16 13:47 var
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
hmm
ok ( i guess permission is ok, but still check the permisison for nagios directory)

cd /usr/local

ls -al | grep nagios

0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
hold one

if your nagios is not running then how you getting the ps output with nagios runing??

0
 

Author Comment

by:Lionel35
Comment Utility
nagios is actually running i was modifying some .cfg files (not the commands.cfg) when i tried to do the pre-flight check its where this problem started
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
Ok
then show the permission of those cfg file which you were working
0
 

Author Comment

by:Lionel35
Comment Utility
-rw-r--r-- 1 nagios nagios  8363 Jul 16 13:29 commands.cfg
-rw-rw-r-- 1 nagios nagios  3155 Jul 15 19:31 contacts.cfg
-rw-rw-r-- 1 nagios nagios  6053 Jul 16 12:41 ecm.cfg
-rw-rw-r-- 1 nagios nagios  5759 Jul 15 19:16 ecm.cfg.bak
-rw-rw-r-- 1 nagios nagios   102 Jul 16 12:47 hostgroup.cfg
-rw-rw-r-- 1 nagios nagios  1095 Jul 16 12:01 hosts.cfg
-rw-rw-r-- 1 nagios nagios  3691 Jul 15 19:43 hosts.cfg.bak
-rw-rw-r-- 1 nagios nagios  6120 Jul 16 12:45 liferay.cfg
-rw-rw-r-- 1 nagios nagios  5414 Jul 16 12:43 localhost.cfg
-rw-rw-r-- 1 nagios nagios  5459 Jul 16 12:34 localhost.cfg.bak
-rw-rw-r-- 1 nagios nagios  3124 Jul 13 15:22 printer.cfg
-rw-rw-r-- 1 nagios nagios  3293 Jul 13 15:22 switch.cfg
-rw-rw-r-- 1 nagios nagios 10822 Jul 16 11:28 templates.cfg
-rw-rw-r-- 1 nagios nagios  3209 Jul 13 15:22 timeperiods.cfg
-rw-rw-r-- 1 nagios nagios  6116 Jul 16 12:42 wcm.cfg
-rw-rw-r-- 1 nagios nagios  4019 Jul 13 15:22 windows.cfg
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
according to my one

commands.cfg should be like this

-rw-rw-r-- 1 nagios nagios  7714 Jun  4 12:25 commands.cfg
0
 

Author Comment

by:Lionel35
Comment Utility
after the change
-rw-rw-r-- 1 nagios nagios  8363 Jul 16 13:29 commands.cfg
Error: Cannot open config file '/usr/local/nagios/etc/objects/commands.cfg' for reading: Permission denied
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
thats wired ..

is this fedora ??

will you be able to stop nagios service and then will try to pre flight check  or restart directly
0
 

Author Comment

by:Lionel35
Comment Utility
hmmm i am on centos if i stop nagios it will not restart cause of the error :(
0
 

Author Comment

by:Lionel35
Comment Utility
and i am afraid that will be the same story for each .cfg files as if i try the pre flight with the others .cfg files it will give me the same error
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
ok what did you change ?? because you said, your nagios is working fine

so thats mean, after installing nagios, you must of exeuted this command

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

before and it worked, right ??

so what did you change that its not working now ??

0
 

Author Comment

by:Lionel35
Comment Utility
not sure i did not touch the permissions i just changed the .cfg files for the server that's why i am at a loss here and the last things i want is to reinstall this
0
 

Author Comment

by:Lionel35
Comment Utility
err when i say i just changed the .cfg files read: i changed the files to monitor the servers nothing like the commands.cfg or templates.cfg etc ...
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
is there anyway to revert the file back to as before ??? ( may be it does not make sense ,but trying every way )
0
 

Author Comment

by:Lionel35
Comment Utility
hmm i think i have the files from the sample-object dir let me try that
0
 

Author Comment

by:Lionel35
Comment Utility
nope same error :(
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
which user are u trying with root (or) nagios.
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
ok what about permission in here ( go to /usr/local/nagios/etc )

-bash-3.2# pwd
/usr/local/nagios/etc

-bash-3.2# cd etc
-bash-3.2# ls -al
total 76
drwxrwxr-x 3 nagios nagios  4096 Jun 12 11:12 .
drwxrwxr-x 8 nagios nagios  4096 Jun  4 12:25 ..
-rw-rw-r-- 1 nagios nagios 10699 Jun  4 12:25 cgi.cfg
-rw-r--r-- 1 root   root      26 Jun  4 12:28 htpasswd.users
-rw-rw-r-- 1 nagios nagios 42730 Jun  4 12:25 nagios.cfg
drwxrwxr-x 2 nagios nagios  4096 Jun 22 09:49 objects  
-rw-rw---- 1 nagios nagios  1340 Jun  4 12:25 resource.cfg



does it same in your ???  ( check, object , cgi.cfg)
0
 

Author Comment

by:Lionel35
Comment Utility
drwxrwxr-x 3 nagios nagios  4096 Jul 16 14:00 .
drwxr-xr-x 8 nagios nagios  4096 Jul 13 15:22 ..
-rw-rw-r-- 1 nagios nagios 11408 Jul 13 15:22 cgi.cfg
-rw-r--r-- 1 root   root      26 Jul 13 15:23 htpasswd.users
-rw-rw-r-- 1 nagios nagios 44065 Jul 16 14:00 nagios.cfg
drw-rw-r-- 2 nagios nagios  4096 Jul 16 13:29 objects
-rw-rw---- 1 nagios nagios  1340 Jul 13 15:22 resource.cfg
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
look the difference

drwxrwxr-x 2 nagios nagios  4096 Jun 22 09:49 objects  
0
 

Author Comment

by:Lionel35
Comment Utility
hmmm you put 777 on object?
0
 

Author Comment

by:Lionel35
Comment Utility
and is the perms are all the same on the rest of the folder (i.e inside) ?
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
i didnot do nothing!!
nagios should create all those folder with accurate permission

here is under objects

bash-3.2# cd objects/
-bash-3.2# ls -al
total 56
drwxrwxr-x 2 nagios nagios  4096 Jun 22 09:49 .
drwxrwxr-x 3 nagios nagios  4096 Jun 12 11:12 ..
-rw-rw-r-- 1 nagios nagios  7714 Jun  4 12:25 commands.cfg
-rw-rw-r-- 1 nagios nagios  2166 Jun  4 12:27 contacts.cfg
-rw-rw-r-- 1 nagios nagios  5608 Jun 12 11:52 localhost.cfg
-rw-rw-r-- 1 nagios nagios  3124 Jun  4 12:25 printer.cfg
-rw-rw-r-- 1 nagios nagios  3293 Jun  4 12:25 switch.cfg
-rw-rw-r-- 1 nagios nagios 10812 Jun  4 12:25 templates.cfg
-rw-rw-r-- 1 nagios nagios  3209 Jun  4 12:25 timeperiods.cfg
-rw-rw-r-- 1 nagios nagios  4007 Jun  4 12:25 windows.cfg
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Lionel35
Comment Utility
ok 777 on objects did work out let me get back to you as now others problem as arise like
Error: Could not find any host matching 'ecm' (config file '/usr/local/nagios/etc/objects/hostgroup.cfg', starting on line 1)
Error: Could not expand members specified in hostgroup (config file '/usr/local/nagios/etc/objects/hostgroup.cfg', starting on line 1)

while theses does exist be back in 15 mn thanks a lot for your help
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
did u define the host definition entry for ecm can you copy you host definition and hostgrp definitons
0
 

Author Comment

by:Lionel35
Comment Utility
here you go:

define host{
        host_name                       ecm.modernluxury.com
        alias                           ecm
        address                         xx.xx.xx.91
        check_command                   check-host-alive
        max_check_attempts              5
        check_period                    24x7
        process_perf_data               0
        retain_nonstatus_information    0
        contact_groups                  nagiosadmins
        notification_interval           30
        notification_period             24x7
        notification_options            d,u,r
        register                        1
        }


define hostgroup{
        hostgroup_name  ML
        alias                 long name for ML
        members         localhost,ecm,wcm,liferay
        }
0
 

Author Comment

by:Lionel35
Comment Utility
on a side note i did commetn out my hosts.cfg and that give me the first error but if i uncomment the hosts.cfg it will give me

Warning: Duplicate definition found for host 'ecm.modernluxury.com' (config file '/usr/local/nagios/etc/objects/ecm.modernluxury.cfg', starting on line 34)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/ecm.modernluxury.cfg' on line 36
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
Ok  at least your permission problem has been solved

about the new problem @kosarajudeepak , might be able to help you.
i have very basic knowlege of nagios
0
 

Author Comment

by:Lionel35
Comment Utility
thanks for the help fosiul01 i will wait for kosarajudeepak
0
 

Author Comment

by:Lionel35
Comment Utility
i resolved the duplicate def but this is what i have now (after commenting out my host define in the .cfg files for each server)

Error: Could not find any host matching 'liferay' (config file '/usr/local/nagios/etc/objects/liferay.ML.cfg', starting on line 141)
Error: Could not expand hostgroups and/or hosts specified in service (config file '/usr/local/nagios/etc/objects/liferay.ML.cfg', starting on line 141)
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
well here is the problem we cannot use alias name in the members field of hostgroup definition use the real host_name.
define hostgroup{
        hostgroup_name  ML
        alias                 long name for ML
        members         localhost,ecm.modernluxury.com,wcm,liferay
        }
similarly for others
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
following is the descrption for hostgroup memebrs object

Shortname != Alias name

members: This is a list of the short names of hosts that should be included in this group.
Multiple host names should be separated by commas. This directive may be
used as an alternative to (or in addition to) the hostgroups directive in host
definitions.
0
 

Author Comment

by:Lionel35
Comment Utility
hmm wait i modified this 2 mn
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
you can either add the host as member to the group by adding it to members filed of hostgroup
(or)
by adding below directive to host definition
hostgroups: This directive is used to identify the short name(s) of the hostgroup(s) that the host belongs to. Multiple hostgroups should be separated by commas. This directive may be used as an
alternative to (or in addition to) using the members directive in hostgroup definitions.

So you definition can be as below:
define host{

        host_name                       ecm.modernluxury.com

        alias                           ecm

        hostgroups                      ML

        address                         xx.xx.xx.91

        check_command                   check-host-alive

        max_check_attempts              5

        check_period                    24x7

        process_perf_data               0

        retain_nonstatus_information    0

        contact_groups                  nagiosadmins

        notification_interval           30

        notification_period             24x7

        notification_options            d,u,r

        register                        1

        }

Open in new window

0
 

Author Comment

by:Lionel35
Comment Utility
this is what i have define host{
        host_name                       ecm
        alias                           ecm.ML.com
        address                         xx.xx.xx.91
        check_command                   check-host-alive
        max_check_attempts              5
        check_period                    24x7
        process_perf_data               0
        retain_nonstatus_information    0
        contact_groups                  nagiosadmins
        notification_interval           30
        notification_period             24x7
        notification_options            d,u,r
        register                        1
        }
i made the contact file but it keep asking about a group called admins which i do not have anywhere
0
 

Author Comment

by:Lionel35
Comment Utility
the error message

Error: Contact group 'admins' specified in service 'HTTP' for host 'ecm' is not defined anywhere!
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Note that the permissions on the object directory should at most be 775 and not 777.  You originally had perms of 664 which means non-root users like nagios have no search permission in the directory.
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
by default u get some definition in localhost.cfg where u have contact_group admins.
So change it as u have defined the contactgroups
0
 

Author Comment

by:Lionel35
Comment Utility
all problem solved by what i can see during pre-flight check let me restart nagios and let you know in any case i cannot thanks you enough for your help
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
Op's I overlooked its the service HTTP which has the contact group as admin's I hope u change it to nagiosadmin.
0
 

Author Comment

by:Lionel35
Comment Utility
ok was able to restart and i can see the servers now i will leave this ticket open until tomorrow morning (PST) just to make sure nagios can find all servers.
Thanks again and if i cannot see the others server i will come back here (crossing fingers) tho.
Thanks
0
 

Author Comment

by:Lionel35
Comment Utility
yep all changed
0
 

Author Comment

by:Lionel35
Comment Utility
ok all fixed just the http command complaining about a 404 on 2 server but i dont think it is a problem
and its only a warning HTTP WARNING: HTTP/1.0 404 Not Found
0
 
LVL 14

Accepted Solution

by:
Deepak Kosaraju earned 500 total points
Comment Utility
just to make sure nagios can find all servers. - well if the servers are added to host definition and nagios server is able to ping and command definitions are accurate then nagios ball is in your court.
0
 

Author Comment

by:Lionel35
Comment Utility
ok kosarajudeepak thanks for your help i will close this ticket and give you the point :) have a great day
0
 

Author Closing Comment

by:Lionel35
Comment Utility
Great explanation and walkthrough from both this guys
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
i am really suprised the way you closed this question!!!
your initial question was permission problem which i solved!!
but you did not assign any points to me!!
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
Hi you forgot to split the points between fosiul01 and me. All points are assigned to me. I wish fosiul01 deserve half points.
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
LOL
0
 

Author Comment

by:Lionel35
Comment Utility
sorry guys let me redo it
0
 

Author Comment

by:Lionel35
Comment Utility
ha men i cant change the way i closed the question?
0
 

Author Comment

by:Lionel35
Comment Utility
ok contacted customer service and asked them to split the reward between both of you sorry again for this mistake
0
 
LVL 29

Expert Comment

by:fosiul01
Comment Utility
haahahahaha
lol
dont worry about that
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
Comment Utility
That's fair enough to close this question by contacting customer care, thanks to every once, Will catch u in some other questions ;-). Have a great day.
0
 

Author Comment

by:Lionel35
Comment Utility
have a great day as well and thanks again guys
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Some time ago I was asked to set up a web portal PC to put at our entrance. When customers arrive, they could see a webpage 'promoting' our company. So I tried to set up a windows 7 PC as a kiosk PC.......... I will spare you all the annoyances I…
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now