Giter Club home page Giter Club logo

sensu-plugins-network-checks's Introduction

Sensu Bonsai Asset Build Status Gem Version Code Climate Test Coverage Dependency Status

Sensu Plugins Network Checks Plugin

Overview

This plugin provides native network instrumentation for monitoring and metrics collection, including hardware, TCP response, RBLs, whois, port status, and more.

Files

  • bin/check-banner.rb
  • bin/check-jsonwhois-domain-expiration.rb
  • bin/check-mtu.rb
  • bin/check-multicast-groups.rb
  • bin/check-netfilter-conntrack.rb
  • bin/check-netstat-tcp.rb
  • bin/check-ping.rb
  • bin/check-ports-bind.rb
  • bin/check-ports-nmap.rb
  • bin/check-ports.rb
  • bin/check-rbl.rb
  • bin/check-socat.rb
  • bin/check-whois-domain-expiration-multi.rb
  • bin/check-whois-domain-expiration.rb
  • bin/metrics-interface.rb
  • bin/metrics-net.rb
  • bin/metrics-netif.rb
  • bin/metrics-netstat-tcp.rb
  • bin/metrics-ping.rb
  • bin/metrics-sockstat.rb

check-banner Connects to a TCP port on one or more hosts, reads until a char (EOF, EOL, etc), and tests output against a pattern.

check-jsonwhois-domain-expiration Checks domain expiration dates using the https://jsonwhois.com API.

check-mtu Checks maximum transmission unit (MTU) of a network interface. In many setups, MTUs are tuned and MTU mismatches cause issues. Having a check for MTU settings helps catch these mistakes. Also, some instances in Amazon EC2 have a default MTU size of 9,000 bytes, which is undesirable in some environments. This check can catch undesirable setups.

check-multicast-groups Checks whether specific multicast groups are configured on specific interfaces. Requires the netstat command.

check-netfilter-conntrack Checks Netfilter connection tracking table condition.

check-netstat-tcp Alert based on thresholds of discrete TCP socket states reported by netstat.

check-ping Ping check script for Sensu.

check-ports-bind Connects to a TCP/UDP address:port to check whether open or closed.

check-ports-nmap Fetches port status using nmap. Catches bad network access control lists (ACLs) and service down events for network resources.

check-ports Connects to a TCP/UDP port on one or more ports check whether ropen or closed. This check now uses a TCPSocket, not nmap (check-ports-nmap above uses nmap).

check-rbl Checks whether an IP is blacklisted in the common DNS blacklists or a list you add.

check-socat Inspects sockets, such as checking whether socat can receive particular a UDP multicast packet within a certain number of seconds or whether a UPD multicast packet contains an expected packet.

check-whois-domain-expiration-multi Checks expiration dates for multiple domains using the whois gem.

check-whois-domain-expiration Checks a domain's expiration dates using the whois gem.

metrics-interface Provides interface metrics.

metrics-net Fetches metrics from all interfaces on the box using the /sys/class interface.

metrics-netif Fetches network interface throughput metrics.

metrics-netstat-tcp Fetches metrics on TCP socket states from netstat. Particularly useful on high-traffic web or proxy servers with large numbers of short-lived TCP connections coming and going.

metrics-ping Pings a host and outputs ping statistics.

metrics-sockstat Parses /proc/net/sockstat and outputs all fields as metrics.

Usage examples

Help

check-banner.rb

Usage: check-banner.rb (options)
    -c, --count NUMBER               Number of successful matches, default(1)
    -C, --critmessage MESSAGE        Custom critical message to send
    -e, --exclude_newline            Exclude newline character at end of write STRING
    -H, --hostnames HOSTNAME(S)      Host(s) to connect to, comma seperated
    -O, --okmessage MESSAGE          Custom ok message to send
    -q, --pattern PAT                Pattern to search for
    -p, --port PORT
    -r, --readtill CHAR              Read till CHAR is reached
    -S, --ssl                        Enable SSL socket for secure connection
    -t, --timeout SECS               Connection timeout
    -w, --write STRING               write STRING to the socket

metrics-interface.rb

Usage: metrics-interface.rb (options)
    -x INTERFACE[,INTERFACE],        List of interfaces to exclude
        --exclude-interface
    -i INTERFACE[,INTERFACE],        List of interfaces to include
        --include-interface
    -s, --scheme SCHEME              Metric naming scheme, text to prepend to metric

