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 / main.yml
Last active August 29, 2015 14:24 — forked from rothgar/main.yml
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
from __future__ import print_function
from snimpy.manager import Manager as M
from snimpy.manager import load
from snimpy.snmp import SNMPNoSuchInstance
#import pymysql
# Load up SNMP MIBs
@hanynowsky
hanynowsky / README.md
Last active August 29, 2015 14:17 — forked from jrydberg/README.md

Riemann is a quite simple but powerful monitoring system. In its core it is an event processing framework allowing a user to handle an incoming event stream. Events are small objects that originate from a host, that has a service and metric value associated with it. Events may also have tags and a free text description. This simple data structure enables an application transmit both exception tracebacks and application metric data using the same mechanism.

Riemann has a few problems though. First, it is a single-machine application, only allowing vertical scaling. Secondly, there's no redundancy or availability solution. In this post we'll try to address the first issue.

vagrant@precise64:~$ irb
1.9.3-p484 :002 > require "riemann"
=> true
# Activate maintenance-mode:
1.9.3-p484 :010 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: "active", ttl: Float::INFINITY}
=> nil
# Deactivate maintenance-mode:
1.9.3-p484 :011 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: nil, ttl: Float::INFINITY}
=> nil
# Linux. Act upon an event in a log file
# www.fduran.com
apt-get upgrade; apt-get install inotify-tools
# create file myalert.sh:
# example finding Exception in tomcat log and sending email
#!/bin/bash
while inotifywait -e modify /path/to/file.log; do
yum -y install autoconf automake bison byacc cpp curl flex gcc gdb git glibc-devel libgcrypt-devel libtool libtool-ltdl-devel m4 make nc pkgconfig rpm-build screen strace tar valgrind vim which OpenIPMI-devel curl-devel ganglia-devel gtk2-devel iptables-devel java-1.7.0-openjdk-devel java-devel jpackage-utils libdbi-devel libesmtp-devel libmemcached-devel libmnl-devel libnotify-devel liboping-devel libpcap-devel librabbitmq-devel libvirt-devel libxml2-devel lm_sensors-devel lvm2-devel mysql-devel net-snmp-devel nut-devel openldap-devel perl-ExtUtils-Embed postgresql-devel protobuf-c-devel python26-devel rrdtool-devel varnish-libs-devel openldap-devel

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

#!/usr/bin/env ruby
# estimate the dewpoint temperature
def dew_point(temp, rv)
e = 6.1121 * (10 ** (7.502 * temp / (237.7 + temp)))
p = (rv * e) / 100.0
dp = (-430.22 + 237.7 * Math.log(p))/(-(Math.log(p)) + 19.08);
end
# estimate the wet bulb temperature
<% header "Content-Type" => "text/html" %>
<h1>Let's run some ruby code: <%= rand %></h1>