Thanks for all the contributions to this project - its docs have been moved into the official documentation.
Please send patches and PRs to the icinga2 repository.
Examples for the Icinga 2 API
Thanks for all the contributions to this project - its docs have been moved into the official documentation.
Please send patches and PRs to the icinga2 repository.
icinga2-api-examples/aws-ec2/icinga2_ec2
Line 121 in 941d3ab
icinga2-api-examples/aws-ec2/icinga2_ec2
Line 123 in 941d3ab
icinga2-api-examples/aws-ec2/icinga2_ec2
Line 124 in 941d3ab
icinga2-api-examples/aws-ec2/icinga2_ec2
Line 125 in 941d3ab
it should be changed from pki to /var/lib/icinga2/certs
This script doesn't seem to work with python 3.6. Mainly, print statements now need parenthesis and it seems a 'list' function needed added when getting the host, service, and notifications. I seemed to be able to get it running with the following changes. Not a coding expert but thought I'd post what I had here for you to review...
#!/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))
else:
return map(lambda x : x['attrs']['__name'], objects)
def diffList(l1,l2):
l2 = set(l2)
return [x for x in l1 if x not in l2]
# add connection details
parser = argparse.ArgumentParser()
parser.add_argument("-H", "--hosturi", help="URL to icinga2 API", required=True)
parser.add_argument("-u", "--username", help="Username to connect to API", required=True)
parser.add_argument("-p", "--password", help="Password to connect to API", required=True)
parser.add_argument("-g", "--group", help="Group to filter", required=False)
args = parser.parse_args()
client = Client(args.hosturi, args.username, args.password)
hosts = getObjects(client, 'Host')
services = getObjects(client, 'Service')
notifications = getObjects(client, 'Notification')
#debug
#print (hosts)
#print (services)
#print (notifications)
if not args.group:
h_names = list(getNameList(hosts, False))
s_names = list(getNameList(services, False))
else:
h_names = list(getNameList(hosts, args.group))
s_names = list(getNameList(services, args.group))
n_names = list(getNameList(notifications))
found_h_names = []
found_s_names = []
for n in n_names:
split_arr = n.split("!")
if len(split_arr) == 2:
for h in h_names:
# debug
# print (n + " " + h)
if h in split_arr[0]:
found_h_names.append(h)
if len(split_arr) == 3:
for s in s_names:
# debug
# print (n + " " + s)
# rebuild the matched full service name with host!service
split_s_full_name = split_arr[0] + "!" + split_arr[1]
if s in split_s_full_name:
found_s_names.append(s)
print("Hosts without notification")
print (", ".join(diffList(h_names, found_h_names)))
print ("")
print("Services without notification")
print (", ".join(diffList(s_names, found_s_names)))
Hi ,
I would like to one specific service check from the API for a specific host. Do you know what is the API for the same.
Lets say , I have a service called "http" from hosts - nagios1.example.com. I would like to acknowledge only this service check.
Thanks
Aravind
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.