Skip to content

Instantly share code, notes, and snippets.

@zapman449
zapman449 / keybase.md
Last active September 9, 2019 12:54
keybase.md

Keybase proof

I hereby claim:

  • I am zapman449 on github.
  • I am japrice (https://keybase.io/japrice) on keybase.
  • I have a public key ASCJ6OCbjqub3WpY7ovoe9sRj_1iz7kIB0wVIsQNcBWgiAo

To claim this, I am signing this object:

@zapman449
zapman449 / gist:3cb1eabce2f07e67d9f1
Created May 29, 2015 18:46
Math of Cache Hit Ratios
The formulas to generate the relevant values of Cache Hit ratios (and sundry):
The variables:
1. % is the cache hit ratio
2. H is the raw number of cache hits
3. M is the raw number of cache misses
4. T is the total number of requests.
The formulas:
'''% = H / T'''
@zapman449
zapman449 / Notes:
Created February 15, 2015 15:32
How to get etcd working with a remote cluster. (bonus points: uses vagrant, and systemd)
That execstart line is a little involved. Changes between each cluster node:
change '-name master3' to be the name of this host in the cluster, as specified by the following '-initial-cluster' statement.
change -listen-peer-urls to the IP of this host in the cluster.
change '-listen-client-urls' to reference the IP of this host in the cluster.
You also may need to change the WorkingDirectory, and the path to the etcd binary.
@zapman449
zapman449 / delta_dict.py
Created February 4, 2014 04:56
DeltaDict A dictionary for tracking the deltas between updates.
#!/usr/bin/python
"""
DeltaDict: A python dictionary for keeping track of the delta between numeric
values.
Insert a number in a key, and you'll get that number back. Next insert a
higher number. Now a get() will return the delta between the numbers.
Useful for monitoring applications where you're presented with a monotomically
@zapman449
zapman449 / parse-fuser.sh
Created December 7, 2013 19:24
fuser -m produces very usefil output, but it's a right pain to parse usefully. This cleans up the output, takes away the character codes, and shows you the ps output for each process which is running against the given mountpoint USAGE: parse-fuser.sh <mountpoint_directory> Sample output: [root@qawstream01 ~]# ./parse-fuser.sh /projects/wstream w…
#!/bin/bash
# fuser -m produces very usefil output, but it's a right pain to parse usefully.
# This cleans up the output, takes away the character codes, and shows you the ps
# output for each process which is running against the given mountpoint
# cut removes the "<mount>:" stuff
# sed1 cuts the characters off of the pids produced by fuser
# sed2 kills all leading spaces
# sed3 removes all spaces, and replaces groups of them with a single |
@zapman449
zapman449 / col_gt.py
Created December 7, 2013 19:12
Simple python program to only print a line of output if a certain column is greater than X. Usage: Only show SAR output when the %iowait column is greater than 10 (10 is the default value): sar -u | col_gt.py iowait Only show SAR output when the %idle is > 80 Tuned for sar output specifically, but should be generic enough to handle column based …
#!/usr/bin/python
"""
Look for column named similar to sys.argv[1]. Filter that column based on
metric of 10, or sys.argv[2] if defined.
Tuned for SAR output, but probably is generic enough for others as well.
"""
import fileinput
import sys
@zapman449
zapman449 / redis.spec
Last active December 24, 2015 10:59
A SPEC file for redis 2.4.16.
Pulled from https://github.com/causes/redis-centos/blob/master/spec/redis.spec originally, and tweaked to support 2.4.x releases (tested for 2.4.14 through 2.4.16.
--Jason
#
define bastion_users (
$id,
$homedir = "/home/${name}",
$comment = '',
) {
#$authorized_key,
#$ssh_config,
#$private_key,
#$public_key,