Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Put me in cron.daily, cron.hourly or cron.d for your own custom schedule
# Running daily? You'll keep 3 daily backups
# Running hourly? You'll keep 3 hourly backups
NUM_BACKUPS_TO_KEEP=3
# Who wants to know when the backup failed, or
# when the binary logs didn't get applied
@ninjix
ninjix / gist:a3e9773de138c2dbfa68
Created December 13, 2014 03:01
SSH config for LXC containers
Host *.lxc
User ubuntu
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
ProxyCommand nc $(grep $(echo %h | sed "s/\.lxc//g") /var/lib/misc/dnsmasq.lxcbr0.leases | awk '{ print $3 }') %p
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
@ninjix
ninjix / url_sha1sum.py
Created October 21, 2014 02:11
A sha1sum check for file URL
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" File download check """
__author__ = "Clayton Kramer"
__copyright__ = "Copyright 2014"
__credits__ = ["Clayton Kramer"]
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Rob Knight"
@ninjix
ninjix / gcharts_area_between_lines.js
Created October 13, 2014 13:44
Google Charts - Area between two lines
// Sourced from http://jsfiddle.net/asgallant/ydNT2/
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['X', 'Y1', 'Y2'],
[0, 6, 12],
[1, 4, 9],
@ninjix
ninjix / apache_status.py
Last active April 19, 2017 18:57
Simple script for monitoring Apache2 mod_status pages. Designed for Zabbix usage.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Quick way to monitor Apache mod_status. Designed for use with Zabbix.
"""
import sys
import urllib2
import argparse
import string
from random import SystemRandom
from django.db import connections
key_chars = string.ascii_letters
random = SystemRandom()
class adhoc_db(object):
"""Context manager that temporarily adds a database connection.
#!/bin/bash
#
# template script for generating CentOS container for LXC
#
#
# lxc: linux Container library
# Authors:
$ python xlogd.py sample.log
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68898', 'priority': '132', 'message': 'bla bla bla warn'}
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68902', 'priority': '131', 'message': 'bla bla bla error'}
parsed: {'appname': 'Dock', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '154', 'priority': '11', 'message': 'CGSReleaseWindowList: called with 5 invalid window(s)'}
parsed: {'appname': 'WindowServer', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '79', 'priority': '11', 'message': 'CGXSetWindowListAlpha: Invalid window 0'}