My charm plays nicely with nagios much thatnx to the superb help from @mthaddon. To this point its been really helpful and I’m successfully using it to send alerts now also to pagerduty.
However, it seems I can’t get nagios to understand the config.yaml elements from my related charm “polkadot”:
juju config nagios_servicegroups = "rpc"
or
juju config nagios_context = "dwellir"
This has no impact on the nagios side of things.
In the interface there is nothing like what I use:
… and the code from the ops side of things looks like this:
def render_checks(self):
"""Render nrpe checks."""
nrpe = NRPE()
if not os.path.exists(self.plugins_dir):
os.makedirs(self.plugins_dir)
# Register a basic test.
# Just add more with add_check before nrpe.write()
nrpe.add_check(
shortname="check-substrate",
description="RPC blocksync",
check_cmd="check_substrate.sh",
)
nrpe.write()
The local-monitors interface behaves in a similar way to the nrpe-external-master interface. For example, charm-nrpe will aggregate the relation data from both interfaces and send it to charm-nagios via the monitors interface (see the implementation in charmhelpers lib).
In the pastebin that I shared, you can see a target-id attribute that is updated on the nrpe application, and shared with nagios via the monitors interface.
The charm code you shared implements the local-monitors interface, but not the monitors one, so Nagios will use its own default settings for “context”.
Note: if juju config nagios nagios_host_context="test2" is used, that value will only affect the hosts and services created for the nagios host itself (e.g. in the localhost_nagios2.cfg file).
I’ll try have a look at this since there are some pieces I don’t get.
My ambition is to somehow be able to group monitored units based on where they are coming from in terms of models. I haven’t been able to get there apart from what `nagios_host_context provides which is not enough…
The charmhelpers lib already supports the nagios_servicegroups config parameter, which is optional on principal charms.
The approach is to use 3 different charms:
The nagios charm (relates to the nrpe charm via the monitors interface)
The nrpe subordinate charm (relates to nagios via monitors, and to a principal charm via the subordinates nrpe-external-master or local-monitors relations)
A principal charm which allows nagios_context and nagios_servicegroups in its config.yaml file (relates to the nrpe charm).