Object file management and structure
Object file management and structure
Hi,
I have a fedora 27 system with nagios-4.3.4-3.fc27.x86_64 installed and I'm confused about how best to design the object config files that are used to store the service and host definitions.
Is it possible to define the config files based on the hostname?
The problem is that occasionally there are times when a host will go down for an extended period before I can mark it off-line, then not having a way for nagios to stop alerting me until the host can be brought back online again. A particular host may be offline for a day or longer.
I understand that once it's offline, it's not possible to mark it as offline or down for maintenance. I thought that by creating each host in its own config file that I could stop nagios, rename or move the file, then restart nagios without that host.
The problem I have is that some hosts overlap, such as with hostgroups where multiple hosts are connected.
Perhaps there's another way? Maybe I should just skip using hostgroups?
I have a fedora 27 system with nagios-4.3.4-3.fc27.x86_64 installed and I'm confused about how best to design the object config files that are used to store the service and host definitions.
Is it possible to define the config files based on the hostname?
The problem is that occasionally there are times when a host will go down for an extended period before I can mark it off-line, then not having a way for nagios to stop alerting me until the host can be brought back online again. A particular host may be offline for a day or longer.
I understand that once it's offline, it's not possible to mark it as offline or down for maintenance. I thought that by creating each host in its own config file that I could stop nagios, rename or move the file, then restart nagios without that host.
The problem I have is that some hosts overlap, such as with hostgroups where multiple hosts are connected.
Perhaps there's another way? Maybe I should just skip using hostgroups?
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Object file management and structure
A common setup is to make sub directories for hosts/services and then name each .cfg in there the hosts name.cfg
Then you are correct that if you are going to assign services to hostgroups they need to go somewhere, I would place them in the services directory with a different naming structure.
The nice thing is, if you remove the host, it is already not going to be part of the hostgroup (especially if you add the hostgroups directive in the hosts .cfg file) and so it will already automatically be removed from the service that just had the hostgroup added.
Because of this flexability Nagios Core installations are like snowflakes, no 2 are the same.
Then you are correct that if you are going to assign services to hostgroups they need to go somewhere, I would place them in the services directory with a different naming structure.
The nice thing is, if you remove the host, it is already not going to be part of the hostgroup (especially if you add the hostgroups directive in the hosts .cfg file) and so it will already automatically be removed from the service that just had the hostgroup added.
Because of this flexability Nagios Core installations are like snowflakes, no 2 are the same.
Re: Object file management and structure
Hi, thanks for your help. However, I'm not sure I understand.
If a host is a member of a hostgroup, and that host is removed, it would also have to be removed from the hostgroup config file too, defeating the whole purpose of putting each host in a separate file.
In other words, here is one hostgroup example I have:
Hostgroups by nature contain more than one host. What if one of those hosts is the one I wish to take offline? Then not only do I have to move the host config files out of the way, I have to now edit this singular file, correct?
Is there no easier way?
It would be great if there was a config option through the main web interface to mark a server offline that's already down.
If a host is a member of a hostgroup, and that host is removed, it would also have to be removed from the hostgroup config file too, defeating the whole purpose of putting each host in a separate file.
In other words, here is one hostgroup example I have:
Code: Select all
define hostgroup {
hostgroup_name GDHQ
alias Home Base
members orion,mastermind,bwimail03
}
Is there no easier way?
It would be great if there was a config option through the main web interface to mark a server offline that's already down.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Object file management and structure
Not if you set it up ad followsgossamer wrote:If a host is a member of a hostgroup, and that host is removed, it would also have to be removed from the hostgroup config file too
Code: Select all
define hostgroup {
hostgroup_name GDHQ
alias Home Base
members orion,mastermind,bwimail03
}
Code: Select all
define host {
host_name orion
use generic-host
address 1.1.1.1
hostgroups GDHQ
}
define host {
host_name mastermind
use generic-host
address 2.2.2.2
hostgroups GDHQ
}
define host {
host_name bwimail03
use generic-host
address 3.3.3.3
hostgroups GDHQ
}
Re: Object file management and structure
Thank you, I've tried that, but it doesn't work. Nagios complains about missing host definitions (mastermind is the host with the separate config):scottwilkerson wrote:Not if you set it up ad followsgossamer wrote:If a host is a member of a hostgroup, and that host is removed, it would also have to be removed from the hostgroup config file tooandCode: Select all
define hostgroup { hostgroup_name GDHQ alias Home Base members orion,mastermind,bwimail03 }
Where each of these host definitions can be in their own file.Code: Select all
define host { host_name orion use generic-host address 1.1.1.1 hostgroups GDHQ } define host { host_name mastermind use generic-host address 2.2.2.2 hostgroups GDHQ } define host { host_name bwimail03 use generic-host address 3.3.3.3 hostgroups GDHQ }
Code: Select all
Reading configuration data...
Read main config file okay...
Error: Could not find any host matching 'mastermind' (config file '/etc/nagios/objects/hostgroups.cfg', starting on line 16)
Error: Could not expand members specified in hostgroup (config file '/etc/nagios/objects/hostgroups.cfg', starting on line 16)
Code: Select all
16 define hostgroup {
17 hostgroup_name GDHQ
18 alias Home Base
19 members orion,mastermind,bwimail03
20 }
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Object file management and structure
My apologies, I meant to modify the hostgroup
It should be this
With the members removed. The member get added through the directive in the host object.
It should be this
Code: Select all
define hostgroup {
hostgroup_name GDHQ
alias Home Base
}
Re: Object file management and structure
Ah, I wasn't aware you could do that. Looks like that fixed it, thanks. I'll continue to experiment.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Object file management and structure
Sounds good!