From 510e1228a56e405fcf072a7f22d97173f7fd1cd6 Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Mon, 6 Mar 2023 17:06:06 -0500 Subject: [PATCH 1/6] ci: publish dockerimage Inspired by https://github.com/tjhop/linode-tagger/pull/2 --- .goreleaser.yaml | 17 +++++++++++++++++ Dockerfile | 15 +++++++++++++++ README.md | 15 ++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4362add..a703143 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -32,6 +32,23 @@ changelog: exclude: - '^docs:' - '^test:' +dockers: + # build latest and specific tag version images + - image_templates: + - "ghcr.io/wbollock/{{.ProjectName}}:{{ .Tag }}" + - "ghcr.io/wbollock/{{.ProjectName}}:latest" + goos: linux + goarch: amd64 + use: docker + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source=https://github.com/wbollock/nagios_exporter" + - "--label=org.opencontainers.image.description='A Prometheus Exporter for Nagios'" + - "--label=org.opencontainers.image.licenses=MIT" nfpms: - id: default formats: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..96feab4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# taken from https://github.com/prometheus/haproxy_exporter/blob/d4aba878f043fd3ad0bcacd0149e7d75e67c0faa/Dockerfile +ARG ARCH="amd64" +ARG OS="linux" +# they don't tag versions only latest +FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest +# https://github.com/prometheus/busybox +LABEL maintainer="Will Bollock " + +ARG ARCH="amd64" +ARG OS="linux" +COPY nagios_exporter /bin/nagios_exporter + +EXPOSE 9927 +USER nobody +ENTRYPOINT [ "/bin/nagios_exporter" ] diff --git a/README.md b/README.md index 7df9964..8e88fa1 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,13 @@ This exporter does not output Nagios check results as Prometheus metrics; it is ## Table of Contents -- [nagios_exporter](#nagios_exporter) +- [nagios\_exporter](#nagios_exporter) - [Table of Contents](#table-of-contents) - [Configuration](#configuration) - [Nagios Core 3/4 support](#nagios-core-34-support) - [Installation](#installation) - [Debian/RPM package](#debianrpm-package) + - [Docker](#docker) - [Binary](#binary) - [Source](#source) - [Grafana](#grafana) @@ -39,6 +40,7 @@ This exporter does not output Nagios check results as Prometheus metrics; it is - [NagiosXI](#nagiosxi) - [Nagios Core 3/4, CheckMK](#nagios-core-34-checkmk) - [Resources Used](#resources-used) + - [Contributors ✨](#contributors-) ## Configuration @@ -98,6 +100,17 @@ wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version } {dpkg,rpm} -i prometheus-nagios-exporter_{{ version }}_linux_amd64.{deb,rpm} ``` +### Docker + +Populate `config.toml` with your `APIKey = ` + +```console +docker run \ +-v ./config.toml:/etc/prometheus-nagios-exporter/config.toml \ +ghcr.io/wbollock/nagios_exporter --\ +--nagios.scrape-uri https:// +``` + ### Binary ```bash From 5fd359785b7ef4b83e6f5a12eedcf0685e83da26 Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Mon, 6 Mar 2023 19:54:42 -0500 Subject: [PATCH 2/6] fix: dockerfile typo --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96feab4..a65f9f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,6 @@ FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest # https://github.com/prometheus/busybox LABEL maintainer="Will Bollock " -ARG ARCH="amd64" -ARG OS="linux" COPY nagios_exporter /bin/nagios_exporter EXPOSE 9927 From 7f32e95926c7620865b655e1fa1d7ed6db0f46bf Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Mon, 6 Mar 2023 19:55:24 -0500 Subject: [PATCH 3/6] build: replace deprecated replacements option https://goreleaser.com/deprecations/#archivesreplacements --- .goreleaser.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a703143..ec89953 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,12 +16,15 @@ builds: ldflags: - -X main.Version={{.Version}} -X main.Commit={{.Commit}} -X main.BuildDate={{ .CommitDate }} archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else if eq .Arch "darwin" }}Darwin + {{- else if eq .Arch "linux" }}Linux + {{- else if eq .Arch "windows" }}Windows + {{- else }}{{ .Arch }}{{ end }} checksum: name_template: 'checksums.txt' snapshot: From 45b3a5774331e5682fe3f4c0fecfb92adb8cd7c7 Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Mon, 6 Mar 2023 19:55:38 -0500 Subject: [PATCH 4/6] docs: fix docker run instructions --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e88fa1..e7a0a49 100644 --- a/README.md +++ b/README.md @@ -102,13 +102,13 @@ wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version } ### Docker -Populate `config.toml` with your `APIKey = ` +Populate `config.toml` with your `APIKey = NagiosXIAPIKey` ```console -docker run \ +sudo docker run \ -v ./config.toml:/etc/prometheus-nagios-exporter/config.toml \ -ghcr.io/wbollock/nagios_exporter --\ ---nagios.scrape-uri https:// +ghcr.io/wbollock/nagios_exporter \ +--nagios.scrape-uri http://localhost ``` ### Binary From df8e73eb50b80e44eff8ca04207c40fe5d8bd6fc Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Wed, 8 Mar 2023 11:27:07 -0500 Subject: [PATCH 5/6] chore: move installation docs to the top --- README.md | 88 +++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 18ed359..a30240c 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,15 @@ This exporter does not output Nagios check results as Prometheus metrics; it is - [nagios\_exporter](#nagios_exporter) - [Table of Contents](#table-of-contents) - - [Configuration](#configuration) - - [Configuration File](#configuration-file) - - [CLI](#cli) - - [Nagios Core 3/4 support](#nagios-core-34-support) - [Installation](#installation) - [Debian/RPM package](#debianrpm-package) - [Docker](#docker) - [Binary](#binary) - [Source](#source) + - [Configuration](#configuration) + - [Configuration File](#configuration-file) + - [CLI](#cli) + - [Nagios Core 3/4 support](#nagios-core-34-support) - [Grafana](#grafana) - [Troubleshooting](#troubleshooting) - [NagiosXI](#nagiosxi) @@ -48,6 +48,46 @@ This exporter does not output Nagios check results as Prometheus metrics; it is - [Releasing](#releasing) - [Contributors ✨](#contributors-) +## Installation + +### Debian/RPM package + +Substitute `{{ version }}` for your desired release. + +```bash +wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version }}/prometheus-nagios-exporter_{{ version }}_linux_amd64.{deb,rpm} +{dpkg,rpm} -i prometheus-nagios-exporter_{{ version }}_linux_amd64.{deb,rpm} +``` + +### Docker + +Populate `config.toml` with your `APIKey = NagiosXIAPIKey` + +```console +sudo docker run \ +-v ./config.toml:/etc/prometheus-nagios-exporter/config.toml \ +ghcr.io/wbollock/nagios_exporter \ +--nagios.scrape-uri http://localhost +``` + +### Binary + +```bash +wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version }}/nagios_exporter_{{ version }}_Linux_x86_64.tar.gz +tar xvf nagios_exporter_{{ version }}_Linux_x86_64.tar.gz +./nagios_exporter/prometheus-nagios-exporter +``` + +### Source + +```bash +wget https://github.com/wbollock/nagios_exporter/archive/refs/tags/v{{ version }}.tar.gz +tar xvf nagios_exporter-{{ version }}.tar.gz +cd ./nagios_exporter-{{ version }} +go build nagios_exporter.go +./nagios_exporter.go +``` + ## Configuration Create a simple `config.toml` in `/etc/prometheus-nagios-exporter` with your Nagios API key: @@ -110,46 +150,6 @@ Example usage: Note that this flag nullifies all others. It cannot be used in conjunction with the Nagios XI API. -## Installation - -### Debian/RPM package - -Substitute `{{ version }}` for your desired release. - -```bash -wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version }}/prometheus-nagios-exporter_{{ version }}_linux_amd64.{deb,rpm} -{dpkg,rpm} -i prometheus-nagios-exporter_{{ version }}_linux_amd64.{deb,rpm} -``` - -### Docker - -Populate `config.toml` with your `APIKey = NagiosXIAPIKey` - -```console -sudo docker run \ --v ./config.toml:/etc/prometheus-nagios-exporter/config.toml \ -ghcr.io/wbollock/nagios_exporter \ ---nagios.scrape-uri http://localhost -``` - -### Binary - -```bash -wget https://github.com/wbollock/nagios_exporter/releases/download/v{{ version }}/nagios_exporter_{{ version }}_Linux_x86_64.tar.gz -tar xvf nagios_exporter_{{ version }}_Linux_x86_64.tar.gz -./nagios_exporter/prometheus-nagios-exporter -``` - -### Source - -```bash -wget https://github.com/wbollock/nagios_exporter/archive/refs/tags/v{{ version }}.tar.gz -tar xvf nagios_exporter-{{ version }}.tar.gz -cd ./nagios_exporter-{{ version }} -go build nagios_exporter.go -./nagios_exporter.go -``` - ## Grafana Import the [dashboard](grafana/dashboard.json) template ([instructions](https://grafana.com/docs/grafana/v9.0/dashboards/export-import/#import-dashboard)). From 2074bc58854fcfde496c29d53044b3ce4a7ae1f8 Mon Sep 17 00:00:00 2001 From: Will Bollock Date: Wed, 8 Mar 2023 11:27:58 -0500 Subject: [PATCH 6/6] fix: re-add metrics section --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index a30240c..e7b6dfe 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ This exporter does not output Nagios check results as Prometheus metrics; it is - [Configuration File](#configuration-file) - [CLI](#cli) - [Nagios Core 3/4 support](#nagios-core-34-support) + - [Metrics](#metrics) - [Grafana](#grafana) - [Troubleshooting](#troubleshooting) - [NagiosXI](#nagiosxi) @@ -150,6 +151,44 @@ Example usage: Note that this flag nullifies all others. It cannot be used in conjunction with the Nagios XI API. +## Metrics + +
+ + Click to expand metrics + +| Metric Name | Description | Type | +|:--------------------------------:|:----------------------------------------------------:|:---------:| +| `nagios_build_info` | Nagios exporter build information | gauge | +| `nagios_host_checks_execution` | Host check execution | histogram | +| `nagios_host_checks_latency` | Host check latency | histogram | +| `nagios_host_checks_minutes` | Host checks over time | histogram | +| `nagios_host_checks_performance_seconds` | Host checks performance | gauge | +| `nagios_hosts_acknowledges_total` | Amount of host problems acknowledged | gauge | +| `nagios_hosts_checked_total` | Amount of hosts checked | gauge | +| `nagios_hosts_downtime_total` | Amount of hosts in downtime | gauge | +| `nagios_hosts_status_total` | Amount of hosts in different states | gauge | +| `nagios_hosts_total` | Amount of hosts present in configuration | gauge | +| `nagios_service_checks_execution` | Service check execution | histogram | +| `nagios_service_checks_latency` | Service check latency | histogram | +| `nagios_service_checks_minutes` | Service checks over time | histogram | +| `nagios_service_checks_performance_seconds` | Service checks performance | gauge | +| `nagios_services_acknowledges_total` | Amount of service problems acknowledged | gauge | +| `nagios_services_checked_total` | Amount of services checked | gauge | +| `nagios_services_downtime_total` | Amount of services in downtime | gauge | +| `nagios_services_status_total` | Amount of services in different states | gauge | +| `nagios_services_total` | Amount of services present in configuration | gauge | +| `nagios_up` | Whether Nagios can be reached | gauge | +| `nagios_update_available_info` | NagiosXI update is available (optional metric!) | gauge | +| `nagios_users_privileges_total` | Amount of admin or regular users | gauge | +| `nagios_users_status_total` | Amount of disabled or enabled users | gauge | +| `nagios_users_total` | Amount of users present on the system | gauge | +| `nagios_version_info` | Nagios version information | gauge | + +`nagios_update_available_info` is optional because the user may not want their Nagios server scraping the external version webpage every `scrape_interval`. + +
+ ## Grafana Import the [dashboard](grafana/dashboard.json) template ([instructions](https://grafana.com/docs/grafana/v9.0/dashboards/export-import/#import-dashboard)).