Page 1 of 1

Challenge with object inheritance

Posted: Thu Feb 11, 2021 11:45 am
by inversecow
Ahoy folks,

I have a bit of an "inheritance" bind, by the feel of it.

I am attempting to leverage the magic of inheritance via a combo of SERVICE TEMPLATES and SERVICE DEFINITIONS.
In the present scenario, this would be paired with ACTIVE monitor checks against a collection of Oracle dBs.

I already have this going using one SERVICE TEMPLATE, to many SERVICE DEFINITIONS
However, that felt less than elegant, with some duplication of settings / effort.

To this end, I though to try and "bake more" into the TEMPLATES level, leaving the DEFINITIONS level cleaner for the specifics of the specific instance of monitor.
Thus, I created the following (as detailed below, for reference sake).
Do note, I am using Custom Variables to "load" the SID, UN, and PASSWD values on a per SERVICE DEFINITION basis.

On the surface, I would have expected the SERVICE TEMPLATE to grant "partial inheritance" of its completed values, to be passed down to the SERVICE DEFINITIONS that are associated to "use" it.
While this mostly works (as has been the case with a number of other monitors in play), I note a strange behavior.

Do observe that while I have clearly different TEMPLATE & DEFINITIONS, for some reason the DEFINITIONS "Free Variables" are cross-pollinating into one-another.
This manifests when I look at my SERVICE STATUS panel within XI, and also in the object.cache file on disk.

I reviewed the vendor docs for Nagios CORE (Object Inheritance With Templates), and went so far as to create versions of the Free Variables with "null" as their values.
This ultimately proved in-effective however.

Curious to know how I might avoid this behavior?

Signed,
-Rowan

---

XI: 5.6.x
MariaDB: 5.5.64.x (off-box)
CCM: 3.0.5
CORE: 4.x

https://assets.nagios.com/downloads/nag ... tance.html

---

# service_template

```
define service {
name TEAM_oracletablespace_service_connection-time
hostgroup_name dba-servers_oracle
service_description TEAM_oracletablespace_service_connection-time
servicegroups TEAM-oracle-monitors
check_command CUSTOM_check_xi_oracle_connection-time!--connect '$HOSTADDRESS$:1521/$_SERVICEORACLE_SID$' --username '$_SERVICEUN$' --password '$_SERVICEPASSWD$'!!!!!!!
initial_state o
max_check_attempts 5
check_interval 5
retry_interval 1
active_checks_enabled 1
check_period 24x7
event_handler_enabled 0
flap_detection_enabled 0
process_perf_data 1
notification_period 24x7
notification_options w,c,u,r,
notifications_enabled 1
contact_groups TEAM-info
register 0
}
```

# service_definitions
## def1

```
define service {
host_name host1.fqdn
service_description connection-time: ora1.host1.fqdn
use TEAM_oracletablespace_service_connection-time
_oracle_sid ora1
_passwd S3cr3TP4ssW0rD
_un dba_admin
register 1
}
```

## def2

```
define service {
host_name host2.fqdn
service_description connection-time: ora2.host2.fqdn
use TEAM_oracletablespace_service_connection-time
_oracle_sid ora2
_passwd S3cr3TP4ssW0rD
_un dba_admin
register 1
}
```

# /usr/local/nagios/var/objects.cache

