Contacts not updated

Hi all

I ran into a problem when updating ‘vars.notification.mail.users’. I send an update request through the API, I can see (in the web interface) that it made it into the config. However, the “Contacts” information is not updated and no emails are sent.
Do I have to trigger the update somehow? I couldn’t find any hint in the docu or elsewhere.

BTW, this is the first issue I ran into and I’m monitoring >1000 host and approx. 4000 services. Thanks to whoever wrote the documentation!
Maybe I’m just suffering from fatigue :slight_smile:

best
Niko

Hi,

Can you share the API requests and the results (as text or screenshot)?

Does it work when you restart the icinga2 daemon manually?

Cheers,
Michael

PS: Thanks for the docs feedback, much appreciated :kissing_heart:

Hi Michael

restarting icinga (neither on the master, nor on the satellite) didn’t trigger the newly set user to take effect.

here are some lines of code and the API result

API script
import requests, json

req_url = 'https://myHostname:myAPIPort/v1/objects/hosts/S10-CPPM-MOT0991'
headers = { 'Accept': 'application/json', 'X-HTTP-Method-Override': 'POST' }
data = {
  "attrs": {
    'vars.notification.mail.users': ['alarcon_a'],
    'vars.IOCs': {
      'S10-CPPM-MOT0991':
        { 'server' : 's10-cppm-mot0991', 'port': '50001', 'owner': 'alarcon_a' }
    }
  }
}
resp = requests.get(req_url, headers=headers, auth=('root', 'icingaadmin'), data=json.dumps(data), verify=False)

if (resp.status_code == 200):
  print("Result: " + json.dumps(resp.json(), indent=4, sort_keys=True))
else:
  print(resp.text)
API result
Result: {
    "results": [
        {
            "code": 200.0,
            "name": "S10-CPPM-MOT0991",
            "status": "Attributes updated.",
            "type": "Host"
        }
    ]
}

two screenshots of the host in question, left before, right after. Notice the change in 'Notification" near the bottom.

screenshots

During the test I noticed that the API isn’t checking whether the user actually excists, is that right?
So far I didn’t use the API, I created the config fiels per script from databases holding the host information. I’d like to switch to the API however, in order to avoid the step of creating config files.

best
Niko

Ah. You’re changing a custom attribute, not the notification object. That won’t work, apply rules are not evaluated after a (custom) attribute change.

If you really want to manage everything using the REST APi, I’d suggest to also create notification objects and modify their user attributes then.

Cheers,
Michael

Thanks for swift reply, I see problem now.

What’s the best way to handle configs for a highly heterogeneous environment?
This is for a particle accelerator control system. Meaning, we have everything from ancient hardware - that’s older than me - to cutting edge stuff. Also, inherently it’s scattered around and split into several separated sub-nets.
Any suggestion appreciated!

best
Niko