Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nagios

Posted on 2009-07-16
63
Medium Priority
?
1,606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 34
  • 17
  • 11
  • +1
63 Comments
 
LVL 29

Expert Comment

by:fosiul01
ID: 24872169
do you have selinux enabled ??

and did you give permisison to nagios user ??
0
 

Author Comment

by:Lionel35
ID: 24872201
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
ID: 24872261
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
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

 

Author Comment

by:Lionel35
ID: 24872279
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
ID: 24872293
omm why this line ??

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

whts the output of
sestatus  
0
 
LVL 14

Expert Comment

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

Author Comment

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

Author Comment

by:Lionel35
ID: 24872333
[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
ID: 24872386
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
ID: 24872423
hold one

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

0
 

Author Comment

by:Lionel35
ID: 24872448
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
ID: 24872485
Ok
then show the permission of those cfg file which you were working
0
 

Author Comment

by:Lionel35
ID: 24872502
-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
ID: 24872539
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
ID: 24872616
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
ID: 24872755
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
ID: 24872775
hmmm i am on centos if i stop nagios it will not restart cause of the error :(
0
 

Author Comment

by:Lionel35
ID: 24872788
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
ID: 24872816
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
ID: 24872837
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
ID: 24872861
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
ID: 24872945
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
ID: 24872985
hmm i think i have the files from the sample-object dir let me try that
0
 

Author Comment

by:Lionel35
ID: 24873020
nope same error :(
0
 
LVL 14

Expert Comment

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

Expert Comment

by:fosiul01
ID: 24873050
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
ID: 24873062
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
ID: 24873093
look the difference

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

Author Comment

by:Lionel35
ID: 24873130
hmmm you put 777 on object?
0
 

Author Comment

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

Expert Comment

by:fosiul01
ID: 24873160
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
 

Author Comment

by:Lionel35
ID: 24873191
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
ID: 24873239
did u define the host definition entry for ecm can you copy you host definition and hostgrp definitons
0
 

Author Comment

by:Lionel35
ID: 24873354
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
ID: 24873374
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
ID: 24873412
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
ID: 24873427
thanks for the help fosiul01 i will wait for kosarajudeepak
0
 

Author Comment

by:Lionel35
ID: 24873455
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
ID: 24873598
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
ID: 24873619
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
ID: 24873624
hmm wait i modified this 2 mn
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 24873646
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
ID: 24873691
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
ID: 24873697
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
ID: 24873710
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
ID: 24873721
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
ID: 24873726
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
ID: 24873749
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
ID: 24873774
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
ID: 24873779
yep all changed
0
 

Author Comment

by:Lionel35
ID: 24873817
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 2000 total points
ID: 24873834
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
ID: 24873886
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
ID: 31604361
Great explanation and walkthrough from both this guys
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24873921
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
ID: 24873928
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
ID: 24873932
LOL
0
 

Author Comment

by:Lionel35
ID: 24873993
sorry guys let me redo it
0
 

Author Comment

by:Lionel35
ID: 24873996
ha men i cant change the way i closed the question?
0
 

Author Comment

by:Lionel35
ID: 24874017
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
ID: 24874024
haahahahaha
lol
dont worry about that
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 24874071
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
ID: 24874230
have a great day as well and thanks again guys
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Suggested Courses

688 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