icinga2
Icinga2 Remote api module. You can create, remove, update, etc of icinga2 objects
Installation
npm install icinga2-api
Getting started
Example
- Check if the host "4demo" exist in monitoring.
- If not, create host "4demo".
Updated
The parameters 'group' and 'onServer' was removed from methode 'createHost' and 'createService'
const icingaapi = ;var icingaServer = "icingas2server.local" "5665" "apiUser" "apiUserPass";icingaServer
Methods
- getServices = function (callback)
- getService = function (ServerName, ServiceName, callback)
- getHosts = function (callback)
- getHost = function (ServerName, callback)
- getHostFiltered = function (filter, callback)
- getServiceFiltered = function(filter, callback)
- filter ="filter": "service.vars.Backup_Server == servicename""filter_vars":"servicename": "backupServer"
- filter =
- getServiceWithState = function (state, callback)
- state = 0/1/2
- createHost = function (template, host, displayname, callback)
- template - icinga2 host-template
- onServer = "dockerHost", set a custom variable in icinga2
- createService = function (template, host, service, displayname, callback)
- createServiceCustom = function (serviceObj, host, service, callback)
- serviceObj =var serviceObj = JSON
- serviceObj =
- createHostCustom = function (hostObj, host, callback)
- hostObjvar hostBody = JSON
- hostObj
- createServiceCustom = function (serviceObj, host, service, callback)
- serviceObjvar serviceBody = JSON
- serviceObj
- deleteHost = function (host, callback)
- deleteService = function (service, host, callback)
- setHostDowntime = function (dObj, hostname, callback)
- dObj (downtime object)var dObj ='type': 'Host''start_time': actTime'end_time': endtime'author': 'icingaadmin''comment': "Downtime for Backup"
- dObj (downtime object)
- setFilteredDowntime = function (dFilter, callback)
- dFilter (example: set downtime for all server where custom variable server = dockerhost)var setDownTimeObject ='type': 'Host''start_time': actTime'end_time': endtime'author': 'icingaadmin''comment': "Downtime for Backup"'filter': 'host.vars.server == server''filter_vars':'server': "dockerhost"
- dFilter (example: set downtime for all server where custom variable server = dockerhost)
- removeFilteredDowntime = function (dFilter, callback)
- dFilter(remove all Downtimes with autor "icingaadmin" and custom vars server "dockerhost"var removeDownTimeObject ="type": "Downtime""filter": "downtime.author == filterAuthor && host.vars.server == filteredHost""filter_vars":"filterAuthor": "icingaadmin""filteredHost": "dockerhost"
- dFilter(remove all Downtimes with autor "icingaadmin" and custom vars server "dockerhost"
- disableHostNotification = function (hostname, callback)
- setHostState = function (host, hostState, StateMessage, callback)
- setServiceState = function (service, host, serviceState, serviceMessage, callback)
- getHostState = function (hostName, callback)
- getServiceTemplates = function(callback)
- checkExistServiceTemplate = function(name, callback)
- getHostTemplates = function(callback)
- checkExistHostTemplate = function(name, callback)
- setServicePerfdata = function (service, server, state, output, perfarr, callback)
- perfarr (Data array) - show process-check-result in icinga2 api docvar perfdataArr = "Memory in %=" + memUsedinPerc + "%;" + aditoMemWarn + ";" + aditomemErr + ";0"
- perfarr (Data array) - show process-check-result in icinga2 api doc
- setHostPerfdata = function (server, state, output, perfarr, callback)
- updateHostAttr = function (hostObj, host, callback)
- hostObjvar hostObj = JSON
- hostObj
- updateServiceAttr = function (serviceObj, host, service, callback)
Examples
Check test.js for more details