Sha256: 0031268049471c223b833fc236552104b5b9a319eb8c139cb02279d6df35e25e

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

#! /usr/bin/env ruby
#
#   check-lxc-status
#
# DESCRIPTION:
#   This is a simple check script for Sensu to check the status of a Linux Container
#
# OUTPUT:
#   plain text, metric data, etc
#
# PLATFORMS:
#   Linux, Windows, BSD, Solaris, etc
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: lxc
#
# USAGE:
#   check-lxc-status.rb -n name    => name of the container
#
#   Default lxc is "testdebian", change to if you dont want to pass host
#   option
#
# NOTES:
#
# LICENSE:
#   Deepak Mohan Dass   <deepakmdass88@gmail.com>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'lxc'

class CheckLXCSTATUS < Sensu::Plugin::Check::CLI
  option :name,
         short: '-n name',
         default: 'testdebian'

  def run
    conn = LXC.container("#{config[:name]}")
    if conn.exists?
      if conn.stopped?
        critical "container #{config[:name]} is Stopped"
      elsif conn.frozen?
        critical "container is #{config[:name]} in Frozen state"
      else
        ok "container  #{config[:name]} is Running"
      end
    else
      critical "container #{config[:name]} does not Exists"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sensu-plugins-lxc-0.0.3 bin/check-lxc-status.rb
sensu-plugins-lxc-0.0.2 bin/check-lxc-status.rb
sensu-plugins-lxc-0.0.1 bin/check-lxc-status.rb