Skip to content

Instantly share code, notes, and snippets.

View philcryer's full-sized avatar
💭
Mostly harmless

Phil Cryer philcryer

💭
Mostly harmless
View GitHub Profile
@philcryer
philcryer / varnish-500-report.sh
Created July 13, 2012 16:46
Finds 50x errors in Varnishncsa logs and writes daily reports for later analysis
#!/bin/bash
# Desc: Finds 50x errors in Varnishncsa logs and writes daily reports for later analysis
# Tags: varnish, varnishlog, varnishncsa, varnishncsa logs, 500 errors, error reports, logs
TODAY_GREP=`date +%d/%b/%Y`
TODAY=`date +%Y%m%d`
REPORT_DIR="/tmp/varnish-500-report"
REPORT_FILE="${REPORT_DIR}/${TODAY}"
VARNISHNCSA_LOG="/var/log/varnish/varnishncsa.log"
@philcryer
philcryer / rpi-openelecup.sh
Last active October 8, 2015 12:38
Raspberry PI OpenELEC updater
#!/bin/bash
# Distributed under the terms of the BSD License.
# Copyright (c) 2012 Phil Cryer [email protected]
# Source https://gist.github.com/gists/3333039
# DESCRIPTION:
# This code updates OpenELEC on Raspberry PI to any available dev version you want
# The script to install the latest version did install the latest, but then failed to run :(
# This script allowed me to try another version (a few days older), which worked :)
@philcryer
philcryer / autostart.sh
Created August 12, 2012 17:11
An example /storage/.config/autostart.sh to do NFS mounting on boot for Raspberry Pi running OpenELEC
#! /bin/sh
(sleep 5;
mount -t nfs 192.168.1.6:/home/media/games -o rw,nolock,tcp,soft,posix,noatime,nodiratime,timeo=600,actimeo=0,nfsvers=3,async,rsize=131072,wsize=131072 /storage/games
mount -t nfs 192.168.1.6:/export/music -o rw,nolock,tcp,soft,posix,noatime,nodiratime,timeo=600,actimeo=0,nfsvers=3,async,rsize=131072,wsize=131072 /storage/music
mount -t nfs 192.168.1.6:/export/videos -o rw,nolock,tcp,soft,posix,noatime,nodiratime,timeo=600,actimeo=0,nfsvers=3,async,rsize=131072,wsize=131072 /storage/videos) &
@philcryer
philcryer / king.sh
Created September 28, 2012 18:57
king of the mountain - because sharing is for faceb00k
#!/bin/bash
# king of the mountain - because sharing is for faceb00k
# * networking fun for geeks in conferences and cafes
# * find other clients on the local network
# * see if they have any exposed files via http
# * use nmap to attempt to knock them offline
# - OSX or Linux supported (nmap, wget required)
# - this script derived from manual steps I used to take
@philcryer
philcryer / gitrc
Last active May 5, 2020 00:00
This .gitrc activates when you're in a directory that is a git repo. It tells you the branch you're on, with color handling of the bash prompt according to the branch/status. For example, the prompt would look like this: [~/foo](master) $ with (master) colored GREEN, until you've added a file to the repo, but not committed it, then it will turn …
#!/bin/bash
#
# Set your bash prompt according to the branch/status of the current git repository.
#
# One-line install:
# curl https://gist.github.com/philcryer/5066010/raw/784e1e4c9df5289fe6f922fb6d122461d374758c/gitrc -o ~/.gitrc; echo "source ~/.gitrc" >> ~/.profile; source ~/.profile
#
# Originally forked from http://gist.github.com/31934 then modified liberally.
#
[...]
[2013-10-02T11:33:38-05:00] INFO: Processing template[/root/.profile] action create (base::default line 1)
[2013-10-02T11:33:38-05:00] INFO: Processing template[/root/.bash_profile] action create (base::default line 8)
[2013-10-02T11:33:38-05:00] INFO: Processing template[/root/.curlrc] action create (base::default line 15)
[2013-10-02T11:33:38-05:00] INFO: Processing yum_key[RPM-GPG-KEY-EPEL-6] action add (yum::epel line 22)
[2013-10-02T11:33:38-05:00] INFO: Processing yum_repository[epel] action add (yum::epel line 27)
[2013-10-02T11:33:38-05:00] INFO: Processing package[tzdata] action install (timezone-ii::default line 16)
[2013-10-02T11:48:49-05:00] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/provider/package/yum-dump.py exceeded timeout 900
[2013-10-02T11:48:49-05:00] INFO: Running queued delayed notifications before re-raising exception
[2013-10-02T11:48:49-05:00] ERROR: Running exception handlers
@philcryer
philcryer / chef woes
Last active December 24, 2015 14:09
20131003 - 76 running chef-client processes exhausting system memory
ISSUE
===========
76 running chef-client processes exhausting system memory, causing other apps to crash (in this case zabbix), chef-client is set to run once an hour, currently showing 76 running processes.
[root@dc2mgmtsavpd01 ~]# ps -fe | grep chef-client | wc -l
76
Also, when I have failed chef-client runs like this I always find this in the ps; a chef-client worker process that is old (hung?), and a yum-dump.py that always needs to be killed before a chef-client run will be successful.
# ps -fe|grep chef
@philcryer
philcryer / nginx config
Last active December 24, 2015 16:58
Current production nginx configuration for fak3r.com, including headers, SSL config and other settings.
# /etc/nginx/sites-enabled/fak3r.com
server {
server_name fak3r.com;
listen 88;
server_name_in_redirect off;
index index.html;
root /usr/share/nginx/www/fak3r.com/;
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
@philcryer
philcryer / gist:6938089
Last active December 25, 2015 07:19
20131015 pd01 error - why does a curl against :80 give an error about memcache being unavail? (note: varnish:80 -> apache:8080 -> moxi
[root@dc2mgmtsavpd01 ~]# curl 10.187.254.188:8080/lbcheck_adv.php
node01 FAILED
Memcache bin <em>default</em> at address localhost:11211 is not available.<br />
Errors on this server will cause it to be removed from the load balancer.
[root@dc2mgmtsavpd01 ~]# /etc/init.d/moxi-server stop
[root@dc2mgmtsavpd01 ~]# netstat -plunt|grep 11211
[root@dc2mgmtsavpd01 ~]# /etc/init.d/moxi-server start
Starting moxi server [ OK ]
@philcryer
philcryer / gist:7009145
Created October 16, 2013 15:03
I want the new Apache DocumentRoot to be owned by apache:apache recursively - how do I do that (ie- chown -R apache:apache /opt/iaas) in chef? This isn't werking:
directory "/opt/iaas/web/app" do
owner "apache"
group "apache"
mode 755
action :create
recursive true
end
directory "/opt/iaas" do
recursive true
owner "apache"