Configuration

Sensu Go

Asset registration

Assets are the best way to make use of this plugin. If you're not using an asset, please consider doing so! If you're using sensuctl 5.13 or later, you can use the following command to add the asset:

sensuctl asset add sensu-plugins/sensu-plugins-network-checks

If you're using an earlier version of sensuctl, you can download the asset definition from this project's Bonsai asset index page.

Asset definition

---
type: Asset
api_version: core/v2
metadata:
  name: sensu-plugins-network-checks
spec:
  url: https://assets.bonsai.sensu.io/c90a2b1335ee9cda57046bd4551b303098a98237/sensu-plugins-network-checks_4.1.0_centos_linux_amd64.tar.gz
  sha512: 0fe990e4eb53c308c6245d8ac8cc7268d34e3235d5188ecda3a7308889a09b8b722a77f57169d6d9a7c2f1bf3b523fcdcb618aeb4cd6b83bd74feb3683d721b7

Check definition

---
type: CheckConfig
spec:
  command: "check-banner.rb"
  handlers: []
  high_flap_threshold: 0
  interval: 10
  low_flap_threshold: 0
  publish: true
  runtime_assets:
  - sensu-plugins/sensu-plugins-network-checks
  - sensu/sensu-ruby-runtime
  subscriptions:
  - linux

Sensu Core

Check definition

{
  "checks": {
    "check-banner": {
      "command": "check-banner.rb",
      "subscribers": ["linux"],
      "interval": 10,
      "refresh": 10,
      "handlers": ["influxdb"]
    }
  }
}

Installation from source

Sensu Go

See the instructions above for asset registration.

Sensu Core

Install and setup plugins on Sensu Core.

Additional notes

Sensu Go Ruby Runtime Assets

The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator, or handler), make sure to include the corresponding Sensu Ruby Runtime Asset in the list of assets needed by the resource.

Contributing

See CONTRIBUTING.md for information about contributing to this plugin.

sensu-plugins-network-checks's People

Contributors

ab avatar amdprophet avatar analytically avatar dcharleston avatar dependabot-preview[bot] avatar dependabot-support avatar drmurx avatar eheydrick avatar evesy avatar hanynowsky avatar hathaway avatar hillaryfraley avatar jindraj avatar johannagnarsson avatar jspaleta avatar kai101 avatar majormoses avatar maticmeznar avatar mattyjones avatar mgreensmith avatar mjulian avatar mlf4aiur avatar rmc3 avatar robinnil avatar scones avatar sensu-plugin avatar talarczykco avatar tas50 avatar xt99 avatar ydkn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-plugins-network-checks's Issues

Feature Request: Add retries parameter to check-ports.rb

Usually things that test connections provide a number of retries. I am aware that similar behavior by modifying my "occurrences" in my check definition. However, it's not quite the same and takes much longer to get a result. For example, my check runs every 2 minutes. Getting a 30 timeout, then waiting 1.5 minutes to test again and repeating isn't as useful as 2 rapid retries in succession to test a app server.
Thoughts?

metrics-sockstat.rb is broken in 5.0.0

Throws an error

 /opt/sensu/embedded/bin/metrics-sockstat.rb 
/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-network-checks-5.0.0/bin/metrics-sockstat.rb:38:in `<class:MetricsSockstat>': uninitialized constant MetricsSockstat::Socket (NameError)
        from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-network-checks-5.0.0/bin/metrics-sockstat.rb:33:in `<top (required)>'
        from /opt/sensu/embedded/bin/metrics-sockstat.rb:23:in `load'
        from /opt/sensu/embedded/bin/metrics-sockstat.rb:23:in `<main>'

Previous versions work fine.

metric-netif doesn't work if default locale is ru_RU.UTF-8

metris-netif use sar to generate netif metrics and grep sar output by word "Average":

sar -n DEV 1 1 | grep Average | grep -v IFACE.each_line do |line|`

But it's wrong way, if defalut system locale is't en_US.UTF-8. For example ru_RU.UTF-8, where "Average" translated to "Среднее":

sar -n DEV 1 1

11:03:33 eth0 79,00 36,00 43,28 4,28 0,00 0,00 0,00 0,03
Среднее: eth0 79,00 36,00 43,28 4,28 0,00 0,00 0,00 0,03

It can be easliy fixed by using env LANG:

LANG=en_US.UTF8 && sar -n DEV 1 1 | grep Average | grep -v IFACE.each_line do |line|`

