need deep understanding of nagios

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.
Locked
h.sabrey
Posts: 30
Joined: Sun Jun 14, 2015 7:18 am

need deep understanding of nagios

Post by h.sabrey »

Gents, greetings.

after installing the Nagios, and taking long time of reading about how to configure hosts in it, i'm quite confused of the following.

1- in the file /usr/local/nagios/etc/objects/nagios.cfg after removing the "#" from the following lines, nagios start to monitor them,

Code: Select all

# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg

# Definitions for monitoring a router/switch
cfg_file=/usr/local/nagios/etc/objects/switch.cfg

# Definitions for monitoring a network printer
cfg_file=/usr/local/nagios/etc/objects/printer.cfg
1.1 what is the link between this files and the files supposed to be in the folders as below??

Code: Select all

cfg_dir=/usr/local/nagios/etc/servers
cfg_dir=/usr/local/nagios/etc/printers
cfg_dir=/usr/local/nagios/etc/switches
cfg_dir=/usr/local/nagios/etc/routers
1.2 in particular can i put the file /usr/local/nagios/etc/objects/switch.cfg in the cfg_dir=...../switches?
1.3.a what about the routers?
1.3.b: are they sharing the same object_file "cfg_file=/.../switch.cfg" with the switches?
1.4 if 1.3.b is yes, i have 100 router in our network to be monitored, how to build a common_cfg_file for all routers and then set specific cfg upon demand for the desired router for monitoring?

i may say in short the process link between cfg_files are not clear for me yet

appreciate your help.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: need deep understanding of nagios

Post by Box293 »

h.sabrey wrote:1.1 what is the link between this files and the files supposed to be in the folders as below??
cfg_file is for pointing to a specific nagios definition file.
cfg_dir will use all the nagios defintion .cfg files in the folder specified.

cfg_dir is handy when you have an automated provisioning system that dumps configs into this directory and restarts nagios, it doesn't need to update the nagios.cfg file to point to the new config file.
h.sabrey wrote:1.2 in particular can i put the file /usr/local/nagios/etc/objects/switch.cfg in the cfg_dir=...../switches?
Yes
h.sabrey wrote:1.3.a what about the routers?
1.3.b: are they sharing the same object_file "cfg_file=/.../switch.cfg" with the switches?
So the names of the config files switch.cfg or windows.cfg can be anything, they could be pink_elephants.cfg and white_mice.cfg, it is entirely up to how you name them based on how you would like to sort objects.

There is no reason why you couldn't have one single config file for all objects. Breaking it up into separate files just makes it easier to administer.

The separate files can reference objects defined in other files, like commands or templates.

When nagios starts, it gathers all the config files and looks at all the configs, checking to make sure everything has been correctly defined. If one config file references a command or template defined elsewhere, it'll work it out.
h.sabrey wrote:1.4 if 1.3.b is yes, i have 100 router in our network to be monitored, how to build a common_cfg_file for all routers and then set specific cfg upon demand for the desired router for monitoring?
Create a hostgroup called "routers".
Add all your routers to this hostgroup.
For all of your services for the routers, assign them to the host_group directive instead of the host_name directive.
This way all these routers will have the same services monitored.

Here's an example:
http://sites.box293.com/nagios/guides/c ... n-services

Does this help?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
h.sabrey
Posts: 30
Joined: Sun Jun 14, 2015 7:18 am

Re: need deep understanding of nagios

Post by h.sabrey »

Box293 wrote:Does this help?
yes it really helps a lot many thanks to you bro, and just to confirm as i've made some changes and got nagios not working

switch file has been used to be a test for the first router thus i want to change the "generic-switch" to "generic-router" nagios refused it, why is it a template directive? if so where is it and can i set my own or no?

for the host group method, i'll have on file for the services and another file for the hosts? appreciate you support for detailing this point exactly.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: need deep understanding of nagios

Post by Box293 »

h.sabrey wrote:switch file has been used to be a test for the first router thus i want to change the "generic-switch" to "generic-router" nagios refused it, why is it a template directive? if so where is it and can i set my own or no?
You've changed the name of "generic-switch" and other objects use it with the "use generic-switch" directive. So now those other objects can't find it and that is why Nagios is broken.

You're better off creating a duplicate of the "generic-switch" entry and call it "generic-router" and adjust it as needed.

An object is a template when it has "register 0" in it's definition.

This guide should explain how templates work:
https://assets.nagios.com/downloads/nag ... tance.html
h.sabrey wrote:for the host group method, i'll have on file for the services and another file for the hosts? appreciate you support for detailing this point exactly.
That is entirely your decision and how you think it's easiest to administer in the future. It has no affect on how nagios works, it just sees a bunch of config files and gets the information from all of them.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
h.sabrey
Posts: 30
Joined: Sun Jun 14, 2015 7:18 am

Re: need deep understanding of nagios

Post by h.sabrey »

many thanks Box293
the mistake:
hsabrey wrote:switch file has been used to be a test for the first router thus i want to change the "generic-switch" to "generic-router" nagios refused it, why is it a template directive? if so where is it and can i set my own or no?
Solution:
to build the Router directive, new directive to be added in the /object/template.cfg as "generic-router", then to be called at the desired location.


Idea:
in case of having a considerable number of Network Elements to be added to the monitoring it is better to siplet the service, hostgroup, and the device itself, so in my case i have some count of 100 Network Element between routers antennas, printers, and others.
so for the routers, as they are grouped per logical function i.e. NAS(s), Edge, Core so these are hostgroups.
as for the antennas, they are grouped based on the tower they are connected to, thus TowerName is the hostgroups

Workout:
the "/object/template" is the playground to create new generic_hosts, "generic-router", "generic-tower".
-- define the required services to be monitored in a separate config file name it as you like, but for me i prefer to name it based on the discipline i.e. serviceRouters.cfg serviceAntennas.cfg
-- define the required hostgroups based on your network structure in a file name hostgroups.cfg
-- define the required network element config file independently; this gives the option to add more specific monitoring services additional to the general service, i.e. site1.cfg, router1.cfg or tower1.cfg; this will help you and give you an easy way for scalability and direct to the point method to find, modify, any NE.


thanks to all whom supported me to get more knowledge...

this article to be marked as closed.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: need deep understanding of nagios

Post by Box293 »

Excellent, glad we could give you a deeper understanding of how nagios config files work.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked