Sha256: 46335b43a4274b7168908ec6c964930e236dfdfeec61ad0e5f074ef67a7d958a
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#! /usr/bin/env ruby # frozen_string_literal: false # check-chef-server # # DESCRIPTION: # This plugin uses Chef Servers's `chef-server-ctl` to check to see if # any component of the chef server is not running. This plugin needs # to be run with elevated privileges (sudo) or it will fail with unknown # state. # # OUTPUT: # plain text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # Chef Server # # USAGE: # #YELLOW # # NOTES: # Returns CRITICAL if any of the chef-server processes are in a 'fail' or 'down' state # # LICENSE: # Tim Smith tsmith@chef.io # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' # # Check Chef Server # class CheckChefServer < Sensu::Plugin::Check::CLI def run # chef-server-ctl must be run with elevated privs. fail if we're not uid 0 if Process.uid.nonzero? unknown('check-chef-server must be run with elevated privileges so that chef-server-ctl can be executed') else status = `/usr/bin/chef-server-ctl status` failed_processes = [] status.each_line do |proc| if proc =~ /fail|down|warning/ failed_processes << proc.match('^(fail|down|warning):\s+([a-z-]+)')[2] end end if failed_processes.count.positive? critical("chef-server service(s): #{failed_processes.join(', ')} #{failed_processes.count == 1 ? 'is' : 'are'} failed, down, or in warning state") else ok end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-chef-7.1.1 | bin/check-chef-server.rb |