Skip to content

Instantly share code, notes, and snippets.

View hanynowsky's full-sized avatar
💭
I may be slow to respond.

Hanynowsky hanynowsky

💭
I may be slow to respond.
View GitHub Profile
@hanynowsky
hanynowsky / gist:41de7e55ad60b1258fa1
Created February 20, 2016 16:35 — forked from Buzer/gist:262da357c24907a1d05d
Sensu bridge extension to Flapjack
# Sends events to Flapjack for notification routing. See http://flapjack.io/
#
# This extension requires Flapjack >= 0.8.7 and Sensu >= 0.13.1
#
# In order for Flapjack to keep its entities up to date, it is necssary to set
# metric to "true" for each check that is using the flapjack handler extension.
#
# Here is an example of what the Sensu configuration for flapjack should
# look like, assuming your Flapjack's redis service is running on the
# same machine as the Sensu server:
@hanynowsky
hanynowsky / pantheon-check-ping-endpionts.rb
Created March 11, 2016 16:30 — forked from joemiller/pantheon-check-ping-endpionts.rb
a meta-check for sensu that creates many other checks
#!/usr/bin/env ruby
#
# this is a special meta-check. It runs ping checks against all hosts in
# the /endpoints API and sends individual results directly to sensu-client via
# the udp/3030 client socket. this is different from the normal sensu check model
# where individual scripts run and their exit status and output is used to create
# a single event.
#
# the reason for this check is to be able to dynamically ping a list of hosts
# without the race conditions and timing issues involved with creating individual
@hanynowsky
hanynowsky / stash_slack_integration.md
Created April 26, 2016 09:05 — forked from molaschi/stash_slack_integration.md
Integrate Stash with Slack using webhooks

This is a short article on how we integrate stash and slack in openmind

First of all i assume you have:

  • a working stash installation
  • a repository you to notify slack on pushes
  • stash user with administration priviledges
  • full access to the server (linux) where stash is installed on
  • a team configured on slack
  • slack user with administration priviledges
@hanynowsky
hanynowsky / random-magic-cube.rb
Created May 3, 2016 09:03 — forked from justinburdett/random-magic-cube.rb
This Ruby script generates a random list of Magic: the Gathering cards, ideally for use in making a random Magic cube, and outputs the card list into a text file (suitable for importing into Magic Online or for use in bulk card shopping). For more information on cube drafting, see cubedrafting.com. You can modify the number of cards generated an…
require 'nokogiri'
require 'open-uri'
print "How many cards? "
CARDS_IN_CUBE = gets.strip.to_i
print "What format? "
LEGAL_IN_FORMAT = gets.strip
card_count = 1
# Create or open a text file in the same directory as this file and stores the card names there.
1. Download the plugin from: https://github.com/sensu/sensu-community-plugins/blob/master/handlers/remediation/sensu.rb
2. Create the handler definition:
{
"handlers": {
"remediator": {
"type": "pipe",
"command": "/etc/sensu/handlers/remediator.rb"
}
}
}
#!/bin/bash
# Make sure we have the dev tools
yum groupinstall "Development Tools"
# Just in case you started installing dependencies from yum
yum -y remove libnfnetlink
# lets put the source code here
mkdir -p ~/.src
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
@hanynowsky
hanynowsky / gist:0ea68ce8405038945fe1736abc0d01a2
Created November 28, 2016 13:56 — forked from juanje/gist:1310403
Use Ruby as AWK or Grep
# A few examples about how to use Ruby for parsing files as we could do
# with Awk or Grep. This is based on what I learn fro this post:
# http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/
# Split each line with ':' and print the first $F[0] field
awk -F: '{ print $1 }' /etc/passwd
ruby -F: -nae 'puts $F[0]' /etc/passwd
# Parse the 'ps aux' output
# It'll print the ID process for the 'jojeda' user
@hanynowsky
hanynowsky / json_cleaner.py
Created January 26, 2018 18:35 — forked from liftoff/json_cleaner.py
Allow comments and trailing commas in JSON files using two simple Python functions to clean them up before parsing
#!/usr/bin/env python
"""
An example of how to remove comments and trailing commas from JSON before
parsing. You only need the two functions below, `remove_comments()` and
`remove_trailing_commas()` to accomplish this. This script serves as an
example of how to use them but feel free to just copy & paste them into your
own code/projects. Usage::
json_cleaner.py some_file.json
@hanynowsky
hanynowsky / check_drbd.sh
Created April 3, 2018 13:21 — forked from holly/check_drbd.sh
keepalived+drbd sample
#!/bin/bash
EXIT_CODE=0
STATUS_FILE=/tmp/drbd.status
STATUS=$(sed -e 's/.* state:\(.*\)$/\1/' $STATUS_FILE)
if [ "${STATUS}" != "MASTER" ]; then
echo "current status is ${STATUS}. skip"
exit