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
# | |
# 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
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
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
#!/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
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
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
#!/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
mapper.mappingSource() | |
{"users":{"_all":{"analyzer":"fuzzy"},"_source":{"enabled":false},"properties":{"album_names":{"type":"string","index_name":"album_name","boost":0.8,"include_in_all":true},"created_at":{"type":"date","store":"yes","format":"dateOptionalTime","include_in_all":false},"description":{"type":"string","boost":0.5,"include_in_all":true},"dversion":{"type":"integer"},"features":{"type":"string","include_in_all":false},"firstname":{"type":"string","boost":0.8,"store":"yes","include_in_all":true},"furtive":{"type":"boolean"},"id":{"type":"string","index":"not_analyzed","store":"yes","include_in_all":false},"img_data":{"type":"binary"},"img_url":{"type":"string","index":"no","store":"yes","include_in_all":false},"lastname":{"type":"multi_field","fields":{"lastname":{"type":"string","boost":0.8,"store":"yes","include_in_all":true},"alphaSort":{"type":"string","index":"not_analyzed","store":"yes","include_in_all":false}}},"location":{"type":"string","store":"yes","include_in_all":true},"name":{"typ |
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
#!/bin/sh | |
COOKBOOKS_FOLDER=cookbooks | |
[ -d .git ] && { | |
git fetch | |
if [ -f .git/latest_changes ]; then | |
SRC="$(cat .git/latest_changes).." | |
else | |
SRC="" |