Cannot find hosts.cfg


#1

Hi all,

I got the following error when running nagios -v on nagios.cfg
Reading configuration data…

Running pre-flight check on configuration data…

Checking services…
Error: There are no services defined!
Checked 0 services.
Checking hosts…
Error: There are no hosts defined!
Checked 0 hosts.
Checking host groups…
Error: There are no host groups defined!
Checked 0 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Error: There are no contacts defined!
Checked 0 contacts.
Checking contact groups…
Error: There are no contact groups defined!
Checked 0 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 22 commands.
Checking time periods…
Checked 0 time periods.
Checking extended host info definitions…
Checked 0 extended host info definitions.
Checking extended service info definitions…
Checked 0 extended service info definitions.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors: 5

***> One or more problems was encountered while running the pre-flight check…

 Check your configuration file(s) to ensure that they contain valid
 directives and data defintions.  If you are upgrading from a previous
 version of Nagios, you should be aware that some variables/definitions
 may have been removed or modified in this version.  Make sure to read
 the HTML documentation regarding the config files, as well as the
 'Whats New' section to find out what has changed.

There is no hosts.cfg file in the etc of nagios.
How should it be created?

Thanks & Regards


#2

When you ran
make all
you should pay attention to the other makes, you can run.
So, run it again, and read what it has to say after it has run
make all
there is a make that will install sample config files. Those are just examples.
You should then follow the nagios docs, and configure each and every item, like hosts, services, hostgroups, contacts, etc… These are not trivial, and nobody can make these for you. It’s up to you, to follow the docs, and define all these things.
Files you should have when done
/usr/local/nagios/etc/checkcommands.cfg
/usr/local/nagios/etc/misccommands.cfg
/usr/local/nagios/etc/contactgroups.cfg
/usr/local/nagios/etc/contacts.cfg
/usr/local/nagios/etc/dependencies.cfg
/usr/local/nagios/etc/escalations.cfg
/usr/local/nagios/etc/hostgroups.cfg
/usr/local/nagios/etc/servicegroups.cfg
/usr/local/nagios/etc/hosts.cfg
/usr/local/nagios/etc/services.cfg
/usr/local/nagios/etc/timeperiods.cfg
/usr/local/nagios/etc/hostextinfo.cfg
/usr/local/nagios/etc/serviceextinfo.cfg

If you choose to deviate from this, then we won’t be able the communicate with each other when troubleshooting.
Each of those files must be defined in the nagios.cfg file and where it is located. You can comment out some files like /usr/local/nagios/etc/escalations.cfg if you don’t want excalations.