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
@RPDiep
RPDiep / fizzbuzz.py
Last active December 2, 2017 12:34
FizzBuzz python oneliner
print('\n'.join([('Fizz' if i % 3 == 0 else '') + ('Buzz' if i % 5 == 0 else '') or str(i) for i in range(1,101)]))
@RPDiep
RPDiep / pingwrapper.py
Created October 12, 2016 11:02
A wrapper around ping which uses ping6 if the target has an AAAA record
#!/usr/bin/python3
import ipaddr
import os
import socket
import sys
if len(sys.argv) == 1:
print("""Usage: %s <hostname|ip>""" % sys.argv[0])
sys.exit(1)
#!/bin/bash
max_apache_semaphores=20
cur_apache_semaphores=$(ipcs -s | grep -c apache)
apachectl=$(which apache2ctl apachectl 2>/dev/null)
[[ ${cur_apache_semaphores} -ge ${max_apache_semaphores} ]] && {
logger -t $(basename $0) "Cleaning up semaphores for apache"
ipcs -s | awk '/apache/ {print $2}' | xargs -n1 ipcrm -s
${apachectl} restart
@RPDiep
RPDiep / README.md
Last active March 4, 2016 15:07
Ubuntu Kernel Cleanup

Ubuntu Kernel Cleanup

General

This script is used to remove old kernels cluttering /boot on Ubuntu systems. The following kernels are preserved:

  • The running kernel
  • The latest kernel from each major version
@RPDiep
RPDiep / keybase.md
Created January 21, 2015 10:12
keybase.md

Keybase proof

I hereby claim:

  • I am RPDiep on github.
  • I am rpdiep (https://keybase.io/rpdiep) on keybase.
  • I have a public key whose fingerprint is 920D 7C11 15D7 5A39 6741 F096 9F01 AF83 773B 3208

To claim this, I am signing this object:

@RPDiep
RPDiep / outgoing_ipv6.sh
Created August 13, 2014 07:42
A script to label the secondary ipv6 addresses differently, thus making the first ipv6 the default for outgoing connections
#!/bin/bash
ETH=$(ip -6 r | awk '/^default/ {print $5}')
for IP in $(awk -F '=' '/IPV6ADDR_SECONDARIES/ {gsub("\"",""); gsub("/[0-9]*","/128"); print $2}' /etc/sysconfig/network-scripts/ifcfg-${ETH})
do
ip addrlabel add prefix ${IP} label 1001
done
#!/usr/bin/python
import socket
import subprocess
import sys
import tempfile
import urllib2
url='http://127.0.0.1/server-status?auto'
zabbixhost='zabbix'
@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',
@RPDiep
RPDiep / udplogreceiver.ini
Created May 30, 2014 14:37
UDP log receive script
[web01]
port=5141
logfile=/var/log/web01.log
@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):