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
# shows how to use the Ruby AWS SDK to list EC2 instance IDs | |
# when your API credentials have been placed under MFA requirements | |
# Prerequisites: | |
# you are running on a host that already has the AWS CLI set up with an IAM key pair | |
# that can describe EC2 instances (OTHERWISE, just pass a | |
# secret_access_id / secret_access_key pair to the STS client initializer) | |
# You have installed the Ruby AWS SDK Gem | |
# http://aws.amazon.com/sdk-for-ruby/ |
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
# ----------------------------------------------------------------------------- | |
# Monkey patches | |
# Modify `Object` (https://gist.github.com/Integralist/9503099) | |
# None of the above solutions work with a multi-level hash | |
# They only work on the first level: {:foo=>"bar", :level1=>{"level2"=>"baz"}} | |
# The following two variations solve the problem in the same way | |
# transform hash keys to symbols |
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 time_diff(start_time, end_time) | |
seconds_diff = (start_time - end_time).to_i.abs | |
years = (seconds_diff / 31556952) | |
months = (seconds_diff / 2629746) | |
weeks = (seconds_diff / 2628288.0).round(0) | |
days = (seconds_diff / 86400) | |
hours = (seconds_diff / 3600) | |
minutes = (seconds_diff / 60) |
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/ruby | |
require 'date' | |
require 'time_difference' | |
now = DateTime.now.utc | |
last = Time.at( 1506470400000 / 1000 ) | |
puts "now is #{now}. class=#{now.class}" | |
puts "last is #{last}. class=#{last.class}" |
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
class Dashing.Icinga2 extends Dashing.Widget | |
@accessor 'current', Dashing.AnimatedValue | |
onData: (data) -> | |
if data.color | |
# clear existing "color-*" classes | |
$(@get('node')).attr 'class', (i,c) -> | |
c.replace /\bcolor-\S+/g, '' | |
# add new class | |
$(@get('node')).addClass "color-#{data.color}" |
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/bash | |
set -e | |
ICINGA_VERSION=$(icinga2 --version | head -n1 | awk -F 'version: ' '{printf $2}' | grep -Po '(?<=r)\d.\d') | |
ICINGA_CERT_SERVICE_BA_USER=admin | |
ICINGA_CERT_SERVICE_BA_PASSWORD=admin | |
ICINGA_CERT_SERVICE_API_USER=root | |
ICINGA_CERT_SERVICE_API_PASSWORD=${ICINGA_CERT_SERVICE_API_PASSWORD:-''} | |
HOSTNAME=$(grep '^const NodeName' /etc/icinga2/constants.conf | awk -F ' = ' '{printf $2}' | sed -e 's|"||g') |
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/bash | |
DIR="/tmp/icinga-pki/xxxxxx" | |
SATELLITE="icinga2-satellite-2.matrix.lan" | |
SALT=$(echo ${s} | sha256sum | cut -f 1 -d ' ') | |
[ -d ${DIR} ] && rm -rf ${DIR} | |
[ -d ${DIR} ] || mkdir -vp ${DIR} | |
chown icinga: ${DIR} | |
icinga2 pki new-cert \ |
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/bash | |
set -e | |
ICINGA_HOST=${ICINGA_HOST:-localhost} | |
ICINGA_API_PORT=${ICINGA_API_PORT:-5665} | |
ICINGA_API_USER=${ICINGA_API_USER:-root} | |
ICINGA_API_PASSWORD=${ICINGA_API_PASSWORD:-icinga} | |
types= |
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
class CircleQueue | |
include Enumerable | |
class Head | |
attr_accessor :first, :last | |
def initialize | |
self.first = self | |
self.last = self | |
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
require 'resolv' | |
class DnsCheck | |
attr_reader :host | |
def initialize(host) | |
@host = host | |
end | |
def a | |
@a ||= Resolv::DNS.new.getresources(host, Resolv::DNS::Resource::IN::A) |
OlderNewer