Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am reading the nagios.cfg file documentation and cannot see where it says what options are required and what options are optional. Are all of these optional? If not where can I find which are optional?

http://nagios.sourceforge.net/docs/nagioscore/3/en/configmain.html

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Backup the configuration file:

# cp -a /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg.bak

Comment out all the options:

# sed -i 's/^/#/' /usr/local/nagios/etc/nagios.cfg

and verify the configuration data:

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

you will see something like this:

Checking services...
Error: There are no services defined!
    Checked 0 services.
Checking hosts...
Error: There are no hosts defined!
    Checked 0 hosts.
Checking contacts...
Error: There are no contacts defined!
    Checked 0 contacts.
...
Total Warnings: 0
Total Errors:   3

So, you need to include some config files which defined at least a host, some services and a contact:

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/localhost.cfg

Reverify:

Checking services...
    Checked 8 services.
Checking hosts...
    Checked 1 hosts.
Checking contacts...
    Checked 34 contacts.
...

Total Warnings: 0
Total Errors:   0
share|improve this answer
    
It's much cleaner to use cfg_dir, rather than a long list of cfg_file lines. Any file whose name ends with .cfg in the cfg_dir will be (recursively) included (concatenated) prior to conf parsing. This allows you to structure your config in a way that makes the most sense to you (e.g., by client, by subnet, by OS type, by tier, etc.) –  Keith Dec 28 '11 at 22:27

Usually, when a configuration option is not specified, it will be assigned a default value. Yes, the link you posted does not state whether an option is optional or not. However, default values are specified. If such a value is suitable for your needs, you don't need to include it in your config or you can include it commented out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.