All Projects → claranet → nagitheus

claranet / nagitheus

Licence: Apache-2.0 license
Nagios Check towards Prometheus

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to nagitheus

check-ssl
Check the expiration date of your ssl-cert with bash (implemented for Nagios/Icinga)
Stars: ✭ 14 (-26.32%)
Mutual labels:  nagios, check
url-survival-check
批量检测URL存活
Stars: ✭ 44 (+131.58%)
Mutual labels:  check
Nagflux
A connector which copies performancedata from Nagios / Icinga(2) / Naemon to InfluxDB
Stars: ✭ 55 (+189.47%)
Mutual labels:  nagios
Thola
Tool for monitoring and provisioning network devices (mainly using SNMP) - monitoring check plugin
Stars: ✭ 179 (+842.11%)
Mutual labels:  nagios
Openitcockpit
openITCOCKPIT is an Open Source system monitoring tool built for different monitoring engines like Nagios, Naemon and Prometheus.
Stars: ✭ 108 (+468.42%)
Mutual labels:  nagios
Nagios Plugins Rabbitmq
A set of nagios checks for RabbitMQ using the management interface
Stars: ✭ 194 (+921.05%)
Mutual labels:  nagios
Nagios Nrpe Server
Nagios NRPE Server Role for Ansible
Stars: ✭ 27 (+42.11%)
Mutual labels:  nagios
checkif.js
Javascript check library
Stars: ✭ 30 (+57.89%)
Mutual labels:  check
check netscaler
A Nagios Plugin written in Perl for the Citrix ADC (formerly Citrix NetScaler). It uses the NetScaler NITRO API.
Stars: ✭ 36 (+89.47%)
Mutual labels:  nagios
Pytest Testinfra
With Testinfra you can write unit tests in Python to test actual state of your servers configured by management tools like Salt, Ansible, Puppet, Chef and so on.
Stars: ✭ 1,987 (+10357.89%)
Mutual labels:  nagios
Check nwc health
check_nwc_health is a plugin which checks the health of network components and interfaces.
Stars: ✭ 127 (+568.42%)
Mutual labels:  nagios
Check docker
Nagios plugin to check docker containers
Stars: ✭ 113 (+494.74%)
Mutual labels:  nagios
Go Check Plugins
Check Plugins for monitoring written in golang
Stars: ✭ 225 (+1084.21%)
Mutual labels:  nagios
Nagvis
Visualization addon for your open source monitoring core
Stars: ✭ 103 (+442.11%)
Mutual labels:  nagios
private-ip
Check if IP address is private.
Stars: ✭ 26 (+36.84%)
Mutual labels:  check
Docker Nagios
Docker-Nagios provide Nagios service running on the docker container and a series of solution for Nagios
Stars: ✭ 41 (+115.79%)
Mutual labels:  nagios
Nagios
Development repository for the nagios cookbook
Stars: ✭ 127 (+568.42%)
Mutual labels:  nagios
Wgcloud
linux运维监控工具,支持系统信息,内存,cpu,温度,磁盘空间及IO,硬盘smart,系统负载,网络流量等监控,API接口,大屏展示,拓扑图,进程监控,端口监控,docker监控,文件防篡改,日志监控,数据可视化,web ssh,堡垒机,指令下发批量执行,linux面板,探针,故障告警
Stars: ✭ 2,669 (+13947.37%)
Mutual labels:  nagios
nagmapReborn
Nagmap Reborn - Standalone integration with some server monitoring systems providing a user-friendly interface through geographic visualization.
Stars: ✭ 19 (+0%)
Mutual labels:  nagios
has-value
Returns true if a value exists, false if empty. Works with deeply nested values using object paths.
Stars: ✭ 27 (+42.11%)
Mutual labels:  check

Check Prometheus from Nagios

What

A Nagios plugin for querying Prometheus.

TL;DR

$ docker run -it claranet/nagitheus:latest -h

Why

This tool has been inspired by the upstream provided shell script to be found here. But unfortunately this shell script is deficient in several ways. Nagitheus instead:

  1. It actually works :)
  2. No need to specify if vector or scalar
  3. It doesn't stop at the first result but iterates over whole vector
  4. Ability to print desired label
  5. Go binary: no need of specific software on the nagios monitoring

How to build

build:

$ go build nagitheus.go
or from mac to linux
env GOOS=linux GOARCH=amd64 go build nagitheus.go

run:

 $ ./nagitheus -H "https://prometheus.example.com" -q "Prometheus Query" -w 2  -c 2 -u username -p PASSWORD -m le  -l label

How to run

