fredian07
(Petre Fredian Gradinaru)
March 27, 2019, 9:21am
1
Hello,
Is there a way to extract/filter all servers/services that have not defined any contact to receive a notification ?
Cheers,
Petre
dnsmichi
(Michael Friedrich)
March 27, 2019, 9:58am
2
Hi,
rephrase that question to “get all host/services which don’t have any notification object”, since 2.x doesn’t have direct host/service contacts anymore.
A while ago I’ve written a small script which you can modify for your own needs.
#!/usr/bin/env python
# pip install icinga2api
# https://github.com/tobiasvdk/icinga2api
import os
import argparse
from icinga2api.client import Client
# use a helper to fetch our cut down object names
def getObjects(client, type_name):
if 'Notification' == type_name:
return client.objects.list(type_name, attrs=['__name'])
else:
return client.objects.list(type_name, attrs=['__name', 'groups'])
# use a helper to convert the full blown object dictionary into a list of __name elements
def getNameList(objects, group = ''):
if group:
return map(lambda x : x['attrs']['__name'], filter(lambda y : group in y['attrs']['groups'], objects))
This file has been truncated. show original
Cheers,
Michael
fredian07
(Petre Fredian Gradinaru)
March 28, 2019, 11:22am
3
Hi,
Thank you very much. It’s exactly what i need.
Cheers,
Petre