This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'trollop' | |
require 'pp' | |
opts = Trollop::options do | |
opt :list, "List local installed gems in shell friendly format", :type => :boolean | |
opt :info, "Display Dependency information about gem", :type => :string | |
opt :check, "Check All installed gems and return broken dependencies", :type=> :boolean | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module God | |
class Watch < Task | |
VALID_STATES = [:init, :up, :start, :restart, :stop] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def should_i_start? | |
puts "Should I ?" | |
Time.now.min % 2 == 1 | |
end | |
def setup_watch(w) | |
w.stop_if do |on| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Copyright (c) 2011 Fotonauts | |
# All rights reserved. | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above copyright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define host { | |
use generic-host <%# Inherit default values from a template %> | |
<%# Use FQDN because munin will send alerts using the FQDN %> | |
host_name <%= @host['fqdn'] %><%# The name we’re giving to this host %> | |
alias <%= @host['hostname'] %><%# A longer name associated with the host %> | |
address <%= @host['ipaddress'] %><%# IP address of the host %> | |
} | |
<% @services.each do |service, info| | |
info = info.to_hash | |
if DefaultMonitoredValues::check_on(info).include?(@host['swissr']['grid']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby_block "Delete Legacy Files" do | |
block do | |
existing = [] | |
Dir.new('/etc/nagios3/conf.d/').each do |f| | |
next if f == '.' or f == '..' | |
existing << f | |
end | |
reals = search(:node, "monitored:[* TO *]").map{ |n| n[:fqdn] +".cfg" } | |
(existing - reals).each do |leftover| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: monitored | |
define :monitored, :additional_params => {} do | |
if ! params[:depends].is_a?(Array) && params[:depends] != nil | |
raise "Depends must be an array (#{params[:depends].inspect})" | |
end | |
doc = {}.merge(params[:additional_params]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DefaultMonitoredValues | |
# Handle defaults to prevent cluttering the chef registry with these things | |
def DefaultMonitoredValues.value_or(hash, key, or_value) | |
if hash.has_key?(key) | |
hash[key] | |
else | |
or_value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
order = node.recipes | |
if order[-1] != "lastrecipe" | |
Chef::Log.error("Last Recipe should be the last recipe to run") | |
raise "Please refactor my runlist" | |
end | |
# This recipe is tightly integrated with monitored in fotonauts and recipe | |
# firstrecipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This recipe should be called at the beginning of the run_list | |
# If we are not the last item of the run_list break | |
order = node.recipes | |
if order[0] != "firstrecipe" | |
Chef::Log.error("First Recipe should be the first recipe to run; current run list is "+order.inspect) | |
raise "Please refactor my runlist" | |
end |