Skip to content

Instantly share code, notes, and snippets.

View keymon's full-sized avatar

Hector Rivas Gandara keymon

  • London, UK
  • 20:49 (UTC +01:00)
View GitHub Profile
#!/usr/bin/env python
#
# Author: Hector Rivas <keymon@gmail.com>
#
# This scripts implements a simple plain external node classifier for puppet.
# It reads a plain .yaml file with all definitions returning the gived node name (or all if none)
#
# It supports:
# * inheretance, by setting an extra property in the node "include" and referencing
# other hosts, or by defining classes called "external:<name>"
@keymon
keymon / change_vtd_lun.sh
Created November 8, 2010 13:19
Initial commit of script to change the exported LUN (the lun that the client gets) of a mapped Virtual Target Disk in a VIOS.
#!/bin/sh
SCRIPT_NAME=$0
if [ $# -lt 2 ]; then
cat <<EOF
Updates the exported LUN of a mapped VTD (Virtual Target Device) device in a VIOS.
This script will set the device to "Defined" stated and then rescan the Virtual Adapter:
rmdev -l vtd
@keymon
keymon / basic-firewall.sh
Created November 8, 2010 16:23
Script para poner en /etc/network/if-up.d/.
#!/bin/bash
# Configuracion
IFACES="eth0 eth1 dummy0"
# OpenSSH only cares about inet and inet6.
# Get the gone, strange people still use ipx.
if [ "$ADDRFAM" != inet ] && [ "$ADDRFAM" != inet6 ]; then
exit 0
fi
@keymon
keymon / cgroup-ctl.sh
Created November 19, 2010 08:42
# :Author: Hector Rivas Gandara # # Based on comments in # - http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html # - http://lkml.org/lkml/2010/11/16/330 # # This script enables the Lennart Poettering cgroup alternative to #
#!/bin/sh
#
# cgroup-ctl.sh
#
# :Author: Hector Rivas Gandara
#
# Based on comments in
# - http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html
# - http://lkml.org/lkml/2010/11/16/330
#
@keymon
keymon / rename.pl
Created May 27, 2011 12:36
Perl rename
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker (Robin.Barker@npl.co.uk),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
@keymon
keymon / grepxml.pl
Created November 8, 2011 10:41
This perl script just greps and XML, printing the structure in plain text.
#!/bin/env perl
#
# This is a simple script that "greps" an XML based on
# the names of the xml elements. It prints the contents
# of the Text data in that element
#
# Author: Hector Rivas
#
use XML::Parser;
use Getopt::Std;
@keymon
keymon / background_process.py
Created December 19, 2011 17:55
Implements run a process in background from python, capturing the output in a buffer and allowing set callbacks for the output.
import sys
import subprocess
import threading
try:
import Queue as queue
except ImportError:
import queue
STDOUT = subprocess.STDOUT
@keymon
keymon / mysql_lvm_backupscript.py
Created January 15, 2012 04:17
MYSQL script to backup the DB using LVM
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Requirements
# - Data files must be in lvm
# - Optionally in xfs (xfs_freeze)
# - User must have LOCK TABLES and RELOAD privilieges::
#
# grant LOCK TABLES, RELOAD on *.*
# to backupuser@localhost
@keymon
keymon / accesslog_parse_mongo.py
Created January 15, 2012 04:28
This script reads apache log files entries from the standard input, parses them and stores them in a mongo database.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This script reads apache log files entries from the standard input, parses them
# and stores them in a mongo database.
#
# Requires:
# - pymongo
# - apachelog: http://code.google.com/p/apachelog
#
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Script: example_query_accesslog.py
import accesslog_parse_mongo
import sys
from datetime import datetime, timedelta
def main():