go-nagios-api

command module
v0.0.0-...-10ba01b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

Nagios JSON API

Intended to provide a JSON API like features for Nagios installations. Its written in golang and therefore systems wanting to run it only need to run a single binary for their distribution.

Installation:

Follow golang installation to install golang.

Clone this repo.

Run: go build . from inside repo directory.

You can now use the standalone binary to run the service.

Run:

$ ./go-nagios-api --addr=:9090 --cachefile=/opt/nagios/object.cache --statusfile=/opt/nagios/status.dat --commandfile=/opt/nagios/nagios.cmd

Or you can provide a configuration file with these parameter in json format (configuration file overwrites cli flags)

$ ./go-nagios-api --config=nagios-api.json

It will start the api service on port 8080. If you wish to change the port simply pass --addr=:80 to make it run on port 80. For running in production see init scripts.

API Calls

Hosts and Services
 GET /hosts : get all configured hosts
 GET /host/<hostname> : get this host
 GET /hoststatus : get all hoststatus
 GET /hoststatus/<hostname> : get hoststatus for this host
 GET /hostgroups : get all configured hostgroups
 GET /services : get all configured services
 GET /servicestatus : get all servicestatus
 GET /servicestatus/<servicename> : get service status for this service
External Commands
POST /disable_notifications 
POST /enable_notifications
POST /disable_host_check  
POST /enable_host_check   
POST /disable_host_notifications
POST /enable_host_notifications
POST /acknowledge_host_problem
POST /acknowledge_service_problem
...
see code for full list of available commands.
Examples
To disable host check for host host1.example.net
curl -i -XPOST http://127.0.0.1:9090/disable_host_check -d '{"hostname": "host1.example.net"}'

To disable notification for all hosts
curl -i -XPOST http://127.0.0.1:9090/disable_notifications

To get all configured hostgroups
curl -i http://127.0.0.1:9090/hostgroups

To disable host check for a particular hostgroup
curl -i -XPOST http://127.0.0.1:9090/disable_hostgroup_host_checks -d '{"hostgroup":"AwesomeHostGroup"}'

To get details for a given host host1.example.net
curl -i http://127.0.0.1:9090/host/host1.example.net
Missing feature or command

If there is a feature that you would like to have and is missing please open an issue. Alternatively, write the feature and make a pull request.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL