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
#!/usr/bin/env ruby
require 'snmp'
#include SNMP
require 'logger'
require 'sensu-plugin/check/cli'
# Author: Hanynowsky
# Usage:
# - : Performs some SNMP Checks
# Pastebin aRuOeLwi
sensu::client_custom:
page: false
grafana_url: "http://dashboards.guesswho.com/grafana/#/dashboard/db/system-overview?var-server=%{::hostname}"
processorcount: %{::processorcount}
memorysize: %{::memorysize}
lsbdistdescription: %{::lsbdistdescription}
kernelrelease: %{::kernelrelease}
is_virtual: %{::is_virtual}
guesswho_seclayer: %{::guesswho_seclayer}
#!/usr/bin/env ruby
require 'snmp'
#include SNMP
require 'logger'
require 'sensu-plugin/check/cli'
# Usage: Import specific MIB modules into the snmp gem mib folder
# - : Import specific MIB modules into the snmp gem mib folder
# - : Performs some SNMP Checks
@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 / koji-package-remover
Created April 28, 2015 08:53
force removal of a Koji package
WORKDIR="/tmp"
SQLFILE=$1.sql
cat > $WORKDIR/$SQLFILE << EOF
delete from tag_listing where build_id in (select id from build where pkg_id in (select id from package where name = '$1'));
delete from rpmsigs where rpm_id in (select id from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1')));
delete from buildroot_listing where rpm_id in (select id from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1')));
delete from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1'));
delete from build where pkg_id = (select id from package where name = '$1');
delete from tag_packages where package_id = (select id from package where name = '$1');
delete from package where name = '$1';
@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