Skip to content

Instantly share code, notes, and snippets.

@hcoyote
hcoyote / find_window.pl
Created February 13, 2012 21:32
Use wmctrl to find a window or exec a command if window name not found.
#!/usr/bin/perl
use strict;
use warnings;
my $debug = 1;
my $wmctrl = '/usr/bin/wmctrl';
my $window_name = shift;
@hcoyote
hcoyote / new_xterm.pl
Created February 13, 2012 21:36
Allow spawning of a new xterm on any work space that isn't setup as an Email work space.
#!/usr/bin/perl
use strict;
use warnings;
our $current_desk;
our @desks;
my $wmctrl = "/usr/bin/wmctrl";
@hcoyote
hcoyote / check_hadoop_metadata_age.pl
Created February 22, 2012 17:26
Determine if the hadoop fsimage file is older than the edits file by some threshold. If the fsimage is older than the edits by some significant value, this is a sign that the secondary namenode may not be properly working because it's not able to produce
#!/usr/bin/perl
#
# This script is managed by puppet.
#
# This check determines if the Hadoop Namenode fsimage file is older
# than the edits file by some threshold. If the fsimage is older than
# the edits by some significant value, this is a sign that the secondary
# namenode may not be properly working because it's not able to produce
# the merged edits+fsimage file that gets sent back to the namenode.
#
@hcoyote
hcoyote / check_hdfs.sh
Created February 22, 2012 17:28
Run hadoop fsck and determine if our HDFS is corrupt in some way. This is very basic and could be extended further to tell you what the corruption really is.
#!/bin/sh
if [ -x /usr/bin/hadoop ] ; then
chk_hdfs=`/usr/bin/hadoop fsck / | grep 'filesystem under path'`
case $chk_hdfs in
*HEALTHY*)
echo "OK - HDFS is healthy"
exit 0
;;
@hcoyote
hcoyote / check_hadoop_safemode.pl
Created February 22, 2012 17:29
Determine if our HDFS is in safemode for some reason.
#!/usr/bin/perl
#
# This script is managed by puppet.
#
use strict;
use warnings;
use File::stat;
use Getopt::Long;
@hcoyote
hcoyote / check_hadoop_dfs_report.pl
Created February 22, 2012 17:33
parse the dfsadmin report and give us some info about the cluster; warn if things are missing, if we have dead nodes, if we don't have enough datanodes, corrupt blocks, etc.
#!/usr/bin/perl
#
# This script is managed by puppet.
#
use strict;
use warnings;
use IO::File;
use Getopt::Long;
@hcoyote
hcoyote / check_zookeeper.sh
Created February 22, 2012 17:35
Get a healthcheck on zookeeper. must be a version that responds to ruok.
#!/bin/sh
HOST=$1
PORT=$2
TIMEOUT=5
if [ ! -x /usr/bin/nc ] ; then
echo "/usr/bin/nc is missing; required for $0 to run"
exit 3
@hcoyote
hcoyote / ops::install_file.pp
Created September 19, 2012 15:59
general puppet define to install a templated file somewhere.
# this define allows us to inject a file into the catalog so it
# transfers over to the client in one big blog, instead of the client having to
# hit up the puppet file server for each file (meaning, 1 additional HTTP request
# per file)
define ops::install_file(
$ensure = present,
$filetype = "bin",
$module = $module_name,
$filename = $name,
@hcoyote
hcoyote / ops::mysql_scripts
Created September 19, 2012 16:02
example usage of ops::install_file
# this calls ops::install_file to install each file in our directory defined in
# ops::install_file ... in our case, /usr/local/ops/bin by default.
class ops::mysql_scripts {
ops::install_file{[
"mye",
"mysql-init",
"mysql-vars",
]:}
@hcoyote
hcoyote / gist:5950262
Created July 8, 2013 16:21
I got your rot13() right here ...
rot13 ()
{
if [ $# = 0 ]; then
tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]";
else
tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" < $1;
fi
}