Skip to content

Commit

Permalink
chore: add notes on API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wbollock committed Sep 1, 2022
1 parent 2bf8f63 commit 4619ed6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# nagiosxi_exporter
# nagiosxi_exporter

## Resources

### Exporter examples

* [haproxy_expoter](https://github.com/prometheus/haproxy_exporter/blob/main/haproxy_exporter.go)
* [15 Steps to Write an Application Prometheus Exporter in GO](https://medium.com/teamzerolabs/15-steps-to-write-an-application-prometheus-exporter-in-go-9746b4520e26)
* [curl-to-go](https://mholt.github.io/curl-to-go/)
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/wbollock/nagiosxi_exporter
module github.com/wbollock/nagios_exporter

go 1.19

require github.com/prometheus/client_golang v1.13.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
71 changes: 67 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,78 @@ import (
"fmt"
"os/exec"
"log"
"net/http"


"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
# begin by initializing prometheus metrics
// api notes
// http://139.144.16.126/nagiosxi/help/?xiwindow=api-object-reference.php

// starter API calls and metrics
// remember get more ideas with `/usr/local/nagios/bin/nagiostats -c /usr/local/nagios/etc/nagios.cfg`

// curl
// curl -XGET "http://139.144.16.126/nagiosxi/api/v1/objects/hosts?apikey=<key>"


// Hosts
// Total Hosts - objects/hostatus | jq '.recordcount'
// Hosts Actively Checked: - objects/hoststatus | jq '.recordcount'
// note - check_type 1 = passive
// Host Passively Checked: 0
// "hoststatus": [
// { ..
// "check_type" : 0 (active), 1 (passive)
// }
// Hosts Up/Down/Unreach
// "current_state": "0", (up) 1 (down) 2 (unreach)
// Hosts Flapping
// "is_flapping": "0",
// Hosts in Downtime
// "scheduled_downtime_depth": "1", (1 = downtime, 0 = no downtime.. the depth is a little concerning)

// Services
// Total Services: 25
// recordcount

// Services Checked: 24
// "has_been_checked": "0", (1 not checked yet )
// Services Scheduled: 25
// "should be scheduled": "0", (1 not scheculed )
// Services Actively Checked: 25
// "check_type": "0",
// Services Passively Checked: 0
// "check_type": "1", - just weird that the passive check I made is 0 for this..
// Services Ok/Warn/Unk/Crit: 24 / 0 / 1 / 0
// Services Flapping: 0
// "is_flapping": "0", (1 is flapping)
// Services In Downtime: 0
// // "scheduled_downtime_depth": "1", (1 = downtime, 0 = no downtime)

// Checks
// Active host checks scheduled
// "check_type": "0", and "should_be_scheduled": "1",
// Passive host checks scheduled
// "check_type": "1", and "should_be_scheduled": "1",

// Misc
// Version info: api/v1/system/info

// begin by initializing prometheus metrics

// spin up a prometheus client

// gather metrics and push them to the client

# spin up a prometheus client
// parse a config - let the user specify a port and where the application lives, maybe also a debug mode and where to log to
// also path to nagios config and nagiosxi
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":9101", nil))

# gather metrics and push them to the client

# parse a config - let the user specify a port and where the application lives, maybe also a debug mode and where to log to
}

0 comments on commit 4619ed6

Please sign in to comment.