Stop! mysqlHammerOfThor.py time!

So, expanding upon my previous post, I wrote a simple python script that would kill all queries running on a MySQL instance based on a host wildcard or runtime of a query.

Yes, yes, I know about mk-kill, but I enjoy writing little scripts.  Writing trivial scripts is always a great way to get better. :)

Continue reading

Share

Code Example: Linux + PyUSB & the Dream Cheeky Thunder/Storm USB Missile Launcher


Went to Staples the other day to grab some assorted accessories for work and I saw they had some Brookstone USB Desktop Missile Launchers in the clearence section, so I grabbed one.

What fun, I thought. Plugged it into my work desktop (running LinuxMint Debian Edition) only to find there were no linux drivers for this particular device.

This turned into a nice little weekend project :)

Continue reading

Share

Building and Installing Python 2.7 RPMs on CentOS 5.7


I was asked today to install Python 2.7 on a CentOS based node and I thought I’d take this oportunity to add a companion article to my Python 2.6 article.

We’re all well aware that CentOS is pretty backwards when it comes to having the latest and greatest sotware packages and is particularly finicky when it comes to Python since so much of RHEL depends on it.

As a rule, I refuse to rush in and install anything in production that isn’t in a manageable package format such as RPM. I need to be able to predictably reproduce software installs across a large number of nodes.

The following steps will not clobber your default Python 2.4 install and will keep both CentOS and your developers happy.

So, here we go.

Continue reading

Share

Code Example: Using Python Suds to Access the Bronto API.

For some internal notification system I was attempting to write a script that would occasionally clear a list in Bronto, our email delivery platform.

They have a lovely little SOAP API, but almost all of the examples were in PHP or Java. Since I am running this as a cronjob, and me being more of a Pythonist, I thought Python was a better place for me to implement this.

The Bronto team, while not terribly proficient in Python, were as helpful as they could be. My major stumbling blocks were getting the authentication mechanism to work correctly, then it took a while to discover how to properly pass arguments to the API.

Eventually I’ll do more stuff with it, but for now, I thought I’d publish this in case it might be useful for someone else using Python with thier API.

Code starts below. Mind you, I am not a developer, be kind :)

Continue reading

Share

Building RPMs for and setting up StatsD and Graphite on CentOS.

A while back Etsy opensourced a little node.js daemon called StatsD that makes it easy for you to ‘Measure All the Things.’

In my current environment setting up graphs for the folks on the business team and on the dev team is difficult and time consuming as it has to funnel through ops. We’re a bottleneck :(

I’m hoping to implement StatsD to make graphing a service that most anyone can directly interact with and remove me and my team as the bottleneck.

Below are my notes for setting it up.

Continue reading

Share

In which I discourse on Java bloat and Cassandra Node Balancing.

So, I was hoping to write a little snippet of code to embed on my blog to allow people to get the token ranges for load balancing their cluster.

In Cassandra, when using the random partitioner, all keys are given a token (essentially an md5 of the Key) that is between 0 and 2^127 (0 through 170141183460469231731687303715884105728 for non-nerds). That range is known as the ring.

Each member node of the Cassandra cluster owns a range of those keys on the ring in the same vein you’d divide up a pie.

Continue reading

Share

New method for installing Python 2.6.4 (with mysql-python) on CentOS 5.5

So I wrote in an earlier post about alt-installing Python 2.6 from source on CentOS, which was easy enough.  But, this made it more difficult to maintain and deploy as well as add modules.  So, I was lucky enough to come across a nice little yum repository hosted by Rizwan Kassim (Geekymedia.com) that contained an RPM that would do the alt-install work for me :)

I’m aware that EPEL has a Python 2.6 package, but the Geekymedia RPMs have a whole flurry of modules you can add as well as an RPM for setuptools which will make your life immeasurably easier when running Python 2.4 and 2.6 side-by-side for installing python packages.

The only problems with the Geekymedia RPMs are that the binary packages are all 32-bit (I’m running servers here folks!) and I was unable to get the MySQL-python26 one to work right for me.

So, let’s get down to business.

Continue reading

Share

Alt-Installing Python 2.6 from source in CentOS

I work with some smart folks who need the latest stuff to get the job done. However, this can sometimes be a problem when you use a more conservative (read: stable) Linux distribution like CentOS.

You see, CentOS 5 comes bundled with Python 2.4 where Fedora or Ubuntu (or Linux Mint) ship with Python 2.6.

(nathan@citadel:~)$ cat /etc/issue
Linux Mint 9 Gloria - Main Edition \n \l
(nathan@citadel:~)$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
(nathan@test1:~)$ cat /etc/issue
CentOS release 5.5 (Final)
(nathan@test1:~)$ python
Python 2.4.3 (#1, Sep  3 2009, 15:37:37)

Continue reading

Share