Skip to content

Instantly share code, notes, and snippets.

View martinrusev's full-sized avatar
🌱
01010110

Martin Rusev martinrusev

🌱
01010110
  • Berlin, Germany
View GitHub Profile
check_type, _ , message = file_output.partition(':')
status_regex = re.search(r"(OK|WARNING|CRITICAL|UNKNOWN)", check_type)
try:
status = status_regex.groups()[0]
# Nagios check
if len(message) == 0:
check_type, _ , message = file_output.partition('-')
except:
@martinrusev
martinrusev / ping_google.sh
Created November 10, 2015 06:12
Ping check
ping -c 1 google.com &> /dev/null && echo "OK - Ping to google.com successful" || echo "CRITICAL - Cant ping google.com"
@martinrusev
martinrusev / ignore.py
Created October 16, 2015 10:23
Amon Process Ignore
def is_ignored(self, fragment):
ignore_list = ['indicator', 'unity', 'gnome', 'zeitgeist', 'notify', 'hud', 'colord',
'whoopsie', 'bluetooth', 'ubuntu', 'gtk', 'watchdog', 'bdi', 'jbd',
'kworker', 'flush', 'vbox', 'upstart', 'ksoftirqd', 'irq', 'dbus',
'migration', 'sh', 'ssh', 'nautilus', 'compiz', 'update', 'at-spi',
'telepathy', 'mission', 'network', 'cupsd', 'pulseaudio', 'gvfs',
'udevd', 'dnsmasq', 'init', 'zsh', 'polkit', 'bamfdaemon',
'modem', 'pid', 'console', 'dconf', 'gconf', 'mount', 'dhclient', 'su', 'du', 'df', 'apt',
'sort', 'sleep', 'goa', 'plugin', 'kthreadd', 'kswap', 'khung', 'launc',
'udisks', 'deja', 'cat', 'gdu', 'nm-', 'avahi', 'rtkit', 'accounts', 'acpid',
@martinrusev
martinrusev / piping.go
Created October 1, 2015 08:09 — forked from kylelemons/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@martinrusev
martinrusev / sender.py
Created September 27, 2015 17:49
Amon Notifications Sender
from amon.apps.notifications.generator import generate_notifications
from amon.apps.notifications.generator import generate_message
from amon.apps.notifications.mail.sender import send_notification_email
from amon.apps.notifications.webhooks.sender import send_webhook_notification
from amon.apps.notifications.pushover.sender import send_pushover_notification
from amon.apps.notifications.victorops.sender import send_victorops_notification
from amon.apps.notifications.pagerduty.sender import send_pagerduty_notification
from amon.apps.notifications.opsgenie.sender import send_opsgenie_notification
from amon.apps.notifications.slack.sender import send_slack_notification
@martinrusev
martinrusev / pushover
Created September 27, 2015 12:42
amon_integrations
import requests
import json
from amon.apps.notifications.models import notifications_model
from amon.apps.notifications.generator import generate_message
def send_victorops_notification(notification=None):
sent = False
victorops_data = notifications_model.get_for_provider(provider_id='victorops')
@martinrusev
martinrusev / compress_test.js
Last active September 6, 2015 11:58 — forked from comerford/compress_test.js
Generating data for MongoDB compression testing
// these docs, in 2.6, get bucketed into the 256 bucket (size without header = 240)
// From Object.bsonsize(db.data.findOne()), the size is actually 198 for reference, so add 16 to that for an exact fit
// with that doc size, 80,000 is a nice round number under the 16MiB limit, so will use that for the inner loop
// We are shooting for ~16 GiB of data, without indexes, so do 1,024 iterations (512 from each client)
// This will mean being a little short (~500MiB) in terms of target data size, but keeps things simple
for(var j = 0; j < 512; j++){ //
bigDoc = [];
for(var i = 0; i < 80000; i++){
@martinrusev
martinrusev / initd.amon
Created September 4, 2015 07:10
Amon init metadata
#!/usr/bin/env bash
# chkconfig: 2345 95 05
# description: Amon web server
# processname: amon
# pidfile: /var/run/amon.pid
### BEGIN INIT INFO
# Provides: amon
# Required-Start: $all
@martinrusev
martinrusev / Dockerfile
Last active August 29, 2015 14:28
blog/docker-in-production-for-the-average-devops
# Base container
RUN apt-get install gcc build-essential git python-dev ...
docker build --force-rm=true --rm=true --no-cache -t=yourapp/base .
# yourwebapp:latest
FROM yourwebapp:base
ADD yoursource ....
docker build --force-rm=true --rm=true --no-cache -t=yourapp:latest
auto_accept: True
log_level: debug
max_open_files: 100000
keep_jobs: 1
file_roots:
base:
- /salt/amon