Domain-expiration invalid date

Hi all,

Is just me or .com domain can't be check anymore? Stop to work like 3-4 days ago for me.

Check failed to run: invalid date, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration.rb:77:in `parse'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration.rb:77:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.2/lib/sensu-plugin/cli.rb:57:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.2/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

I checked .ca, .us and they are still working fine. I checked a couple .com domain and they all failing.

check-ping false positives

Check-ping gives constant false positives. I ping a number of servers on a number of different networks including 8.8.8.8

The checks fail and then the following check always succeeds. The check that fails always says none successful. When pinging during this period from bash, no packets are lost.

CheckPING CRITICAL: ICMP ping unsuccessful for host: 10.1.8.1 (successful: 0/20)
CheckPING CRITICAL: ICMP ping unsuccessful for host: 10.1.8.2 (successful: 0/3)

The following is an example where sensu gave a critical and then a ok alert during the pings below:

[root@sensu ~]# ping 10.1.8.1 -i 0.1 -c 2000
--- 10.1.8.1 ping statistics ---
2000 packets transmitted, 2000 received, 0% packet loss, time 200026ms
rtt min/avg/max/mdev = 0.185/0.330/0.948/0.202 ms

Thanks

metrics-sockstat.rb does not output hostname as first field

When using this metrics plugin for Grafana via InfluxDB, it does not get added to the correct measurement.

Expected behaviour: The first field should contain the hostname of the server it runs on.
Observed behaviour: The first field is 'network' which puts all the metrics under the same measurement in InfluxDB making it rather useless for visualizations in grafana.

What it looks like:
network.sockets.total_used 298 1558632775

What it should look like:
my-server-name-here.network.sockets.total_used 298 1558632775

Appreciate all the work you guys do, thanks so much!

check-whois-domain-expiration.rb doesn't work with .social domains

$ check-whois-domain-expiration.rb -d test.social
Check failed to run: Unable to find a parser for property `expires_on', ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:350:in `delegate_property_to_parsers'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:312:in `expires_on'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:333:in `method_missing'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-network-checks-2.0.1/bin/check-whois-domain-expiration.rb:78:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

whois checks for .org domains fail with "Parsing error"

In the following example.org refers to an actual .org domain.

This check command:

check-whois-domain-expiration-multi.rb --domains example.org --warn 22 --critical 15

Fails with:

WhoisDomainExpirationCheck UNKNOWN: example.org (Parsing error)

This fails for all .org domains.

Doing a manual check using the ruby gem as follows works:

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    whois (4.0.6)
PLATFORMS
  ruby
DEPENDENCIES
  whois
BUNDLED WITH
   1.16.2

test.rb:

#!/usr/bin/env ruby

require 'bundler/setup'
require 'whois'

puts Whois::Client.new.lookup("example.org")

cannot load such file -- net/ping (LoadError)

I have sensu server and sensu-client Installed on one machine (centos) and installed the the plugins through gem.

Everything was good when I run the check_ping.rb from the command line, but When I configure the same check in /etc/sensu/conf.d/ and check in the UI I am getting this ruby issue;

gem install sensu-plugins-network-checks

and configured EMBEDDED_RUBY=true

when I check the UI the below is the error I am facing

/opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:56:in require': cannot load such file -- net/ping (LoadError) from /opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:56:inrequire'
from /opt/sensu/embedded/lib/ruby/2.3.0/gems/sensu-plugins-network-checks-0.2.4/bin/check-ping.rb:31:in `

'
Sensu::Plugin::CLI: ["Not implemented! You should override Sensu::Plugin::CLI#run."]

metrics-ping.rb not working

Sensu version: 0.22.0. Plugin installed with sensu-install command.

sensu@a7cf7f839d7c:/$ metrics-ping.rb -c 1 -h localhost
Check failed to run: wrong argument type NilClass (must respond to :each), ["/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:79:in `zip'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:79:in `results'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:87:in `output'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:101:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]

Add arm as build target

As a Sensu user, I'd like to be able to run checks from a raspberry pi, or other arm-based platform. Adding arm as a build target would allow me to do that.

metrics-ping.rb fails to run in alpine 3.12

Description

metrics-ping.rb fails to run in alpine 3.12

without iputils package:

Check failed to run: wrong argument type NilClass (must respond to :each), ["/var/cache/sensu/sensu-agent/0844b7ca3523626f1293c6a55817092d528bb39b5f7f36aefc756171e0566f4f1ffaa7e0a978727936a5a2e2a071c2457510ae4e86accd795a7670816ecab9e5/lib/ruby/2.4.0/bundler/gems/sensu-plugins-network-checks-a2115474fe19/bin/metrics-ping.rb:87:in `zip'", "/var/cache/sensu/sensu-agent/0844b7ca3523626f1293c6a55817092d528bb39b5f7f36aefc756171e0566f4f1ffaa7e0a978727936a5a2e2a071c2457510ae4e86accd795a7670816ecab9e5/lib/ruby/2.4.0/bundler/gems/sensu-plugins-network-checks-a2115474fe19/bin/metrics-ping.rb:87:in `results'", "/var/cache/sensu/sensu-agent/0844b7ca3523626f1293c6a55817092d528bb39b5f7f36aefc756171e0566f4f1ffaa7e0a978727936a5a2e2a071c2457510ae4e86accd795a7670816ecab9e5/lib/ruby/2.4.0/bundler/gems/sensu-plugins-network-checks-a2115474fe19/bin/metrics-ping.rb:95:in `write_output'", "/var/cache/sensu/sensu-agent/0844b7ca3523626f1293c6a55817092d528bb39b5f7f36aefc756171e0566f4f1ffaa7e0a978727936a5a2e2a071c2457510ae4e86accd795a7670816ecab9e5/lib/ruby/2.4.0/bundler/gems/sensu-plugins-network-checks-a2115474fe19/bin/metrics-ping.rb:109:in `run'", "/var/cache/sensu/sensu-agent/0844b7ca3523626f1293c6a55817092d528bb39b5f7f36aefc756171e0566f4f1ffaa7e0a978727936a5a2e2a071c2457510ae4e86accd795a7670816ecab9e5/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:59:in `block in <class:CLI>'"]

Then I installed it:

# apk add iputils
(1/2) Installing libcap (2.27-r0)
(2/2) Installing iputils (20190709-r0)
Executing busybox-1.31.1-r19.trigger
OK: 8 MiB in 22 packages

And it doesn't work: ping error: unable to ping IP

And besides this, check-ping.rb stops work too:

CheckPING CRITICAL: ICMP ping unsuccessful for host: IP (successful: 0/3)

Environment

Alpine version:

/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.12.3
PRETTY_NAME="Alpine Linux v3.12"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

Sensu Docker image version 6.2.5.

Any help?

check-whois-domain-expiration.rb warn and crit flags reversed

Alerting flag appear to be handled reversed based on warning and critical thresholds

root@sensu0:/opt/sensu/embedded/bin ./check-whois-domain-expiration.rb -d dyn.com
WhoisDomainExpirationCheck OK: dyn.com expires on 08-04-2019 (339 days away)

root@sensu0:/opt/sensu/embedded/bin ./check-whois-domain-expiration.rb -d dyn.com  -w 340
WhoisDomainExpirationCheck CRITICAL: dyn.com expires on 08-04-2019 (339 days away)

root@sensu0:/opt/sensu/embedded/bin# ./check-whois-domain-expiration.rb -d dyn.com  -c 340
WhoisDomainExpirationCheck WARNING: dyn.com expires on 08-04-2019 (339 days away)

check-whois-domain-expiration - "invalid date" (still)

I know this was addressed in #59, and I agree it works for the example of "google.com", but for other sites it's still failing. I am on:

  • sensu-plugins-network-checks-2.3.0
  • whois-parser-1.0.1

Works:

$ GEM_PATH=/opt/sensu/embedded/lib/ruby/gems/2.3.0 /opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/check-whois-domain-expiration.rb -d google.com
WhoisDomainExpirationCheck OK: google.com expires on 09-13-2020 (929 days away)

Fails with different domain:

$ GEM_PATH=/opt/sensu/embedded/lib/ruby/gems/2.3.0 /opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/check-whois-domain-expiration.rb -d plainlystated.com
WhoisDomainExpirationCheck UNKNOWN: plainlystated.com can't be checked

