Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1631
  • Last Modified:

Nagios

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
Lionel35
Asked:
Lionel35
  • 34
  • 17
  • 11
  • +1
1 Solution
 
fosiul01Commented:
do you have selinux enabled ??

and did you give permisison to nagios user ??
0
 
Lionel35Author Commented:
Selinux is disabled as far as i can tell i gave the permissions advised from the nagios tutorial
0
 
fosiul01Commented:
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
Lionel35Author Commented:
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
 
fosiul01Commented:
omm why this line ??

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

whts the output of
sestatus  
0
 
Deepak KosarajuCommented:
can you copy the ls -l output of  /usr/local/nagios
0
 
Lionel35Author Commented:
Sorry it was the result of another command here is what i have
SELinux status:                 disabled
0
 
Lionel35Author Commented:
[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
 
fosiul01Commented:
hmm
ok ( i guess permission is ok, but still check the permisison for nagios directory)

cd /usr/local

ls -al | grep nagios

0
 
fosiul01Commented:
hold one

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

0
 
Lionel35Author Commented:
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
 
fosiul01Commented:
Ok
then show the permission of those cfg file which you were working
0
 
Lionel35Author Commented:
-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
 
fosiul01Commented:
according to my one

commands.cfg should be like this

-rw-rw-r-- 1 nagios nagios  7714 Jun  4 12:25 commands.cfg
0
 
Lionel35Author Commented:
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
 
fosiul01Commented:
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
 
Lionel35Author Commented:
hmmm i am on centos if i stop nagios it will not restart cause of the error :(
0
 
Lionel35Author Commented:
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
 
fosiul01Commented:
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
 
Lionel35Author Commented:
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
 
Lionel35Author Commented:
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
 
fosiul01Commented:
is there anyway to revert the file back to as before ??? ( may be it does not make sense ,but trying every way )
0
 
Lionel35Author Commented:
hmm i think i have the files from the sample-object dir let me try that
0
 
Lionel35Author Commented:
nope same error :(
0
 
Deepak KosarajuCommented:
which user are u trying with root (or) nagios.
0
 
fosiul01Commented:
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
 
Lionel35Author Commented:
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
 
fosiul01Commented:
look the difference

drwxrwxr-x 2 nagios nagios  4096 Jun 22 09:49 objects  
0
 
Lionel35Author Commented:
hmmm you put 777 on object?
0
 
Lionel35Author Commented:
and is the perms are all the same on the rest of the folder (i.e inside) ?
0
 
fosiul01Commented:
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
 
Lionel35Author Commented:
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
 
Deepak KosarajuCommented:
did u define the host definition entry for ecm can you copy you host definition and hostgrp definitons
0
 
Lionel35Author Commented:
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
 
Lionel35Author Commented:
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
 
fosiul01Commented:
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
 
Lionel35Author Commented:
thanks for the help fosiul01 i will wait for kosarajudeepak
0
 
Lionel35Author Commented:
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
 
Deepak KosarajuCommented:
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
 
Deepak KosarajuCommented:
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
 
Lionel35Author Commented:
hmm wait i modified this 2 mn
0
 
Deepak KosarajuCommented:
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
 
Lionel35Author Commented:
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
 
Lionel35Author Commented:
the error message

Error: Contact group 'admins' specified in service 'HTTP' for host 'ecm' is not defined anywhere!
0
 
TintinCommented:
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
 
Deepak KosarajuCommented:
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
 
Lionel35Author Commented:
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
 
Deepak KosarajuCommented:
Op's I overlooked its the service HTTP which has the contact group as admin's I hope u change it to nagiosadmin.
0
 
Lionel35Author Commented:
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
 
Lionel35Author Commented:
yep all changed
0
 
Lionel35Author Commented:
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
 
Deepak KosarajuCommented:
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
 
Lionel35Author Commented:
ok kosarajudeepak thanks for your help i will close this ticket and give you the point :) have a great day
0
 
Lionel35Author Commented:
Great explanation and walkthrough from both this guys
0
 
fosiul01Commented:
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
 
Deepak KosarajuCommented:
Hi you forgot to split the points between fosiul01 and me. All points are assigned to me. I wish fosiul01 deserve half points.
0
 
fosiul01Commented:
LOL
0
 
Lionel35Author Commented:
sorry guys let me redo it
0
 
Lionel35Author Commented:
ha men i cant change the way i closed the question?
0
 
Lionel35Author Commented:
ok contacted customer service and asked them to split the reward between both of you sorry again for this mistake
0
 
fosiul01Commented:
haahahahaha
lol
dont worry about that
0
 
Deepak KosarajuCommented:
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
 
Lionel35Author Commented:
have a great day as well and thanks again guys
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 34
  • 17
  • 11
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now