Posts

JSON output from DF

So I'm adding more capabilities to my sysinfo.py program. The next thing that I want to do is get a JSON result from df . This is a function whose description, from the man page, says "report file system disk space usage". Here is a sample of the output of df for one of my systems: Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/flapjack-root 959088096 3802732 906566516 1% / udev 1011376 4 1011372 1% /dev tmpfs 204092 288 203804 1% /run none 5120 0 5120 0% /run/lock none 1020452 0 1020452 0% /run/shm /dev/sda1 233191 50734 170016 23% /boot So I started by writing a little Python program that used the subprocess.check_output() method to capture the output of df . This went through various iterations and ended up with this single line of python code, which requires eleven lines...

Automatic Inventory

Now I have four machines.  Keeping them in sync is the challenge.  Worse yet, knowing whether they are in sync or out of sync is a challenge. So the first step is to make a tool to inventory each machine.  In order to use the inventory utility in a scalable way, I want to design it to produce machine-readable results so that I can easily incorporate them into whatever I need. What I want is a representation that is both friendly to humans and to computers.  This suggests a self-describing text representation like XML or JSON.  After a little thought I picked JSON. What sorts of things do I want to know about the machine?  Well, let's start with the hardware and the operating system software plus things like the quantity of RAM and other system resources.  Some of that information is available from uname and other is availble from the sysinfo(2) function. To get the information from the sysinfo(2) function I had to do several things: Install sysinfo on each machine sudo apt-get ...

Log consolidation

Image
Well, my nice DNS service with two secondaries and a primary is all well and good, but my logs are now scattered across three machines. If I want to play with the stats or diagnose a problem or see when something went wrong, I now have to grep around on three different machines. Obviously I could consolidate the logs using syslog. That's what it's designed for, so why don't I do that. Let's see what I have to do to make that work properly: Set up rsyslogd on flapjack to properly stash the DNS messages Set up DNS on flapjack to log to syslog Set up the rsyslogd service on flapjack to receive syslog messages over the network Set up rsyslog on waffle to forward dns log messages to flapjack Set up rsyslog on pancake to forward dns log messages to flapjack Set up the DNS secondary configurations to use syslog instead of local logs Distribute the updates and restart the secondaries Test everything A side benefit of using syslog to accumulate my dns logs is tha...

Waiting for the File Server

Well, I now have four different UNIX machines and I've been doing sysadmin tasks on all of them.  As a result I now have four home directories that are out of sync. How annoying. Ultimately I plan to create a file server on one of my machines and provide the same home directory on all of them, but I haven't done that yet, so I need some temporary crutches to tide me over until I get the file server built. In particular, I need to find out what is where. The first thing I did was establish trust among the machines, making flapjack, the oldest, into the 'master' trusted by the others.  This I did by creating an SSH private key using ssh-keygen  on the master and putting the matching public key in .ssh/authorized_keys on the other machines. Then I decided to automate the discovery of what directories were on which machine.  This is made easier because of my personal trick for organizing files, namely to have a set of top level subdirectories named org/ , people/ , and pr...

Two Intel NUC servers running Ubuntu

Image
A week or two ago I took the plunge and ordered a pair of Intel NUC systems. Here's what happened next as I worked to build a pair of Ubuntu servers out of the hardware: I ordered the components for two Linux servers from Amazon: Intel NUC D54250WYK [$364.99 each] Crucial M500 240 GB mSATA [$119.99 each] Crucial 16GB Kit [$134.99 each] Cables Unlimited 6-Foot Mickey Mouse Power Cord [$5.99 each] for a total of $625.96 per machine. Because I have a structured wiring system in my apartment I didn't bother with the wifi card. ... Assembly was fast, taking ten or fifteen minutes to open the bottom cover, snap in the RAM and the SSD, and button the machine up again. Getting Ubuntu installed was rather more work (on an iMac): Download the Ubuntu image from the Ubuntu site. Prepare a bootable USB with the server image (used diskutil to learn that my USB stick was on /dev/disk4): hdiutil convert -format UDRW -o ubuntu-14.04-server-amd64.img ubuntu-14.04-server-amd64.iso diskutil un...

2014 Five Borough Bike Tour - I'm riding

The Five Borough Bike Tour is an annual event in which tens of thousands of New Yorkers ride 40 or 50 miles from lower Manhattan up through the Bronx, Queens, Brooklyn, and over the Verrazano Narrows Bridge to Staten Island.  For the last three years I've supported a wonderful organization called Bronxworks ( http://bronxworks.org/ ) that helps families in need in The Bronx.  I ride with a number of friends, some of whom live in the Bronx, and all of whom have adopted this wonderful group. I rode with the Bronxworks team in 2011 and 2012 but a conflict prevented me from riding in 2013, though I donated to support the rest of the team.  Fortunately for me I will be riding again this year.  If you want to contribute to Bronxworks in support of my ride you may visit my fundraising page  http://www.crowdrise.com/BronxWorks2014BikeTour/fundraiser/marcdonner .  If you do so, I will be eternally grateful!  

From the Editors: The Invisible Computers

[Originally published in the November/December 2011 issue (Volume 9 number 6) of IEEE Security & Privacy magazine.] Just over a decade ago, shortly before we launched IEEE Security & Privacy, MIT Press published Donald Norman 's book The Invisible Computer . At the time, conversations about the book focused on the opportunities exposed by his powerful analogies between computers and small electric motors as system components. Today, almost everything we use has one or more computers, and a surprising number have so many that they require internal networks. For instance, a new automobile has so many computers in it that it has at least two local area networks, separated by a firewall, to connect them, along with interconnects to external systems. There's probably even a computer in the key! Medical device makers have also embraced computers as components. Implantable defibrillators and pacemakers have computers and control APIs. If it's a computer, it must have so...