(beneath the rescue, it's "invalid date")

This domain is my personal blog, but I get the same errors with domains related to my work.

False Failures

I've been getting a lot of false alerts recently. I thought it was a problem with one of my hosts, but after some investigation today, it seems to be check-ping giving odd results?

If I repeatedly run it, I get some success, some failure - but meanwhile a ping from my sensu host to the host i'm checking in another window results in no problems.

I came across #34 and updated sensu-plugins-network-checks to 1.1.0 (as well as all my other sensu gems), but it doesn't seem to have solved it:

$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING CRITICAL: ICMP ping unsuccessful for host: myhost.mydomain.com (successful: 0/1)
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING CRITICAL: ICMP ping unsuccessful for host: myhost.mydomain.com (successful: 0/1)
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING CRITICAL: ICMP ping unsuccessful for host: myhost.mydomain.com (successful: 0/1)
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING CRITICAL: ICMP ping unsuccessful for host: myhost.mydomain.com (successful: 0/1)
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING CRITICAL: ICMP ping unsuccessful for host: myhost.mydomain.com (successful: 0/1)
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com
$ /opt/sensu/embedded/bin/check-ping.rb -h myhost.mydomain.com
CheckPING OK: ICMP ping successful for host: myhost.mydomain.com

but then a ping running concurrently in another terminal:

--- myhost.mydomain.com ping statistics ---
180 packets transmitted, 180 received, 0% packet loss, time 179196ms
rtt min/avg/max/mdev = 0.644/1.528/10.605/1.394 ms

Any ideas?

Thanks,

Ian

metrics-ping.rb: pinging unresponsive host results in error

OS: Debian 8 (Jessie) under Docker 1.10 on CentOS 7 host.
Pinging an unresponsive host results in error (check failed to run) after the timeout expires. Pinging a responding host returns correct result. I tried with ping from inetutils-ping and iputils-ping packages, but the error seems the same for both.

root@ad4985f61de8:/# metrics-ping.rb --host 8.8.8.1
Check failed to run: undefined local variable or method `status' for #<PingMetrics:0x00000001ba2df8>, ["/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:95:in `validate'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/metrics-ping.rb:100:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]

check-whois-domain-expiration-multi.rb v2.1.1 fails with "undefined local variable or method `domain_result'"

Running on version 2.1.1 I get the following error:

Check failed to run: undefined local variable or method `domain_result' for #, ["/nix/store/x8fgw5n17bna0khbwdh8qxpa7y0v2gd9-sensu-1.2.0/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-2.1.1/bin/check-whois-domain-expiration-multi.rb:97:in `block in expiration_results'", "/nix/store/x8fgw5n17bna0khbwdh8qxpa7y0v2gd9-sensu-1.2.0/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-2.1.1/bin/check-whois-domain-expiration-multi.rb:86:in `each'", "/nix/store/x8fgw5n17bna0khbwdh8qxpa7y0v2gd9-sensu-1.2.0/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-2.1.1/bin/check-whois-domain-expiration-multi.rb:86:in `expiration_results'", "/nix/store/x8fgw5n17bna0khbwdh8qxpa7y0v2gd9-sensu-1.2.0/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-2.1.1/bin/check-whois-domain-expiration-multi.rb:113:in `run'", "/nix/store/x8fgw5n17bna0khbwdh8qxpa7y0v2gd9-sensu-1.2.0/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in '"]

Rolling back to 2.1.0 makes things work again.

Feature request, optional timeout between checks

For some reason the top level domain name '.nu' refuses multiple checks within some close to zero time limit. I noticed that it only works if the checks are approximately 1s between each other. A sleep option between the checks would be appreciated.

Failed to convert timeout

Using ruby2.3.0 and sensu core 0.25.3 this check:
check-whois-domain-expiration-multi.rb -t 30 -w 60 -c 15 -d sensibill.io
fails with this error:
Check failed to run: undefined method zero?' for "30":String, ["/opt/sensu/embedded/lib/ruby/2.3.0/timeout.rb:74:in timeout'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/whois-3.6.3/lib/whois/client.rb:91:in lookup'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration-multi.rb:86:in block in expiration_results'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration-multi.rb:82:in each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration-multi.rb:82:in expiration_results'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-1.1.0/bin/check-whois-domain-expiration-multi.rb:107:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.3.0/lib/sensu-plugin/cli.rb:57:in block in class:CLI'"]

It looks like converting the timeout to_i would solve the issue.
Also, it would be nice to have the same timeout option for check-whois-domain-expiration.rb

ping-check and metrics-ping is not working in 5.0.0

I'm not sure if I did something wrong I just move from Sensu core to Sensu go
and I try to using this ping plugin but it not working

output for metrics-ping is "ping error: unable to ping"
output for ping-check is "CheckPING CRITICAL: ICMP ping unsuccessful for host: (successful: 0/1)"
but my old Sensu core server that still running with same plugin still able to ping without error but it version 4.0.0
I try to install version 4.0.0 plugin into Sensu go also not work

Did I miss anything?
Thank you ver much.

metrics name ('tcp') is truncated when --scheme is used

without --scheme usage:

[ec2-user@ip-10-127-251-45 ~]$ /opt/sensu/embedded/bin/metrics-netstat-tcp.rb -d
ip-10-127-251-45.us-west-2.compute.internal.tcp.UNKNOWN 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.ESTABLISHED 2 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.SYN_SENT 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.SYN_RECV 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.FIN_WAIT1 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.FIN_WAIT2 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.TIME_WAIT 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.CLOSE 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.CLOSE_WAIT 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.LAST_ACK 0 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.LISTEN 2 1522370627
ip-10-127-251-45.us-west-2.compute.internal.tcp.CLOSING 0 1522370627

tcp is truncated when --scheme is used:
[ec2-user@ip-10-127-251-45 ~]$ /opt/sensu/embedded/bin/metrics-netstat-tcp.rb -d --scheme web-server
web-server.UNKNOWN 0 1522370637
web-server.ESTABLISHED 2 1522370637
web-server.SYN_SENT 0 1522370637
web-server.SYN_RECV 0 1522370637
web-server.FIN_WAIT1 0 1522370637
web-server.FIN_WAIT2 0 1522370637
web-server.TIME_WAIT 0 1522370637
web-server.CLOSE 0 1522370637
web-server.CLOSE_WAIT 0 1522370637
web-server.LAST_ACK 0 1522370637
web-server.LISTEN 2 1522370637
web-server.CLOSING 0 1522370637

I added '.tcp.' int scheme option to tackle this problem, so not a big issue but thought to notify.

Failing Ping Checks - Check failed to run: No such file or directory

Hi,

Intermittently, about 1 in every 15-20 checks I get this error when tring to ping. It does not seem to be related to network connectivity.

Check failed to run: No such file or directory - mtr, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-0.2.4/bin/check-ping.rb:101:in``'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-network-checks-0.2.4/bin/check-ping.rb:101:inrun'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in block in <class:CLI>'"]

metrics-ping.rb reporting incorrect results

Centos 7.4
iputils-s20160308
sensu-1.2.0

I'm not sure what unit of measurement the plugin is reporting for latency (I'm assuming seconds), but it's reporting the same for the internet and my internal network which is not correct

[root@graphite bin]# ./ruby ./metrics-ping.rb 10.0.1.30
...
graphite.ping.min 0.064 1515571785
graphite.ping.avg 0.072 1515571785
graphite.ping.max 0.097 1515571785
[root@graphite bin]# ./ruby ./metrics-ping.rb 8.8.8.8
...
graphite.ping.min 0.044 1515572088
graphite.ping.avg 0.064 1515572088
graphite.ping.max 0.073 1515572088

here's ping output just to show what latencies should look like

[root@graphite bin]# ping -c 5 10.0.1.30
PING 10.0.1.30 (10.0.1.30) 56(84) bytes of data.
64 bytes from 10.0.1.30: icmp_seq=1 ttl=64 time=0.178 ms
64 bytes from 10.0.1.30: icmp_seq=2 ttl=64 time=0.196 ms
64 bytes from 10.0.1.30: icmp_seq=3 ttl=64 time=0.249 ms
64 bytes from 10.0.1.30: icmp_seq=4 ttl=64 time=0.198 ms
64 bytes from 10.0.1.30: icmp_seq=5 ttl=64 time=0.260 ms
--- 10.0.1.30 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.178/0.216/0.260/0.033 ms
[root@graphite bin]# ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=6.71 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=59 time=8.19 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=59 time=5.95 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=59 time=8.32 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=59 time=6.30 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 5.955/7.097/8.326/0.985 ms