$ go run nagitheus.go -H 'https://prometheus.mgt.domain.com' -q "(kubelet_volume_stats_used_bytes/kubelet_volume_stats_capacity_bytes*100)>2" -w 2  -c 5  -m ge -u UN -p PW -l persistentvolumeclaim
WARNING prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 2.2607424766047886 CRITICAL prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 5.625835543270624
exit status 2

Usage

  -H string
      Host to query (Required, i.e. https://example.prometheus.com)
  -q string
      Prometheus query (Required)
  -w string
      Warning treshold (Required)
  -c string
      Critical treshold (Required)
  -d string
      Print whole prometheus result to output (Optional) (default "no")
  -l string
      Label to print (Optional) (default "none")
  -f string
      Format message with go template (Optional)
  -m string
      Comparison method (Optional) (default "ge")
  -u string
      Username (Optional)
  -p string
      Password (Optional)
  -t string
      Token (Optional)
  --critical-on-missing
      Return CRITICAL if query results are missing (Optional) (default "no")
  --max-chars
      Max. count of characters to print
  --print-details
      Prints all returned values on multiline result
  --print-perf-data
	    Prints performance data for results in the format `query_result=<result>;<warning>;<critical>`
  --value-mapping string
    	Mapping result metrics for output (Optional, json i.e. '{"0":"down","1":"up"}')
  --value-unit string
    	Unit of the value for output (Optional, i.e. '%')
  -v  Prints nagitheus version

This software will perform a request on the prometheus server. Required flags are the Host, Query, Warning and Critical.

Debug

-d yes will print to outputn the whole response from Prometheus (best used from command line and not from Nagios):

Prometheus response: {
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "endpoint": "http-metrics",
          "exported_namespace": "aux",
          "instance": "10.42.0.2:10255",
          "job": "kubelet",
          "namespace": "kube-system",
          "persistentvolumeclaim": "prometheus-kube-prometheus-db-prometheus-kube-prometheus-0",
          "service": "kubelet"
        },
        "value": [
          1521551995.114,
          "2.2607424766047886"
        ]
      },
      {
        "metric": {
          "endpoint": "http-metrics",
          "exported_namespace": "aux",
          "instance": "10.42.0.4:10255",
          "job": "kubelet",
          "namespace": "kube-system",
          "persistentvolumeclaim": "prometheus-kube-prometheus-db-prometheus-kube-prometheus-0",
          "service": "kubelet"
        },
        "value": [
          1521551995.114,
          "5.625835543270624"
        ]
      }
    ]
  }
}

Output

If the result contains multiple values, the output returns a summary and multiline results.

Label

-l labelname takes a label that you want to print toghether with Status and value:

CRITICAL 1 persistentvolumeclaim critical, 1 persistentvolumeclaim warning, 0 persistentvolumeclaim ok :
------
CRITICAL persistentvolumeclaim prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 5.625835543270624
WARNING persistentvolumeclaim prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 2.2607424766047886

Without the label the result would be:

CRITICAL 1 item critical, 1 item warning, 0 item ok :
------
WARNING value is 2.2607424766047886
CRITICAL value is 5.625835543270624

Format

-f formatstring take a go template string to print status the way you want. Some variables are available for display.

  • Label
  • Value
  • Metric Map of metrics returned from prometheus that you can access with {{.Metric.<metric_name>}}

Example:

-f '{{.Metric.node}}: {{.Metric.condition}} is {{.Value}}' --value-mapping '{"1":"KO","0":"OK"}'

Will output

WARNING 0 condition critical, 1 condition warning, 2 condition ok :
------
WARNING kube-node-1: FrequentContainerdRestart is KO
OK kube-node-1: CorruptDockerOverlay2 is OK
OK kube-node-2: CorruptDockerOverlay2 is OK
OK kube-node-2: FrequentContainerdRestart is OK

Method

-m ge OR gt OR le OR lt tells the check how to compare the result with the critical and warning flags

Basic auth

-u username -p password when both are set the request will be performed with basic auth

Token

-t token the request will be performed adding the token to headers

For example in Openshift you need to do

TOKEN=$(oc whoami -t)
-t $TOKEN

Value Mapping

-value-mapping <json key-value pairs> allow mapping of the result values to defined strings for output, e.g. 0=>DOWN, 1=> UP:

./nagitheus -H 'https://prometheus.mgt.domain.com' -q 'up{job="prometheus"}' -c 1 -w 1 -m lt -l job -value-mapping '{"0":"DOWN","1":"UP"}'

returns

OK job prometheus is UP

Value Unit

-value-unit <unit> allows adding a unit to the output result values, e.g. '%', 'GB':

WARNING persistentvolumeclaim prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 2.2607424766047886 %
CRITICAL persistentvolumeclaim prometheus-kube-prometheus-db-prometheus-kube-prometheus-0 is 5.625835543270624 %

Version

-v returns the version of nagitheus

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].