Software, Physics, Data, Mountains

...and other random associations

Core Infrastructure Part 1 - Adding NFS to Juju Charms

Several features have recently landed in juju that make it easier to convert some common infrastructure-level components over and use them within your stack of services. I figured it’s worth a series of posts about core services, storage, logging, monitoring, messaging, etc… and how they fit into the juju ecosystem.

We’ll start with NFS. I’d consider that vanilla workhorse to be core infrastructure technology… it’s still pretty much everywhere you look. Many friends keep ancient boxes around as dedicated NFS fileserver appliances that are usually in fairly critical roles. Well, how would this fit into a sexy new juju stack of services?

PreSonus FireBox in Ubuntu

Just some notes to myself for later.

I want a little better sounding audio on screencasts so I dusted off the firewire soundcard I got a few years ago for recording bass tracks.

This model FireBox 24-bit/96kHz from PreSonus worked great for me on audio production stuff several years ago, but at the time I could give jackd and friends a realtime kernel to have their way with.

Now, I don’t really have the spare hardware to dedicate to a RT audio setup…
gotta run several ubuntu server VMs for work and can’t really hand the whole shebang over to jack every time I wanna record something.

Here’s my attempt to do it without realtime priorities… I’ll track my progress here.

Git-create New Github Repos

Ok, I’m too lazy to go through the web interface every time I want to add a new github repo. github api to the rescue…

The goal

I want

git create myrepo "my repo description"

to create a new github repo ‘myrepo’.

Grrr… Fix Dpms on Hawk

From here

#!/usr/bin/perl
my $cmd = q[dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'"];
open (IN, "$cmd |");
while (<IN>) {
    if (/^\s+boolean true/) {
        system '~/gpufolding/gpufah.bash';
    }
    elsif (/^\s+boolean false/) {
        system 'kill `pgrep gupfah.bash`';
        system 'kill `pgrep Folding.*home`';
    }
}

From here

#!/usr/bin/perl
#gnome
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";

open (IN, "$cmd |");

while (<IN>) {
if (m/^\s+boolean true/) {
#when screensaver activates, run the following commands
#system("/home/eric/compiled/scripts/rtorrentstart");
system("touch /home/asoukenka/rtorrenthasstarted");
} elsif (m/^\s+boolean false/) {
#when screensaver deactivates, run the following commands
#system("kill `pgrep rtorrent`");
system("touch /home/asoukenka/rtorrenthasbeenkilled");
}
}

and

#!/usr/bin/perl
#requires:
# rtorrent, screen, gnome/kde, perl
#
# Instructions:
# - Properly comment the line for gnome or kde
# - Give script execute permission (chmod +x)
# - Run script ./<scriptname> **** do not use rtorrent in script name will mess up kill command
#
# There is a log file created by the script at /tmp/autortorrent 
#
#


#gnome
#my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";

#kde
my $cmd = "dbus-monitor --session \"type='signal',interface='org.freedesktop.ScreenSaver',member='ActiveChanged'\"";
open (IN, "$cmd |");

while (<IN>) {
if (m/^\s+boolean true/) {
#when screensaver activates, run the following commands
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
system("screen -dmS rtorrent rtorrent");
system("echo \"started:\" >> /tmp/autortorrent");
system("date >> /tmp/autortorrent");
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
} elsif (m/^\s+boolean false/) {
#when screensaver deactivates, run the following commands
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
system("kill `pgrep rtorrent`");
system("echo \"stopped:\" >> /tmp/autortorrent");
system("date >> /tmp/autortorrent");
#system("ps aux |grep rtorrent >> /tmp/autortorrent");
system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent");
}
}

from here

#!/bin/sh
gnome-screensaver-command --lock
xset dpms force off
gnome-screensaver-command --inhibit
exit

also some stuff in here

Try to run gnome-screensave in no-daemon and debug mode to see what’s going on… according to https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/193192


Some inhibit stuff from here

#!/usr/bin/python
import subprocess

#run inhibition
ss_inhibit = subprocess.Popen(["gnome-screensaver-command", "-i", "-n", 
                               "mplayer", "-r", "video"])

#run gmplayer
player = subprocess.Popen("gmplayer")

#wait for mplayer to exit
player.wait()

#kill the inhibition
ss_inhibit.kill()

or from here

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"

or

dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /ScreenSaver org.gnome.ScreenSaver.SimulateUserActivity
dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"
gnome-screensaver-command --poke

Run Single Rspec Test

From here

./script/spec spec/models/posting_spec.rb -e"should update the analyst's employer count of active ideas"

Debug Rspec

Duh

./script/spec --debug spec/models/posting_spec.rb 

Hadoop-test-install

From Michael Noll’s hadoop on ubuntu post

mkdir /var/lib/hadoop
chown mmm.mmm /var/lib/hadoop

hadoop datanode -format

bin/start-all.sh 

hadoop dfs -copyFromLocal /tmp/gutenberg gutenberg

hadoop dfs -ls

hadoop jar /usr/local/hadoop/hadoop-mapred-examples-0.21.0.jar wordcount gutenberg gutenberg-output

hadoop dfs -ls
hadoop dfs -ls gutenberg-output

bin/hadoop dfs -cat gutenberg-output/part-r-00000
mkdir /tmp/gutenberg-output
bin/hadoop dfs -getmerge gutenberg-output /tmp/gutenberg-output
head /tmp/gutenberg-output/gutenberg-output