It also seems to not report packet loss (which is always 0)

[root@graphite bin]# tc qdisc add dev eno16777984 root netem loss 30%
[root@graphite bin]# ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=4 ttl=59 time=8.26 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 1 received, 80% packet loss, time 4000ms
rtt min/avg/max/mdev = 8.262/8.262/8.262/0.000 ms
[root@graphite bin]# ./ruby ./metrics-ping.rb 8.8.8.8 -c 10
...
graphite.ping.packet_loss 0 1515572688
...
[root@graphite bin]# ./ruby ./metrics-ping.rb 8.8.8.8 -c 10
...
graphite.ping.packet_loss 0 1515572702
...
[root@graphite bin]# ./ruby ./metrics-ping.rb 8.8.8.8 -c 10
...
graphite.ping.packet_loss 0 1515572714
...

metrics-ping.rb fails sometimes with Check failed to run: SIGUSR2

Here is the full stack trace

Check failed to run: SIGUSR2, ["/opt/sensu/embedded/lib/ruby/2.2.0/open3.rb:348:in `value'", 
"/opt/sensu/embedded/lib/ruby/2.2.0/open3.rb:348:in `block in capture2e'", 
"/opt/sensu/embedded/lib/ruby/2.2.0/open3.rb:199:in `popen_run'", 
"/opt/sensu/embedded/lib/ruby/2.2.0/open3.rb:188:in `popen2e'", 
"/opt/sensu/embedded/lib/ruby/2.2.0/open3.rb:335:in `capture2e'", "/etc/sensu/plugins/metrics-ping.rb:97:in `ping'", "/etc/sensu/plugins/metrics-ping.rb:105:in `run'", 
"/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]

How can I filter out all veth* interfaces.

Is there a way to hide interfaces that starts with "veth"? My graphite DB is filling up with tons of metrics from this plugin, and I'd like to filter them out if possible.

$ ./metrics-netif.rb
test.veth0cbff6b.rx_kB_per_sec 0.0 1566912465
test.veth0cbff6b.tx_kB_per_sec 0.0 1566912465
test.veth4a7e2fd.rx_kB_per_sec 0.88 1566912465
test.veth4a7e2fd.tx_kB_per_sec 1.6 1566912465
test.vethc2bac1e.rx_kB_per_sec 0.81 1566912465
test.vethc2bac1e.tx_kB_per_sec 1.59 1566912465
test.veth47902d8.rx_kB_per_sec 0.25 1566912465
test.veth47902d8.tx_kB_per_sec 0.83 1566912465
test.lo.rx_kB_per_sec 0.0 1566912465
test.lo.tx_kB_per_sec 0.0 1566912465
test.veth7df096d.rx_kB_per_sec 0.07 1566912465
test.veth7df096d.tx_kB_per_sec 0.06 1566912465
test.vethd47e902.rx_kB_per_sec 0.0 1566912465
test.vethd47e902.tx_kB_per_sec 0.0 1566912465
test.vethe993f5f.rx_kB_per_sec 0.0 1566912465
test.vethe993f5f.tx_kB_per_sec 0.0 1566912465
test.veth987aa56.rx_kB_per_sec 0.26 1566912465
test.veth987aa56.tx_kB_per_sec 0.27 1566912465
test.veth8cd1ca9.rx_kB_per_sec 0.0 1566912465
test.veth8cd1ca9.tx_kB_per_sec 0.0 1566912465
test.vethe97552e.rx_kB_per_sec 0.0 1566912465
test.vethe97552e.tx_kB_per_sec 0.0 1566912465
test.veth00be40e.rx_kB_per_sec 0.0 1566912465
test.veth00be40e.tx_kB_per_sec 0.0 1566912465
test.veth8aeeeac.rx_kB_per_sec 0.0 1566912465
test.veth8aeeeac.tx_kB_per_sec 0.0 1566912465

check-rbl.rb not working

I've gem installed dnsbl-client and sensu-plugin, yet the check fails with the following error:

$ /etc/sensu/plugins/check-rbl.rb
Sensu::Plugin::CLI: ["Not implemented! You should override Sensu::Plugin::CLI#run."]
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:126:in require': cannot load such file -- dnsbl-client (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:126:inrequire'
from /etc/sensu/plugins/check-rbl.rb:32:in `

'

I'm using CentOS 7.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.