Skip to content

Instantly share code, notes, and snippets.

View RPDiep's full-sized avatar

Rene Diepstraten RPDiep

  • PCextreme B.V.
  • Middelburg, The Netherlands
View GitHub Profile
#!/bin/bash
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
### END INIT INFO
# Usage:
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached_server1
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached_server2
@RPDiep
RPDiep / mysqlbackup.sh
Last active December 20, 2015 18:09
A script to create mysql backups and keep backups with a retention scheme.
#!/bin/bash
#
# Copyright 2013 Rene Diepstraten
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/bin/bash
#
# A simple remote side-by-side diff
#
# Author: Rene Diepstraten <rene@renediepstraten.nl>
#
[[ $# -ne 2 ]] || [[ ! $1 =~ ":" ]] || [[ ! $2 =~ ":" ]] && { echo -e "\nUsage: $0 <host1>:<file> <host2>:<file>\n" >&2 ; exit 1; }
file1=${1##*:} ; host1=${1%%:*} ; file2=${2##*:} ; host2=${2%%:*}
@RPDiep
RPDiep / 98r1soft-installmodule
Last active August 29, 2015 13:56
Apt hook for installing r1soft modules on ubuntu
DPkg::Post-Invoke {"/usr/local/sbin/r1soft-installmodule"}
@RPDiep
RPDiep / removeoldkernels
Last active March 4, 2016 15:05
A script to remove old kernels in ubuntu
#!/bin/bash
kernelversion=$(uname -r)
kernelminversion=${kernelversion%-*}
latestkernelversion=$(dpkg -l | awk '/linux-image-[0-9]/ {print $2}' | sort | tail -1 | grep -o '[0-9][0-9\.-]*[0-9]')
packages_to_remove=$(dpkg -l | awk '/linux-(image|headers)-[0-9]/ {print $2}' | egrep -v "${kernelminversion}|${latestkernelversion}")
[[ -z "${packages_to_remove}" ]] || dpkg -P ${packages_to_remove}
@RPDiep
RPDiep / show_ipaddresses
Created February 11, 2014 12:46
A simple script to show the ip addresses for a host
#!/bin/bash
# Find the device with the default route
default_eth=$(ip r | awk '/default via/ {print $5}')
# Show the IP addresses for this device
ip a s ${default_eth} | awk '/global/ {print $2}' | cut -d'/' -f1
@RPDiep
RPDiep / dbcheck.py
Last active August 29, 2015 14:01
A simple python script that checks for crashed tables. The output file can be read by monitoring solutions such as zabbix, nagios or icinga.
#!/usr/bin/python
#
# Author: Rene Diepstraten <rene@pcextreme.nl>
#
outputfile = "/var/dbcheck/dbcheck.txt"
import MySQLdb, signal, sys
def sigint_handler(signum, frame):
@RPDiep
RPDiep / udplogreceiver.ini
Created May 30, 2014 14:37
UDP log receive script
[web01]
port=5141
logfile=/var/log/web01.log
@RPDiep
RPDiep / zabbix_wsrep_stats
Created June 12, 2014 11:14
zabbix_wsrep_stats
#!/usr/bin/python
#
# Author: Rene Diepstraten <rene@pcextreme.nl>
#
send_items=[
'wsrep_apply_oooe',
'wsrep_apply_oool',
'wsrep_apply_window',
'wsrep_causal_reads',
#!/usr/bin/python
import socket
import subprocess
import sys
import tempfile
import urllib2
url='http://127.0.0.1/server-status?auto'
zabbixhost='zabbix'