Skip to content

Instantly share code, notes, and snippets.

View donjohnson's full-sized avatar

Don Johnson donjohnson

View GitHub Profile
echo '{"a":4}'|nc hekatest 5565
@donjohnson
donjohnson / gist:36183f5b87a243ec2249
Created May 27, 2014 23:50
Change iterm2 (test build) window profile on ssh connect, and ssh bash autocompletion
# SSH CONFIG
PermitLocalCommand yes
############ prod
Host saltmaster
HostName ec2-xx-xx-xxx-x.us-west-1.compute.amazonaws.com
User ec2-user
LocalCommand echo -e "\033]50;SetProfile=Salt Master\a";
@donjohnson
donjohnson / gist:2654410
Created May 10, 2012 16:46
per-process-timings.sh
#!/bin/bash
hertz=100
host=`cat /etc/hn`
for pidfile in `find /var/run -type f -name '*.pid*'`
do
progname=`basename $pidfile|sed -e 's/\.pid$//g'`;
# if progname = agent, progname = puppet-agent.
if [ $progname = "agent" ]
[root@ps7.p ~]# date;puppet agent --onetime --test --noop
Thu May 3 01:16:16 EDT 2012
info: Caching catalog for ps7.p
info: Applying configuration version '1336022164'
notice: Finished catalog run in 0.10 seconds
[root@ps7.p ~]# date;puppet agent --onetime --test --noop
Thu May 3 01:16:19 EDT 2012
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template sitefiles/motd/default: Could not find value for 'ys_catalog_version' at 7:/etc/puppet/modules/site/sitefiles/templates/motd/default at /etc/puppet/modules/dist/motd/manifests/init.pp:6 on node ps7.p
warning: Not using cache on failed catalog
@donjohnson
donjohnson / gist:2513850
Created April 27, 2012 22:15
mysql slow query log to opentsdb using maatkit/percona query digester
pt-query-digest mysql.slow.log --no-report --filter 'print "put mysql.slowqueries $event->{timestamp} $event->{Query_time} query_md5=" . make_checksum($event->{fingerprint}) . " host=$event->{host} db=$event->{db} dbuser=$event->{user}\n"'|nc opentsdb 4242
format:
put mysql.slow.query 1335559893 1.889435 query_md5=AECBE3F75D62FCA4 host=api1 db=prod dbuser=app
[usr]$ time /opt/ruby/bin/puppet -V
2.7.13
real 0m0.525s
user 0m0.423s
sys 0m0.096s
[usr]$ time /opt/ruby/bin/ruby -v
ruby 1.9.3p194 (2012-04-20) [x86_64-linux]
real 0m0.006s
#!/bin/bash
#TODO: actual callouts
### BEGIN LOCKING CODE
### The following non-reinvented wheel is from http://wiki.bash-hackers.org/howto/mutex.
# lock dirs/files
LOCKDIR="/tmp/statsgen-lock"
PIDFILE="${LOCKDIR}/PID"
$source = "puppet:///modules/sitefiles/ipmiserver/"
$conserver_files = ['/etc/conserver.cf', '/etc/conserver.passwd', '/etc/console.cf']
file { $conserver_files:
source => "$source/$name", #<---would like to use $name here
ensure => present,
require => Package['conserver'],
}
curl -d 'track=#BlackFriday' -uUSER:PASS -s -o - https://stream.twitter.com/1/statuses/filter.json | perl -mJSON -e '$|++; my $json = new JSON; while (<>) {m/\{/ or next ; my $json_text = $json->allow_nonref->utf8->relaxed->decode($_) ; $i++ ; print "\@" . $json_text->{user}{screen_name} . " " . $json_text->{text} . "\n";}'
@donjohnson
donjohnson / gist:1350003
Created November 9, 2011 01:22
splunk :(
[root@vm-splunk01.sf ~]# export SPLUNK_HOME="/opt/splunk"
[root@vm-splunk01.sf ~]# $SPLUNK_HOME/bin/splunk help commands
ERROR: pid 24401 terminated with signal 6
Splunk is not running, and it must be for this operation. To start splunk, run "splunk start".
[root@vm-splunk01.sf ~]# $SPLUNK_HOME/bin/splunk help
ERROR: pid 24411 terminated with signal 6
Splunk is not running, and it must be for this operation. To start splunk, run "splunk start".
[root@vm-splunk01.sf ~]# $SPLUNK_HOME/bin/splunk
Not enough arguments. Please specify a valid command from this list: