View on GitHub


Test Coverage
[![Sensu Bonsai Asset](](
[![Build Status](](
[![Gem Version](](
[![Code Climate](](
[![Test Coverage](](
[![Dependency Status](](

## Sensu Plugins Network Checks Plugin

- [Overview](#overview)
- [Files](#files)
- [Usage examples](#usage-examples)
- [Configuration](#configuration)
  - [Sensu Go](#sensu-go)
    - [Asset registration](#asset-registration)
    - [Asset definition](#asset-definition)
    - [Check definition](#check-definition)
  - [Sensu Core](#sensu-core)
    - [Check definition](#check-definition)
- [Installation from source](#installation-from-source)
- [Additional notes](#additional-notes)
- [Contributing](#contributing)

### 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
Connects to a TCP port on one or more hosts, reads until a char (EOF, EOL, etc), and tests output against a pattern.

Checks domain expiration dates using the API.

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.

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

Checks Netfilter connection tracking table condition. 

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

Ping check script for Sensu.

Connects to a TCP/UDP `address:port` to check whether open or closed.

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

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).

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

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.

Checks expiration dates for multiple domains using the `whois` gem.

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

Provides interface metrics.

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

Fetches network interface throughput metrics.

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.

Pings a host and outputs ping statistics.

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

## Usage examples

### Help

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

Usage: metrics-interface.rb (options)
    -x INTERFACE[,INTERFACE],        List of interfaces to exclude
    -i INTERFACE[,INTERFACE],        List of interfaces to include
    -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
  name: sensu-plugins-network-checks
  sha512: 0fe990e4eb53c308c6245d8ac8cc7268d34e3235d5188ecda3a7308889a09b8b722a77f57169d6d9a7c2f1bf3b523fcdcb618aeb4cd6b83bd74feb3683d721b7

#### Check definition

type: CheckConfig
  command: "check-banner.rb"
  handlers: []
  high_flap_threshold: 0
  interval: 10
  low_flap_threshold: 0
  publish: true
  - sensu-plugins/sensu-plugins-network-checks
  - sensu/sensu-ruby-runtime
  - 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](#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 []( for information about contributing to this plugin.