<commit_before>#! /usr/bin/env ruby
#
#   check-dhcp
#
# DESCRIPTION:
#   This plugin checks DHCP server responses.
#   It must run as root to be able to bind to a listening port (udp 67 or 68)
#   By default it will simply check for a response to a discover broadcast
#   that is a valid DHCP::Message, ignoring contents.
#
#   If 'server' is specified, the check pretends to be a DHCP relay-agent, and
#   does a unicast request against a specific DHCP server.
#
#   The 'offer' or 'ipaddr' options can be used to test that the response
#   is an offer (of any address), or of a specific address.
#
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: net-dhcp
#   gem: socket
#   gem: ipaddr
#
# USAGE:
#   #YELLOW
#
# NOTES:
#
# LICENSE:
#   <NAME> <<EMAIL>>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'
require 'net/dhcp'
require 'ipaddr'
require 'socket'

class CheckDHCP < Sensu::Plugin::Check::CLI
  option :server,
         description: 'IP address of DHCP Server - will use unicast',
         short: '-s SERVER',
         long: '--server SERVER'

  option :timeout,
         description: 'Time to wait for DHCP responses (in seconds)',
         short: '-t TIMEOUT',
         long: '--timeout TIMEOUT',
         default: '10'

  option :offer,<commit_msg>Remove Ruby 1.8.7 compat<commit_after>#! /usr/bin/env ruby
#
#   check-dhcp
#
# DESCRIPTION:
#   This plugin checks DHCP server responses.
#   It must run as root to be able to bind to a listening port (udp 67 or 68)
#   By default it will simply check for a response to a discover broadcast
#   that is a valid DHCP::Message, ignoring contents.
#
#   If 'server' is specified, the check pretends to be a DHCP relay-agent, and
#   does a unicast request against a specific DHCP server.
#
#   The 'offer' or 'ipaddr' options can be used to test that the response
#   is an offer (of any address), or of a specific address.
#
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: net-dhcp
#   gem: socket
#   gem: ipaddr
#
# USAGE:
#   #YELLOW
#
# NOTES:
#
# LICENSE:
#   <NAME> <<EMAIL>>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'net/dhcp'
require 'ipaddr'
require 'socket'

class CheckDHCP < Sensu::Plugin::Check::CLI
  option :server,
         description: 'IP address of DHCP Server - will use unicast',
         short: '-s SERVER',
         long: '--server SERVER'

  option :timeout,
         description: 'Time to wait for DHCP responses (in seconds)',
         short: '-t TIMEOUT',
         long: '--timeout TIMEOUT',
         default: '10'

  option :offer,
{'fraction_non_alphanumeric': 0.11005625879043601, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 2.973463687150838, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1153498', 'n_tokens_mistral': 990, 'n_tokens_neox': 947, 'n_words': 363}