Tuesday, 15 June 2010

transmission + munin



OK, so things like the Rocks Avalanche Installer (pdf) show how useful bittorrent can be for providing a scalable install service. How do you know the status of bittorrent installs though? transmission-remote -l is all well and good if you're on the console but what about long term graphing? Cue Munin and a quick bit of python:


#!/usr/bin/python
# Munin plugin for monitorring transmission bittorrent status
# Andrew Elwell
# $Id: $
import sys, os

if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print "yes"
elif len(sys.argv) == 2 and sys.argv[1] == "config":
print 'graph_args --base 1000'
print 'graph_title Transmission torrent status'
print 'graph_vlabel Count'
print 'graph_category Transmission'

print 'Stopped.label Stopped'
print 'Stopped.draw AREA'
print 'Idle.label Idle'
print 'Idle.draw STACK'
print 'Seeding.label Seeding'
print 'Seeding.draw STACK'
print 'Up.label Up and Down'
print 'Up.draw STACK'
print 'Downloading.label Downloading'
print 'Downloading.draw STACK'
print 'Will.label Will Verify'
print 'Will.draw STACK'
print 'Verifying.label Verifying'
print 'Verifying.draw STACK'

else:
# OK we cheat - initialise ALL values to 0, then overwrite with 'real' ones, then spit out the whole dictionary.
data = {'Stopped': 0, 'Seeding': 0, 'Idle': 0, 'Up': 0, 'Downloading':0, 'Will':0,'Verifying':0 }
for state in os.popen("transmission-remote -l |sed 's/^\s\+//g' | sed 's/\s\{2,\}/~/g' | cut -d '~' -f8 | sort | uniq -c | grep -v '1 $' | grep -v '1 Status' | awk '{print $2, $1}'"):
(s,c) = state.split()
data[s] = c
for k,v in data.iteritems():
print k + '.value' ,v


EDIT: Suppose I should really find a nice template that copes with embedding code, but in the meantime thats what 'view source' is for...

Monday, 14 June 2010

Kerberos & SSH at CERN

Quick blog posting to save me having to explain to people what's needed:

1) RTFM: http://linux.web.cern.ch/linux/docs/kerberos-access.shtml -- thats where most of the good debugging tips are

2) to get it working between say your ubuntu laptop and cern hosts you'll need to append
allow_weak_crypto = true
to /etc/krb5.conf [libdefaults] section. (see bug)

3) make life easy and put a few things in your ~/.ssh/config

host *
Protocol 2
VerifyHostKeyDNS yes
VisualHostKey yes
GSSAPIAuthentication yes
PreferredAuthentications gssapi-with-mic,publickey

host lxplus
hostname lxplus.cern.ch
ForwardAgent yes
GSSAPIDelegateCredentials yes
GSSAPITrustDNS yes

(despite what the man page says there are NO SPACES between the options in PreferredAuthentications (see SSH bug 1702)

Tuesday, 25 May 2010

killed

I rarely have a need for bluetooth on my laptop, so mostly have it disabled. however when I was running Fedora 12. I had a nice option somewhere to leave bluetooth disabled and use the kill switch on my HP Compaq 8510p to purely turn off the wifi (advantage is that it also means the LED indicates wifi activity, not just always on)

However since migrating to Ubuntu Lucid 10.04 I can't reenable the bluetooth. All I have in the gnome widget is 'Your computer does not have any Bluetooth adaptors plugged in.' Grrr. Time to boot off a CD methinks and fix this.

Wednesday, 28 April 2010

yes, Yes, YES!

*something* at home on my linux box is doing alot of DNS lookups

grep 'yes.elwell.org.uk from 127.0.0.1' /var/log/daemon.log | wc -l
13284

and I have no idea what's responsible. (googling for yes and DNS is too vague)
Anyone any ideas?

Update Sussed it
smb.conf had "wins server = yes" not wins support....

Tuesday, 2 March 2010

concerto + twitter

During the trials of concerto at CERN, I wanted to make the text fields a bit more dynamic like say following a specific twitter feed.

This would (ideally) simply consist of a DB entry with type=twitter, value=name of person. In the Real World however I got round this by hacking up a simple python script that connects to the DB and does a simple UPDATE of an existing text/plain entry via cron.

posted below incase others find it useful:

#!/usr/bin/python

# Script to pull twitter feeds for cern / lhcstatus
import twitter
import MySQLdb


conn = MySQLdb.connect (host = "...", user = "...", passwd = "...", db = "...")
api = twitter.Api()
feeds = { 'cern': 25, 'lhcstatus': 28 }
for f in feeds:
tweets = api.GetUserTimeline(f,count=1)
for tweet in tweets:
sql = 'UPDATE content SET CONTENT = "%s" WHERE id = %s' % (tweet.GetText(),feeds[f])
cursor = conn.cursor ()
try:
cursor.execute(sql)
conn.commit()
except:
conn.rollback()
cursor.close ()
conn.close ()


yes its hacky, but hey, called from cron regularly it works :-)

Monday, 1 March 2010

They're following me!


As you know, I've been 'tweeting' the Status of the LHC from the 'Page1 comments' field. Decided to knock up a quick script to plot the number of followers over time, and lo:

Friday, 12 February 2010

Design vs Reality

Decided to check that savannah was behaving as it should be. As with any good process we have a nice flowchart that depicts the allowed transition states.

ie:

however, thanks to a quick 'copy n paste' into graphviz it appears the reality is a little more complicated. Ho hum, cleanup time....




update: Just tidied up savannah and lo:

Ressurection of a WirelessThings OpenPi (from kickstarter)

Many years ago, I was handed one of the openpi kickstarter devices (see https://www.kickstarter.com/projects/wirelessthings/openpi-wireless-...