Skip to content

Instantly share code, notes, and snippets.

View joemiller's full-sized avatar

joe miller joemiller

View GitHub Profile
# yum -y install rubygem-sensu
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.sonic.net
* epel: mirrors.solfo.com
* extras: mirror.raystedman.net
* updates: centos.mirrors.hoobly.com
sensu | 1.2 kB 00:00
sensu/primary | 1.0 kB 00:00
sensu 1/1
$ rpm2cpio sensu-release.noarch.rpm |cpio --list
./etc/yum.repos.d
./etc/yum.repos.d/.bash_history
./etc/yum.repos.d/.bash_logout
./etc/yum.repos.d/.bash_profile
./etc/yum.repos.d/.bashrc
./etc/yum.repos.d/.cshrc
./etc/yum.repos.d/.gem
./etc/yum.repos.d/.gem/specs
./etc/yum.repos.d/.gem/specs/rubygems.org%80
@joemiller
joemiller / ex.rb
Created January 17, 2012 14:58
perl friendly ruby regex example for smooth_p
$ cat test.txt
blah 100
foo 20
$ cat test.rb
File.read('test.txt').each do |line|
line =~ /^(\w+)\s+(\d+).*$/
puts $1 + $2
end
## 'update-static-leases on;' tells dhcpd to send ddns updates even for
## hosts that have 'fixed-addresses'.
update-static-leases on;
# the following logic is used when deciding what hostname to register in DNS
# when a client is assigned an addres. The logic below says:
# 1. if the client sent a host-name as part of the DHCPREQUEST, use it
# 2. else, if the client is part of a fixed declaration, such as: "host <name> { .. }",
# use <name> as the client's hostname
# 3. default scenario: we can't figure anything out, so lets use the MAC address for the
# hostname
if exists host-name {
option server.ddns-hostname = option host-name;
} elsif known {
#lease-file-name "/usr/local/dhcpd/var/dhcpd.leases";
#pid-file-name "/usr/local/dhcpd/var/dhcpd.pid";
#ping-check false;
option ntp-servers 10.0.0.1;
option domain-name "dom.tld";
option domain-name-servers 10.0.0.1;
@joemiller
joemiller / gist:1670573
Created January 24, 2012 15:01
Sensu-reuse-nagios-plugins-for-quick-profit.md

In my previous article I mentioned a key strength of Sensu is the ability to re-use existing Nagios plugins. This is a powerful feature of Sensu. Nagios has been around for at least 1000 years according to most recent archaeological discoveries, which means a vast amount of human effort (and capital) has gone into creating Nagios plugins. Being able to leverage this prior effort is a huge win. In this article I'll demonstrate creating a Sensu check with the check_http Nagios plugin.

Install the check_http nagios plugin

Following on the previous article, we'll be doing this demo based off of CentOS 5 but it should not be difficult to find a build of check_http for your distribution.

First, Make sure you have the EPEL yum repo installed on your machine. Next, let'

@joemiller
joemiller / shell-output
Created January 27, 2012 23:24
poc catamqp
$ echo "yo dog, i heard you like some cats with your queues so i catted your queues" | ./catamqp.rb
$ ./amqpcat.rb
yo dog, i heard you like some cats with your queues so i catted your queues
@joemiller
joemiller / gist:1720349
Created February 2, 2012 00:17
new style sensu handler example for bensix2 on irc
"handlers": {
"default": { "type": "pipe", "command": "/etc/sensu/handlers/default" },
},
@joemiller
joemiller / checks.json
Created February 2, 2012 11:25
a simple sensu check.
{
"checks": {
"test": {
"handler": "default",
"command": "echo 'Im OK'; exit 0",
"standalone": true,
"interval": 60
}
}
}