where is hosts.cfg and service.cfg

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
sbacarach
Posts: 9
Joined: Tue Jul 07, 2015 3:14 am

where is hosts.cfg and service.cfg

Post by sbacarach »

Hello all,
I juste installing Nagios 4.0.4.
Now i would like to configure a new hosts and service.
Issue :
I don't fing this 2 files hosts.cfg and services.cfg normaly localy into /usr/local/nagios/etc/objects.

So i created this two files and add the two lignes into /usr/local/nagios/etc/nagios.cfg
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg


I restarted nagis but nagios can't with the error message.

Anyone knows where is two files ????

Thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: where is hosts.cfg and service.cfg

Post by tmcdonald »

What error message are you receiving?
Former Nagios employee
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: where is hosts.cfg and service.cfg

Post by jdalrymple »

What you did should work. What error did you receive?

That said - all of the .cfg files in use by nagios should be listed in that nagios.cfg file you're working in (unless you're using a "-d /some/different/path/nagios.cfg" when you launch Nagios.

Look for the lines that start with cfg_file and cfg_dir
sbacarach
Posts: 9
Joined: Tue Jul 07, 2015 3:14 am

Re: where is hosts.cfg and service.cfg

Post by sbacarach »

The error message when i put the 2 lignes into nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg

is error to start services nagios.

By default the hosts.cfg and services.cfg doesn't exist into nagios.cfg and this 2 files doesn't exist.

So my question is : how can i configure hosts and services for monitor any server ?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: where is hosts.cfg and service.cfg

Post by tmcdonald »

Please post the exact error message you are receiving. This will better help us determine what is wrong, whether it be permissions, mistyped filenames, or something else.

Speaking of, run the following command as root from the Nagios server command line and post the results:

Code: Select all

ls -lh /usr/local/nagios/etc/objects/
Former Nagios employee
sbacarach
Posts: 9
Joined: Tue Jul 07, 2015 3:14 am

Re: where is hosts.cfg and service.cfg

Post by sbacarach »

[root@soaserver etc]# /etc/init.d/nagios start
Starting nagios (via systemctl): Job for nagios.service failed. See 'systemctl status nagios.service' and 'journalctl -xn' for details.
[ÉCHOUÉ]
[root@soaserver etc]# journalctl -xn
-- Logs begin at mer. 2015-07-08 17:28:44 CEST, end at ven. 2015-07-10 16:44:32
juil. 10 16:44:32 soaserver nagios[11966]: ***> One or more problems was encount
juil. 10 16:44:32 soaserver nagios[11966]: Check your configuration file(s) to e
juil. 10 16:44:32 soaserver nagios[11966]: directives and data defintions. If y
juil. 10 16:44:32 soaserver nagios[11966]: version of Nagios, you should be awar
juil. 10 16:44:32 soaserver nagios[11966]: may have been removed or modified in
juil. 10 16:44:32 soaserver nagios[11966]: the HTML documentation regarding the
juil. 10 16:44:32 soaserver nagios[11966]: 'Whats New' section to find out what
juil. 10 16:44:32 soaserver systemd[1]: nagios.service: control process exited,
juil. 10 16:44:32 soaserver systemd[1]: Failed to start LSB: Starts and stops th
-- Subject: Unit nagios.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel
--
-- Unit nagios.service has failed.
--
-- The result is failed.
juil. 10 16:44:32 soaserver systemd[1]: Unit nagios.service entered failed state
lines 1-18/18 (END)

Result of ls -lh /usr/local/nagios/etc/objects/