```
define service {
host_name host1.fqdn
service_description connection-time: ora1.host1.fqdn
check_period 24x7
check_command TEAM_check_xi_oracle_connection-time!--connect '$HOSTADDRESS$:1521/$_SERVICEORACLE_SID$' --username '$_SERVICEUN$' --password '$_SERVICEPASSWD$'!!!!!!!
contact_groups TEAM-info
notification_period 24x7
initial_state o
importance 0
check_interval 5.000000
retry_interval 1.000000
max_check_attempts 5
is_volatile 0
parallelize_check 1
active_checks_enabled 1
passive_checks_enabled 1
obsess 1
event_handler_enabled 0
low_flap_threshold 0.000000
high_flap_threshold 0.000000
flap_detection_enabled 0
flap_detection_options a
freshness_threshold 0
check_freshness 0
notification_options r,w,u,c
notifications_enabled 1
notification_interval 2.000000
first_notification_delay 0.000000
stalking_options n
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
_ORACLE_SID ora1
_PASSWD S3cr3TP4ssW0rD
_UN dba_admin
}
...
define service {
host_name host1.fqdn
service_description connection-time: ora2.host2.fqdn
check_period 24x7
check_command TEAM_check_xi_oracle_connection-time!--connect '$HOSTADDRESS$:1521/$_SERVICEORACLE_SID$' --username '$_SERVICEUN$' --password '$_SERVICEPASSWD$'!!!!!!!
contact_groups TEAM-info
notification_period 24x7
initial_state o
importance 0
check_interval 5.000000
retry_interval 1.000000
max_check_attempts 5
is_volatile 0
parallelize_check 1
active_checks_enabled 1
passive_checks_enabled 1
obsess 1
event_handler_enabled 0
low_flap_threshold 0.000000
high_flap_threshold 0.000000
flap_detection_enabled 0
flap_detection_options a
freshness_threshold 0
check_freshness 0
notification_options r,w,u,c
notifications_enabled 1
notification_interval 2.000000
first_notification_delay 0.000000
stalking_options n
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
_ORACLE_SID ora2
_PASSWD S3cr3TP4ssW0rD
_UN dba_admin
}
...
define service {
host_name host2.fqdn
service_description connection-time: ora1.host1.fqdn
check_period 24x7
check_command TEAM_check_xi_oracle_connection-time!--connect '$HOSTADDRESS$:1521/$_SERVICEORACLE_SID$' --username '$_SERVICEUN$' --password '$_SERVICEPASSWD$'!!!!!!!
contact_groups TEAM-info
notification_period 24x7
initial_state o
importance 0
check_interval 5.000000
retry_interval 1.000000
max_check_attempts 5
is_volatile 0
parallelize_check 1
active_checks_enabled 1
passive_checks_enabled 1
obsess 1
event_handler_enabled 0
low_flap_threshold 0.000000
high_flap_threshold 0.000000
flap_detection_enabled 0
flap_detection_options a
freshness_threshold 0
check_freshness 0
notification_options r,w,u,c
notifications_enabled 1
notification_interval 20.000000
first_notification_delay 0.000000
stalking_options n
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
_ORACLE_SID ora1
_PASSWD S3cr3TP4ssW0rD
_UN dba_admin
}
...
define service {
host_name host2.fqdn
service_description connection-time: ora2.host2.fqdn
check_period 24x7
check_command TEAM_check_xi_oracle_connection-time!--connect '$HOSTADDRESS$:1521/$_SERVICEORACLE_SID$' --username '$_SERVICEUN$' --password '$_SERVICEPASSWD$'!!!!!!!
contact_groups TEAM-info
notification_period 24x7
initial_state o
importance 0
check_interval 5.000000
retry_interval 1.000000
max_check_attempts 5
is_volatile 0
parallelize_check 1
active_checks_enabled 1
passive_checks_enabled 1
obsess 1
event_handler_enabled 0
low_flap_threshold 0.000000
high_flap_threshold 0.000000
flap_detection_enabled 0
flap_detection_options a
freshness_threshold 0
check_freshness 0
notification_options r,w,u,c
notifications_enabled 1
notification_interval 20.000000
first_notification_delay 0.000000
stalking_options n
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
_ORACLE_SID ora2
_PASSWD S3cr3TP4ssW0rD
_UN dba_admin
}
```

Re: Challenge with object inheritance

Posted: Fri Feb 12, 2021 4:46 pm
by benjaminsmith
Hi Rowan,

The service template has a hostgroup directive (hostgroup_name dba-servers_oracle), and I think what might be happening is if both of these hosts are also members of that hostgroup, then they are both being added to ora1.host1.fqdn and ora2.host2.fqdn services.

Try removing this from the template and then apply configuration and let me know if that works.

If not, send me the system profile and I can try to import the configs on my test system.

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button

Re: Challenge with object inheritance

Posted: Fri Feb 12, 2021 5:06 pm
by inversecow
benjaminsmith wrote:Hi Rowan,

The service template has a hostgroup directive (hostgroup_name dba-servers_oracle), and I think what might be happening is if both of these hosts are also members of that hostgroup, then they are both being added to ora1.host1.fqdn and ora2.host2.fqdn services.

Try removing this from the template and then apply configuration and let me know if that works.

If not, send me the system profile and I can try to import the configs on my test system.

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Ahoy Benjamin,

Thank you for the analysis and response on this matter.

Confirmed both subject nodes are in this host group (HG), and the host group is a part of the service template.
The thought behind this, was to use the HG as a "mount point" of sorts for the Service Template.
We do this with ~90%+ of our other monitors (both HOST && SERVICE, which also both use a combo of Templates & definitions).

I believe the major difference here, is this is one of the first type where we use something other than a check_icmp_ping (forget exactly what ping plugin we use) or check_dummy (as most of our SERVICE monitors are passive, via NCPA / NRDP).

I will experiment with removing the hosts (which I had added to mount user visiblity permissions), then with removing the HG.
Ideally we would like to work a scenario where we can still mount these Service templates against the HGs, for maximum flexibility for our users.

Will report back with findings, and have a great weekend! :-)

Signed,
-Rowan

Re: Challenge with object inheritance

Posted: Mon Feb 15, 2021 11:51 am
by benjaminsmith
Hi Rohan,

Sounds good. I can always import your configs from a system profile to test anything out on my end. Let me know it goes.

--Benjamin