Skip to content

Instantly share code, notes, and snippets.

View nstielau's full-sized avatar

Nick Stielau nstielau

  • Red Hat
  • San Francisco
View GitHub Profile
@nstielau
nstielau / client.sh
Created September 27, 2012 23:22
Sensu Push Example
echo '{
"handlers": ["debug"],
"name": "push_woot_test",
"output": "woot!",
"status": 0
}' | nc -w1 127.0.0.1 3030
@nstielau
nstielau / execute_insecure.rb
Last active December 10, 2015 18:48
Chef Symlink Vector Example
execute "say_hello_to_bob" do
command "echo 'hello again' >> /home/bob/hello.txt"
end
@nstielau
nstielau / queue_checks.json
Created March 6, 2013 11:47
Example Sensu check, which only alerts after 10 failures on a 60 second interval, and won't alert on nights or weekends.
{
"checks": {
"noisy_queue_check": {
"handler": "default",
"command": "/etc/sensu/plugins/check-queue-length.rb",
"interval": 60,
"refresh": 60,
"occurrences": 10,
"subscribers": [ "workers" ],
"subdue" : {
@nstielau
nstielau / config.json
Last active December 17, 2015 08:08
Check syntax for triggering remediation (publish:false) actions. If occurrences is 1 or 2, and the severity is 1 (warning), the light_remediation will be triggered. If occurrences is 3 through 10, and the severity is 1 (warning), the medium_remediation will be triggered. If occurrences is above 2, and the severity is 2 (critical), the heavy_reme…
{
"handlers": {
"remediator": {
"type": "pipe",
"command": "/etc/sensu/handlers/remediator.rb"
},
},
"checks": {
"fail_with_remediation": {
"command": "/bin/false",
@nstielau
nstielau / I_exit_clean.coffee
Created May 23, 2013 18:31
Coffeescript zero exit status snippet
# For some reason, coffee appears to exit with
# non-zero status (1) when it recieves a SIGTERM
# by default. This doesn't play nice with process
# managers like systemd. This simple two-liner
# will allow your coffee scripts to exit cleanly.
process.on 'SIGTERM', ->
process.exit()
@nstielau
nstielau / check_with_remediation.json
Last active April 24, 2019 16:35
Example of Sensu remediation.
{
"checks": {
"check_something": {
"command": "ps aux | grep cron",
"interval": 60,
"subscribers": ["application_server"],
"handlers": ["debug", "irc", "remediator"],
"remediation": {
"light_remediation": {
"occurrences": [1, 2],
@nstielau
nstielau / check-load-debug.rb
Last active December 26, 2015 05:39
check_load.rb with debugging output
#!/usr/bin/env ruby
#
# Check Linux system load
# ===
#
# Copyright 2012 Sonian, Inc <[email protected]>
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
@nstielau
nstielau / packer_fedora_bounty.md
Last active December 26, 2015 05:49
Packer for Fedora Vagrant box

WANTED: Automated Fedora Vagrant Box Creation

Deliverables

  • Public Github Repo with Packer VirtualBox templates for Fedora 19, 20
  • Script capable of creating box, testing, and uploading to S3 on success (to be run via CI)
  • Bare-bones Vagrantfile example

Box Requirements

@nstielau
nstielau / victorops.json
Created February 12, 2014 19:13
Configuring Sensu for VictorOps
{
"handlers": {
"victorops": {
"type": "pipe",
"command": "/etc/sensu/handlers/victorops.rb"
}
},
"checks": {
"tmp_check": {
"description": "check that /tmp exists ",
@nstielau
nstielau / lint_json.sh
Created February 25, 2014 21:35
A one-liner for validating json
# Lint JSON with python (the exit 255 stops xargs after the first failed command)
find . -name "*.json" -print | xargs -Ixx bash -c "echo JSON linting xx 1>&2; cat xx | python -mjson.tool > /dev/null || exit 255"