ls -lh /usr/local/nagios/etc/objects/
total 104K
-rw-rw-r--. 1 nagios nagios 7,6K 7 juil. 10:04 commands.cfg
-rw-rw-r--. 1 nagios nagios 7,6K 7 juil. 10:04 commands.cfg~
-rw-rw-r--. 1 nagios nagios 2,1K 7 juil. 10:04 contacts.cfg
-rw-rw-r--. 1 nagios nagios 2,1K 7 juil. 10:04 contacts.cfg~
-rw-r--r--. 1 root root 91 9 juil. 16:20 hosts.cfg
-rw-rw-r--. 1 nagios nagios 5,3K 7 juil. 10:04 localhost.cfg
-rw-rw-r--. 1 nagios nagios 5,3K 7 juil. 10:04 localhost.cfg~
-rw-rw-r--. 1 nagios nagios 3,1K 7 juil. 10:04 printer.cfg
-rw-rw-r--. 1 nagios nagios 3,1K 7 juil. 10:04 printer.cfg~
-rw-r--r--. 1 root root 261 9 juil. 16:24 services.cfg
-rw-rw-r--. 1 nagios nagios 3,2K 7 juil. 10:04 switch.cfg
-rw-rw-r--. 1 nagios nagios 3,2K 7 juil. 10:04 switch.cfg~
-rw-rw-r--. 1 nagios nagios 11K 7 juil. 10:04 templates.cfg
-rw-rw-r--. 1 nagios nagios 11K 7 juil. 10:04 templates.cfg~
-rw-rw-r--. 1 nagios nagios 3,2K 7 juil. 10:04 timeperiods.cfg
-rw-rw-r--. 1 nagios nagios 3,2K 7 juil. 10:04 timeperiods.cfg~
-rw-rw-r--. 1 nagios nagios 3,9K 7 juil. 10:04 windows.cfg
-rw-rw-r--. 1 nagios nagios 3,9K 7 juil. 10:04 windows.cfg~

I added files hosts.cfg and services.cfg
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: where is hosts.cfg and service.cfg

Post by tmcdonald »

Most likely permissions issues. Please run the following commands as root from the Nagios server command line and post the results:

Code: Select all

chown nagios.nagios /usr/local/nagios/etc/objects/hosts.cfg
chown nagios.nagios /usr/local/nagios/etc/objects/services.cfg
chmod 664 /usr/local/nagios/etc/objects/hosts.cfg
chmod 664 /usr/local/nagios/etc/objects/services.cfg
/etc/init.d/nagios restart
Former Nagios employee
sbacarach
Posts: 9
Joined: Tue Jul 07, 2015 3:14 am

Re: where is hosts.cfg and service.cfg

Post by sbacarach »

I modified the security file and i had the same issue

Restarting nagios (via systemctl): Job for nagios.service failed. See 'systemctl status nagios.service' and 'journalctl -xn' for details.
[ÉCHOUÉ]
[root@soaserver objects]# journalctl -xn
-- Logs begin at mer. 2015-07-08 17:28:44 CEST, end at ven. 2015-07-10 16:56:12
juil. 10 16:56:12 soaserver nagios[12738]: ***> One or more problems was encount
juil. 10 16:56:12 soaserver nagios[12738]: Check your configuration file(s) to e
juil. 10 16:56:12 soaserver nagios[12738]: directives and data defintions. If y
juil. 10 16:56:12 soaserver nagios[12738]: version of Nagios, you should be awar
juil. 10 16:56:12 soaserver nagios[12738]: may have been removed or modified in
juil. 10 16:56:12 soaserver nagios[12738]: the HTML documentation regarding the
juil. 10 16:56:12 soaserver nagios[12738]: 'Whats New' section to find out what
juil. 10 16:56:12 soaserver systemd[1]: nagios.service: control process exited,
juil. 10 16:56:12 soaserver systemd[1]: Failed to start LSB: Starts and stops th
-- Subject: Unit nagios.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel
--
-- Unit nagios.service has failed.
--
-- The result is failed.
juil. 10 16:56:12 soaserver systemd[1]: Unit nagios.service entered failed state
lines 1-18/18 (END)
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: where is hosts.cfg and service.cfg

Post by jdalrymple »

Code: Select all

journalctl --no-tail --no-pager | grep nagios
please
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: where is hosts.cfg and service.cfg

Post by tmcdonald »

- What OS and version is this on?

- Please run the following and post the output: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

- What do you mean by "the security file"?
Former Nagios employee
Locked