Skip to content

Instantly share code, notes, and snippets.

View matthanley's full-sized avatar

Matt Hanley matthanley

View GitHub Profile
@matthanley
matthanley / mariadb-backup.sh
Created April 5, 2022 08:48
Backup script using wsrep_desync and mysqldump for MariaDB/MySQL+Galera clusters
#!/bin/bash
# Usage:
# [BACKUP_DIR=/var/backups] \
# [RETENTION=30] \
# [WSREP_DESYNC=true] \
# ./mariadb-backup.sh <hostname> <database> <user> <password> [<port>]
DB_HOST=${1}
DB_NAME=${2}
@matthanley
matthanley / notify_slack.py
Created April 4, 2022 16:32
MariaDB Galera status notification script for Slack
#!/usr/bin/env python
# configure this in my.cnf on a Galera-based MySQL-alike server:
# wsrep_notify_cmd=/usr/local/sbin/wsrep_notify_slack
import argparse
import json
import os
import socket
import urllib2
@matthanley
matthanley / var-lib-docker-volumes.mount
Created March 11, 2022 15:17
Docker Swarm with GlusterFS volumes
# /etc/systemd/system/var-lib-docker-volumes.mount
# Mounts a Gluster volume on /var/lib/docker/volumes
#
[Unit]
Description=docker volumes
Before=docker.service
[Mount]
What={{gluster_server}}:/{{gluster_volume}}
@matthanley
matthanley / styles.css
Created November 23, 2021 12:36
Custom browser styles
/* Add a gradient to GH labels */
:root .hx_IssueLabel,
[data-color-mode=light][data-light-theme*=light] .hx_IssueLabel,
[data-color-mode=dark][data-dark-theme*=light] .hx_IssueLabel {
--lightness-threshold: 0.7 !important;
--triad1: hsl(
calc(var(--label-h) + 10),
calc(var(--label-s) * 1%),
calc(var(--label-l) * 1%)
);
@matthanley
matthanley / gluster-bricks.sh
Created February 13, 2020 15:14
PRTG monitoring scripts for GlusterFS
#!/bin/bash
if [ -z "$1" ]; then
echo "2:0:no volume provided"
exit 1
fi
# volume bricks online = y
bricks=`sudo gluster volume info $1 | sed -nr 's/Number of Bricks:[^=]+= ([0-9]+)/\1/p'`
online=`sudo gluster volume status $1 detail | egrep 'Online.+Y' | wc -l`
@matthanley
matthanley / service.sh
Created February 13, 2020 11:06
PRTG systemd service check (Linux SSH Script)
#!/bin/sh
systemctl status $1 > /dev/null 2>&1
result=$?
if [ $result -ne 0 ]; then
echo "2:$result:$1 down"
else
echo "0:$result:$1 ok"
fi
@matthanley
matthanley / bashrc
Last active November 4, 2017 12:51
Gentoo bashrc
# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
@matthanley
matthanley / SPDisableEventFiring.cs
Last active December 26, 2015 09:59
Exception-safe method of disabling event firing in SharePoint 2010
public class SPDisableEventFiring : SPEventReceiverBase, IDisposable
{
private bool _eventFiringEnabled;
public SPDisableEventFiring()
{
_eventFiringEnabled = base.EventFiringEnabled;
base.EventFiringEnabled = false;
}