bin/check-chef-nodes.rb in sensu-plugins-chef-0.0.6 vs bin/check-chef-nodes.rb in sensu-plugins-chef-1.0.0
- old
+ new
@@ -19,10 +19,11 @@
# gem: <?>
#
# USAGE:
# Look for nodes that haven't check in for 1 or more hours
# ./check-chef-nodes.rb -t 3600 -U https://api.opscode.com/organizations/<org> -K /path/to/org.pem
+# ./check-chef-nodes.rb -t 3600 -U https://api.opscode.com/organizations/<org> -K /path/to/org.pem -e "^sensu.*$"
#
# NOTES:
#
# LICENSE:
# Copyright 2014 Sonian, Inc. and contributors. <support@sensuapp.org>
@@ -56,15 +57,22 @@
option :key,
description: 'Client\'s key',
short: '-K CLIENT-KEY',
long: '--keys CLIENT-KEY'
+ option :exclude_nodes,
+ description: 'Node to excludes',
+ short: '-e EXCLUDE-NODES',
+ long: '--exclude-nodes EXCLUDE-NODES',
+ default: '^$'
+
def connection
@connection ||= chef_api_connection
end
def nodes_last_seen
nodes = connection.get_rest('/nodes')
+ nodes.delete_if { |node_name| node_name =~ /#{exclude_nodes}/ }
nodes.keys.map do |node_name|
node = connection.get_rest("/nodes/#{node_name}")
if node['ohai_time']
{ node_name => (Time.now - Time.at(node['ohai_time'])) > config[:critical_timespan].to_i }
else