Why SysAdmin’s Can’t Code

May 12th, 2013

Most systems administrators are quick, perhaps too quick, to tell you “I’m not a coder.”  Oddly, this admission normally comes after boasting about how many programming languages they know or have used.  Why is this?  Can this be changed?  Here is my 5 step plan on how any SA can become an honest to goodness programmer.

Step 1: Find a problem you care about solving, for yourself

SysAdmin’s don’t actually use tools, they study them. The point isn’t to solve a problem but rather to know how to solve a problem if the need ever arises. SA’s are filling their tool chests full of handy hints and useful solutions for nearly any problem that can be encountered. Whats more, this is a subconscious tendency…. they want to use things, but because their true goal is simply learning and knowing the tool, when they wish to build something with this thing they’ve just learned, they blank out. Learning is the goal, goal achieved, next tool.

This causes any SA approaching programming languages to become masters of hello_world in a dozen languages. Again, the goal is to have a basic understanding of the language and then to move on.

The only way to break out of this rut is to find a problem you actually yourself have, and solving it. Don’t write a program for someone else, write it for yourself. Write something that integrates with your LDAP servers or pulls metrics and stores them in a database… whatever it is, make it practical, not an abstract academic exercise.

Step 2: Pick a language and stick with it

Because they are masters of adaptation and have so much hello_world foo, they are likely switch languages before making any real progress. If you want to write in C, then do that, but don’t switch to Ruby or Python because writing regex in C is a PITA…. push through and learn how to do regex in C.

SysAdmin’s also need to know what everyone else knows…. or more. This is a point of pride, master of all trades. Just because Go is on the rise, don’t think that PHP or Python is obsolete and useless. If you want to use Go, then fine, but stick with it. If you want to use Clojure, fine, but don’t just feel lame because suddenly people are talking about Node.js.

To facilitate this, write lots and lots of small programs that exercise different parts of the language and let you build a deeper knowledge of the core language. Save all those in a source control repository for later review and to help you build your confidence.

Step 3: Scripting isn’t programming

SysAdmin’s are tool masters… they know as many of them as possible. This is why scripting is a natural thing for us, it allows us to plug different tools together. But this isn’t really programming, its plumbing. This becomes more apparent when you start programming in a non-shell language. A sysadmin’s code tends to have a lot of execs… that is, essentially writing shell scripts in a non-shell language.

Step 4: Modules and libraries aren’t cheating

SysAdmin’s are purists and have a lot of ego. Using a module or library is akin to cheating. This is why many SysAdmin’s only know basic C, they don’t have the drive to implement their own protocol implementations, but view using a library as cheating…. so they are masters of pointers and little more. Many programmers look at modules and libraries like SA’s look at programs themselves, as building blocks to be plugged together to achieve a goal.

Don’t exec a tool, use a module or library, and don’t feel weird about doing it.

Step 5: Don’t think about other people

One of the biggest impediments to coding is embarrassment. That your code isn’t good enough or its formatted wrong or your not doing things in a certain “normal” way. This is the equivalent of going to the first day of school and being made to feel like an outcast for not having the right clothes or shoes… you like it and it works for you, but some how you’re wrong and just not cool enough to fit in. For anyone this is discouraging, but for a SysAdmin who’s pride is in being a master of all things its unbearable and causes them to throw in the “I’m not a coder” towel.

The solution is to just not give a shit. If your lines of code exceed 80 characters, so what. If you use curly braces instead of “end”, fine. Just don’t listen to those people. What matters is functional programs, not pretty syntax. If you truly pick a language and stick with it, at some point you’ll fall into common practice fairly naturally, but until then don’t allow yourself to give up just because you constantly feel like some imaginary critic is yelling at you while you code. This is why its important to, first and foremost, write for yourself to solve problems that you yourself have.

Hadoop Analysis of Apache Logs Using Flume-NG, Hive and Pig

December 27th, 2012

Big Data is the hotness, there is no doubt about it.  Every year its just gotten bigger and bigger and shows no sign of slowing.  There is a lot out there about big data, but despite the hype, there isn’t a lot of good technical content for those who want to get started.  The lack of technical how-to info is made worse by the fact that many Hadoop projects have moved their documentation around over time and Google searches commonly point to obsolete docs.  My intent here is to provide some solid guidance on how to actually get started with practical uses of Hadoop and to encourage others to do the same.

From an SA perspective, the most interesting Hadoop sub-projects have been those for log transport, namely Scribe, Chukwa, and Flume.  Lets examine each.

Log Transport Choices

Scribe was created at Facebook and got a lot of popularity early on due to adoption at high profile sites like Twitter, but development has apparently ceased  and word is that Facebook stopped using it themselves.  So Scribe is off my list.

Chukwa is a confusing beast, its said to be distributed with Hadoop’s core but its just an old version in the same sub-directory of the FTP site, the actual current version is found under the incubator sub-tree.  It is a very comprehensive solution, including a web interface for log analysis, but that functionality is based on HBase, which is fine if you want to use HBase but may be a bit more than you wish to chew off for simple Hive/Pig analysis.  Most importantly, the major Hadoop distributions from HortonWorks, MapR, and Cloudera use Flume instead.  So if your looking for a comprehensive toolset for log analysis, Chukwa is worth checking out, but if you simply need to efficiently get data into Hadoop for use by other Hadoop components, Flume is the clear choice.

That brings us to Flume, more specifically Flume-NG.  The first thing to know about Flume is that there were major changes to Flume pre and post 1.0, major enough that they took to refering to pre 1.0 as “Flume OG” (“Old generation” or “Origonal Gangsta” depending on your mood) and the new post 1.0 releases as “Flume NG”.  Whenever looking at documentation or help on the web about Flume be certain as to which you are looking at!  In particular, stay away from the Flume CWiki pages,  refer only to the flume.apache.org.  I say that because there is so much old cruft in the CWiki pages that you can be easily mislead and become frustrated, so just avoid it.

Now that we’ve thinned out the available options, what can we do with Flume?

Getting Started with Flume

Flume is a very sophisticated tool for transporting data.  We are going to focus on log data, however it can transport just about anything you throw at it.  For our purposes we’re going to use it to transport Apache log data from a web server back to our Hadoop cluster and store it in HDFS where we can then operate on it using other Hadoop tools.

Flume NG is a java application that, like other Hadoop tools, can be downloaded, unpacked, configured and run, without compiling or other forms of tinkering.  Download the latest “bin” tarball and untar it into /opt and rename or symlink to “/opt/flume” (it doesn’t matter where you put it, this is just my preference).  You will need to have Java already installed.

Before we can configure Flume its important to understand its architecture.  Flume runs as an agent.  The agent is sub-divided into 3 categories: sources, channels, and sinks.  Inside the Flume agent process there is a pub-sub flow between these 3 components.  A source accepts or retrieves data and sends it into a channel.  Data then queues in the channel.  A sink takes data from the channel and does something with it.  There can be multiple sources, multiple channels, and multiple sinks per agent.  The only important thing to remember is that a source can write to multiple channels, but a sink can draw from only one channel.

Lets take an example.  A “source” might tail a file.  New log lines are sent into a channel where they are queued up.  A “sink” then extracts the log lines from the channel and writes them into HDFS.

At first glance this might appear overly complicated, but the distinct advantage  here is that the channel de-couples input and output, which is important if you have performance slowdowns in the sinks.  It also allows the entire system to be plugin-based.  Any number of new sinks can be created to do something with data… for instance, Casandra sinks are available, there is an IRC sink for writing data into an IRC channel.  Flume is extremely flexible thanks to this architecture.

In the real world we want to collect data from a local file, send it across the network and then store it centrally.  In Flume we’d accomplish this by chaining agents together.  The “sink” of one agent sends to the “source” of another.  The standard method of sending data across the network with Flume is using Avro.  For our purposes here you don’t need to know anything about Avro except one of the things it can do is to move data over the network.  Here is what this ultimately looks like:

So on our web server, we create a /opt/flume/conf/flume.conf that looks like this:

## Flume NG Apache Log Collection
## Refer to https://cwiki.apache.org/confluence/display/FLUME/Getting+Started
##
# http://flume.apache.org/FlumeUserGuide.html#exec-source
agent.sources = apache
agent.sources.apache.type = exec
agent.sources.apache.command = gtail -F /var/log/httpd/access_log
agent.sources.apache.batchSize = 1
agent.sources.apache.channels = memoryChannel
agent.sources.apache.interceptors = itime ihost itype
# http://flume.apache.org/FlumeUserGuide.html#timestamp-interceptor
agent.sources.apache.interceptors.itime.type = timestamp
# http://flume.apache.org/FlumeUserGuide.html#host-interceptor
agent.sources.apache.interceptors.ihost.type = host
agent.sources.apache.interceptors.ihost.useIP = false
agent.sources.apache.interceptors.ihost.hostHeader = host
# http://flume.apache.org/FlumeUserGuide.html#static-interceptor
agent.sources.apache.interceptors.itype.type = static
agent.sources.apache.interceptors.itype.key = log_type
agent.sources.apache.interceptors.itype.value = apache_access_combined

# http://flume.apache.org/FlumeUserGuide.html#memory-channel
agent.channels = memoryChannel
agent.channels.memoryChannel.type = memory
agent.channels.memoryChannel.capacity = 100

## Send to Flume Collector on 1.2.3.4 (Hadoop Slave Node)
# http://flume.apache.org/FlumeUserGuide.html#avro-sink
agent.sinks = AvroSink
agent.sinks.AvroSink.type = avro
agent.sinks.AvroSink.channel = memoryChannel
agent.sinks.AvroSink.hostname = 1.2.3.4
agent.sinks.AvroSink.port = 4545

## Debugging Sink, Comment out AvroSink if you use this one
# http://flume.apache.org/FlumeUserGuide.html#file-roll-sink
#agent.sinks = localout
#agent.sinks.localout.type = file_roll
#agent.sinks.localout.sink.directory = /var/log/flume
#agent.sinks.localout.sink.rollInterval = 0
#agent.sinks.localout.channel = memoryChannel

This configuration looks overwhelming at first, but it breaks down simply into an “exec” source, a “memory” channel, and an “Avro” sink, with additional parameters specified for each. The syntax for each is in the following form:

agent_name.sources = source1 source2 ...
agent_name.sources.source1.type = exec
...

agent_name.channel = channel1 channel2 ...
agent_name.channel.channel1.type = memory
...

agent_name.sinks = sink1 sink2 ...
agent_name.sinks.sink1.type = avro
...

In my example the agent name was “agent”, but you can name it anything you want. You will specify the agent name when you start the agent, like this:

$ cd /opt/flume
$ bin/flume-ng agent -f conf/flume.conf -n agent

Now that our agent is running on the web server, we need to setup the other agent which will deposit logs lines into HDFS. This type of agent is commonly called a “collector”. Here is the config:

## Sources #########################################################
## Accept Avro data In from the Edge Agents
# http://flume.apache.org/FlumeUserGuide.html#avro-source
collector.sources = AvroIn
collector.sources.AvroIn.type = avro
collector.sources.AvroIn.bind = 0.0.0.0
collector.sources.AvroIn.port = 4545
collector.sources.AvroIn.channels = mc1 mc2

## Channels ########################################################
## Source writes to 2 channels, one for each sink (Fan Out)
collector.channels = mc1 mc2

# http://flume.apache.org/FlumeUserGuide.html#memory-channel
collector.channels.mc1.type = memory
collector.channels.mc1.capacity = 100

collector.channels.mc2.type = memory
collector.channels.mc2.capacity = 100

## Sinks ###########################################################
collector.sinks = LocalOut HadoopOut

## Write copy to Local Filesystem (Debugging)
# http://flume.apache.org/FlumeUserGuide.html#file-roll-sink
collector.sinks.LocalOut.type = file_roll
collector.sinks.LocalOut.sink.directory = /var/log/flume
collector.sinks.LocalOut.sink.rollInterval = 0
collector.sinks.LocalOut.channel = mc1

## Write to HDFS
# http://flume.apache.org/FlumeUserGuide.html#hdfs-sink
collector.sinks.HadoopOut.type = hdfs
collector.sinks.HadoopOut.channel = mc2
collector.sinks.HadoopOut.hdfs.path = /flume/events/%{log_type}/%{host}/%y-%m-%d
collector.sinks.HadoopOut.hdfs.fileType = DataStream
collector.sinks.HadoopOut.hdfs.writeFormat = Text
collector.sinks.HadoopOut.hdfs.rollSize = 0
collector.sinks.HadoopOut.hdfs.rollCount = 10000
collector.sinks.HadoopOut.hdfs.rollInterval = 600

This configuration is a little different because the source accepts Avro network events and then sends them into 2 memory channels (“fan out”) which feed 2 different sinks, one for HDFS and another for a local log file (for debugging). We start this agent like so:

# bin/flume-ng agent -f conf/flume.conf -n collector

Once both sides are up, you should see data moving. Use “hadoop fs -lsr /flume” to examine files there and if you included the file_roll sink, look in /var/log/flume.

# hadoop fs -lsr /flume/events
drwxr-xr-x   - root supergroup          0 2012-12-24 06:17 /flume/events/apache_access_combined
drwxr-xr-x   - root supergroup          0 2012-12-24 06:17 /flume/events/apache_access_combined/cuddletech.com
drwxr-xr-x   - root supergroup          0 2012-12-24 09:50 /flume/events/apache_access_combined/cuddletech.com/12-12-24
-rw-r--r--   3 root supergroup     224861 2012-12-24 06:17 /flume/events/apache_access_combined/cuddletech.com/12-12-24/FlumeData.1356329845948
-rw-r--r--   3 root supergroup      85437 2012-12-24 06:27 /flume/events/apache_access_combined/cuddletech.com/12-12-24/FlumeData.1356329845949
-rw-r--r--   3 root supergroup     195381 2012-12-24 06:37 /flume/events/apache_access_combined/cuddletech.com/12-12-24/FlumeData.1356329845950

Flume Tunables & Gotcha’s

There are a lot of tunables to play with and carefully consider in the example configs above. I included the documentation links for each component and I highly recommend you review it. Lets specifically look at some things that might cause you frustration while getting started.

First, interceptors. If you look at our HDFS sink path, you’ll see the path includes “log_type”, “host”, and a date. That data is associated with an event when the source grabs it, it is meta-data headers on each event. You associate that data with the event using an “interceptor”. So look back at the source where we ‘gtail’ our log file and you’ll see that we’re using interceptors to associate the log_type, “host”, and date with each event.

Secondly, by default Flume’s HDFS sink writes out SequenceFiles. This seems fine until you run Pig or Hive and get inconsistent or usual results back. Ensure that you specify the “fileType” as “DataStream” and the “writeFormat” as “Text”.

Lastly, there are 3 triggers that will cause Flume to “roll” the HDFS output file: size, count, and interval. When Flume writes data, if any one of the triggers is true it will roll to use a new file. By default the count is 30 (seconds), size is 1024 (bytes), and count is 10. Think about that, if any of those is true the file is rolled. So you end up with a LOT of HDFS files, which may or may not be what you want. Setting any value to 0 disables that type of rolling.

Analysis using Pig

Pig is a great tool for the Java challenged. Its quick, easy, and repeatable. The only real challenge is in accurately describing the data your asking it to chew on.

The PiggyBank library can provide you with a set of loaders which can save you from regex hell. The following is an example of using Pig on my Flume ingested Apache combined format logs using the PiggyBank “CombinedLogLoader”:

# cd /opt/pig
# ./bin/pig
2012-12-23 10:32:56,053 [main] INFO  org.apache.pig.Main - Apache Pig version 0.10.0-SNAPSHOT (r: unknown) compiled Dec 23 2012, 10:29:56
2012-12-23 10:32:56,054 [main] INFO  org.apache.pig.Main - Logging error messages to: /opt/pig-0.10.0/pig_1356258776048.log
2012-12-23 10:32:56,543 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://10.12.29.198/
2012-12-23 10:32:57,030 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to map-reduce job tracker at: 10.12.29.198:9101

grunt> REGISTER /opt/pig-0.10.0/contrib/piggybank/java/piggybank.jar;
grunt> raw = LOAD '/flume/events/apache_access_combined/cuddletech.com/12-12-24/''
    USING org.apache.pig.piggybank.storage.apachelog.CombinedLogLoader
    AS (remoteAddr, remoteLogname, user, time, method, uri, proto, status, bytes, referer, userAgent);
grunt> agents = FOREACH raw GENERATE userAgent;
grunt> agents_uniq = DISTINCT agents;
grunt> DUMP agents_uniq;
...

(-)
(Motorola)
(Mozilla/4.0)
(RSSaggressor)
(Java/1.6.0_24)
(restkit/4.1.2)
(Blogtrottr/2.0)
(Mozilla/5.0 ())
(Recorded Future)
...

While Pig is easy enough to install (unpack and run), you must build the Piggybank JAR, which means you’ll need a JDK and Ant. On a SmartMachine with Pig installed in /opt/pig, it’d look like this:

# pkgin in sun-jdk6-6.0.26 apache-ant
# cd /opt/pig/
# ant
....
# cd /opt/pig/contrib/piggybank/java
# ant
....
jar:
     [echo]  *** Creating pigudf.jar ***
      [jar] Building jar: /opt/pig-0.10.0/contrib/piggybank/java/piggybank.jar

BUILD SUCCESSFUL
Total time: 5 seconds

Analysis using Hive

Similar to Pig, the challenge with Hive is really just describing the schema around the data. Thankfully there is assistance out there for just this problem.

[root@hadoop02 /opt/hive]# bin/hive
Logging initialized using configuration in jar:file:/opt/hive-0.9.0-bin/lib/hive-common-0.9.0.jar!/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201212241029_318322444.txt
hive>
hive> CREATE EXTERNAL TABLE access(
    >   host STRING,
    >   identity STRING,
    >   user STRING,
    >   time STRING,
    >   request STRING,
    >   status STRING,
    >   size STRING,
    >   referer STRING,
    >   agent STRING)
    > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
    > WITH SERDEPROPERTIES (
    >   "input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\]) ([^ \"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\"[^\"]*\") ([^ \"]*|\"[^\"]*\"))?",
    >   "output.format.string" = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s"
    > )
    > STORED AS TEXTFILE
    > LOCATION '/flume/events/apache_access_combined/cuddletech.com/12-12-24/';
OK
Time taken: 7.514 seconds
hive>

Now you can query to your hearts content. Please note that in the above example if you omit the “EXTERNAL” keyword when creating the table that Hive will move your data into its own data warehouse directory, which may not be what you want.

Next Steps

Hadoop provides an extremely powerful set of tools to solve very big problems. Pig and Hive are easy to use and very powerful. Flume-NG is an excellent tool for reliably moving data and extremely extensible. There is a lot I’m not getting into here, like using file-backed or database backed channels in Flume to protect against node failure thus increasing delivery reliability, or using multi-tiered aggregation by using intermediate Flume agents (meaning, Avro Source to Avro Sink)… there is a lot of fun things to explore here. My hope is that I’ve provided you with an additional source of data to help you on your way.

If you start getting serious with Hadoop, I highly recommend you buy the following O’Reilly books for Hadoop, which are very good and will save you a lot of time wasted in trial-and-error:

A Friendly Warning

In closing, I feel it necessarily to point out the obvious. For most people there is no reason to do any of this. Hadoop is a Peterbilt for data. You don’t use a Peterbilt for a job that can be done with a Ford truck, its not worth the time, money and effort.

When I’ve asked myself “How big must data be for it to be big data?” I’ve come up with the following rule: If a “grep” of a file takes more than 5 minutes, its big. If the file can not be reasonably sub-divided to be smaller files or any query requires examining multiple files, then it might be Hadoop time.

For most logging applications, I strongly recommend either Splunk (if you can afford it) or using Rsyslog/Logstash and ElasticSearch, they are far more suited to the task with less hassle, less complexity and much more functionality.

Heavy Metal: A Brief Guide to the Djent Revolution

December 26th, 2012

2012 has been a great year for metal fans, and in particular, for the more mature metal fan.  Maybe you’ve noticed, the headbanging demographic has slowly been changing, as seen best by “That Metal Show”:

There are lots of great metal bands, but a lot of our old favorites fail to really evolve and after decades of rockin’ to Slayer, Megadeth, Pantera, etc, you just need something new, something more evolved, and complex. A critical element of metal is that its stimulating, not just aggressive, and some of the old stand by bands are just too familiar.

Three bands really forged a new era in the evolution of death metal (if you are unfamiliar with the topology of the various metal sub-genres you’ll really enjoy exploring the progression with the Map of Metal), those bands are:

  • Meshuggah
  • Periphery
  • Animals as Leaders

From these bands came an explosive new sub-genre which became known as “Djent”.  Some attributes that define Djenty metal are:

  • Extensive use of palm muting.  This makes typical metal triplets sound very crisp.
  • Unusual timings and song progressions.  This was previously seen in many math-metal bands, and these songs do not follow the horrifically boring old intro-verse-chorus-verse-solo-chorus-chorus-end model.  The unusual timings means that there are lots of rhythmic changes and sudden “left turns” that transform the song quickly, as opposed to the old way of having a single primary riff that you simply play around with for 4-5 minutes. This is similar to Jazz. If you don’t understand what I mean, listen to “Buttersnips” below and see how many times the song changes course in just the first 30-60 seconds.
  • Virtuoso Guitar Playing.  The guitar work in djent is very complex, very layered, and commonly utilizes 8 and 12 string guitars, providing for chord progressions that are incredibly deep and rich.

So lets look at two examples.

First, Animals as Leaders. This band is 100% instrumental. They have draw many jazz guitar fans because they share so many elements of jazz guitar. If you enjoy both hard rock/heavy metal and jazz musicians like Pat Metheny, they are for you:

Second is Periphery. Proof that more guitars means better music. This track, “Buttersnips”, got some air-play and drew a number of people into the genre:

Meshuggah is actually credited with coining the term Djent, but their music is much more bass dominated than other bands that are being looped into the genre and while there are Meshuggah songs I really like, on the whole I’m not a fan. Most “djenty” songs are almost like 4-5 songs in one, because of the twists and turns they take, whereas Mushuggah is much more traditional and linear (on the whole).

Like DevOps, whats important about the word “Djent”, more than its specific meaning, is that it provides a rallying point to explore and find other music and fans. Some other bands that I really enjoy (“djenty ness” may be debated, but I loop them all in):

  • Chimp Spanner: Instrumental, highly recommended for Animals as Leaders fans.
  • Tesseract: I’m less interested in them personally, but they are a pillar of Djent
  • Structures
  • Born of Osiris: Loosely coupled into Djent, but elements are there
  • Textures: Recommended for fans of Kings X
  • Volumes
  • Circles
  • Aliases
  • Benea Reach
  • Extol: An old band that I fell in love with many years ago, but for the same reasons I enjoy the new Djent bands, I own the entire Extol catalog. Check this out to see what I mean, like Djent it keeps morphing, changing, and uses unusual timing to keep it interesting.

Notice a trend in the names? I recommend getting on iTunes, sampling some of the bands above and then exploring what others bought to find new and interesting bands.

Not down with the djenty groove? Other bands that are worth your while, outside the boundaries of Djent, that you should check out if you’ve been away from metal for a while, including:

  • Baroness: I liked the “Blue” and “Red” albums, the new “Yellow & Green” album didn’t do it for me.
  • Chimaira: “The Age of Hell” was an amazing album
  • Gojira: This years “L’enfant suvage” album was amazing
  • Mastodon: Always good and getting better, I love that they have 2 singers which really adds depth. “The Hunter” was a great release, and the fact that they write albums to be listened to all the way by having continuous themes makes them great. “Crack the Skye” was great, “Blood Mountain” was great, but I think “Leviathan” remains my personal favorite

Finally… lets never forgot that “Motorhead” is still rocking hard and hasn’t gotten old yet. “WE ARE MOTORHEAD AND WE PLAY ROCK ‘N ROLL!” Always, Lemmy, always.

iPXE: Now with Native Menus and SmartOS Support

October 8th, 2012

If you’ve never heard of iPXE, it is the official fork of gPXE, which was the ultimate result of the Etherboot Project of old.  Apparently there was a power struggle that caused the primary contributors to leave Etherboot/gPXE and they renamed gPXE to iPXE to distinguish.  Technically gPXE still exists, but for all intents and purposes its a dead project.

If you are completely unfamiliar with both iPXE and gPXE let me summarize.  The industry standard way to network boot is via PXE.  A PXE client is burned into the ROM of your NIC, but because it has to fit in a tight space it is very dumb.  iPXE is an open source PXE client that is modern and very intelligent.  It can execute scripts, it can inspect the system interfaces and SMBIOS, it can download images and scripts via HTTP, FTP, NFS, and more, it has SAN support for booting off of AoE, FCoE, and iSCSI, etc.  It can be used in several ways, including burned into your NIC’s ROM as a replacement (uncommon), booted from USB/ISO/etc media, or most typically it is itself PXE booted such that your dumb PXE client in your NIC boots to iPXE and it then does all the heavy lifting.  If you are doing any type of network booting you should know what iPXE is and if you ever want to do anything fancy, iPXE is the way to do it.  One example many of us like to use is creating an iPXE script which calls out to a web app (PHP commonly) which looks up information from SMBIOS (such as serial number, service tag, MAC address, etc.) and interfaces with a database to make decisions on which image to boot.  You can do lots of fun things.  Most of your next-gen bare metal provisioning tools, such as Razor, rely on iPXE.

There are two really exciting things for me, just added in the last couple months.  The first and most basic is that SmartOS boots natively from iPXE.  In the past, primarily with OpenSolaris, you had to chainload PXEGRUB to boot Solaris, but it looks like some patches were accepted and now you can dump GRUB completely.

The other existing development is the addition of native menus in iPXE.  Historically, if you wanted to create a versatile netboot server you would use iPXE/gPXE to  chainload SYSLINUX’s menu.c32 program which would render your boot selection menu and boot your selected OS.  But no more!  iPXE can do it all on its own now thanks to the addition of 3 commands to iPXE: menu, item, and choose.  With these new commands and liberal use of “goto” labels you can create some extremely complex and powerful setups with no other helper programs in the way.

Lets take a look at a simple menu:

#!gpxe

######## MAIN MENU ###################
:start
menu Welcome to iPXE's Boot Menu
item
item smartos    Boot SmartOS
item
item shell      Enter iPXE shell
item reboot     Reboot
item
item exit       Exit (boot local disk)
choose --default smartos --timeout 60000 target && goto ${target}

## Utility menu items:
:shell
echo Type exit to get the back to the menu
shell
set menu-timeout 0
goto start

:failed
echo Booting failed, dropping to shell
goto shell

:reboot
reboot

:exit
exit

########## MENU ITEMS #######################
:sdc
kernel /sdc/20121001T165806Z/platform/i86pc/kernel/amd64/unix -B hostname=r720test,standalone=true
initrd /sdc/20121001T165806Z/platform/i86pc/amd64/boot_archive
boot

:smartos
kernel /smartos/20121004T212912Z/platform/i86pc/kernel/amd64/unix
initrd /smartos/20121004T212912Z/platform/i86pc/amd64/boot_archive
boot

You can see here that the “menu” command declares a menu with a title. The elements are items with a label and description (you can assign hot keys as well) and an item with no value is an empty line, and you can use the “–gap –” argument to create section headers, in the form “item –gap — —–SmartOS——-”. Finally, the choose command puts your selection into a named variable and also allows you to specify a default selection and timeout specified in milliseconds. Just about everything else is handled by the “goto” command and labels sprinkled throughout the script. Most importantly, we use the value obtained by the choose command to “goto” the label with the commands to boot the given OS. You can also have multiple menus, one which goes to the other and back, by being creative.

When you couple all this together, you get an iPXE that is more powerful than ever before and extremely exciting.

I’ve taken this opportunity to update the SmartOS Documentation for PXE booting,  using iPXE directly as above is now the officially recommended way to netboot.

Writing a Better SOP

September 25th, 2012

Within an ops team you should have 3 primary types of governance enablers: controls, policies and processes. A control is a guiding principle, which is implemented as a one or more policies (which are just rules), which are in turn standardized in a set of procedures. Its important to have all 3, because controls are very vague, policies are often general and broad in nature, which means to provide consistent quality results we require prescriptive procedures. At Joyent we call these “Standard Operating Procedures” (SOP).

The whole point of an SOP is to produce consistent results regardless of who’s using it. That means that all SOP’s need to be in a similar, familiar, and easy to follow format that is suitable to anyone who may need to use it. That, therefore, means that to get those consistent results there can be no room for ambiguity, it must be explicit and convey any necessary context along with it. Ambiguity is the mortal enemy of consistency. Case in point, if you’ve ever been asked to recompile software with a large number of configure flags, if your unable to determine which flags were used in the past you’ll go cold with anxiety over whether or not your building it properly. When you go back and ask who it was built in the past someone might say “Don’t you know how to compile software?” and the answer is likely going to be “Yes I do, but I don’t know how YOU compile software.” Whats important is that the person implementing a procedure be given all the information and context necessary to understand, and if necessary, interpret the information as appropriate for the given situation.

The first key to better SOP’s is to provide a template for others to follow. Without a standard template each author will write the procedure in their own unique style. Some people will write you a book, others will just paste some lines from their terminal into a code block. The template therefore must enforce a certain flow that ensures we include all the needed information but in a concise and complete way. Plus, we want SOP creators to focus entirely on writing the content, not debating the format.

Here is the template I use for Joyent Operations SOPs (in Confluence markup):

* Author:  {page-info:created-user}  created at: {page-info:created-date}
* Version: 1
* Revisions: {page-info:current-version}
* Reviewed by: (User @ date)
* Time to implement: 1hr
* Products this applies to: (SKU1)

{toc}

h1. Description & Scope

h1. Prerequisites

* Root access to node
* [SOP-222: Something|SOP-222: Something]
* [SOP-224: Something else|SOP-224: Something else]

h1. Procedure

h3. Step 1: Do this

{noformat}
Example
{noformat}

h3. Step 2: Do that

h3. ...

h1. Procedure Validation

# Login and verify external connectivity (ping google.com)
# curl zone IP address, page returns
# etc.

h1. Notes/Jira Examples

* [http://confluence.atlassian.com/display/DOC/JIRA+Issues+Macro]
* [http://confluence.atlassian.com/display/DOC/JIRA+Portlet+Macro]
* [https://studio.plugins.atlassian.com/browse/CONFJIRA-154]

Lets step through the above template.

All SOPs must be numbered for easy reference. Even the template itself is SOP-000. The SOP title is in the form: “SOP-102 Creating LDAP Users”, for instance.

The top of the SOP is full of metadata. The author, creation date, major version number and number of revisions made and products (or projects or whatever) that this SOP applies to. You’ll notice 2 other fields: “Reviewed By” and “Time to implement”. These are perhaps the most important of all. After an SOP is created it must be reviewed by someone else in the group, preferably with as little knowledge of the subject as possible. They should read and follow the SOP as written, starting a timer when the begin and stopping the timer when they are complete… it is that stopwatch time which becomes the “time to implement”. This is extremely important, the time estimate for implementation by the author will be way too short because they know what they are doing, the time it takes a complete n00b will be more useful and truthful.

Moving on through the template, “Description and Scope” are where we provide context. What are we talking about, what does it entail at a high level, what does this impact, etc. We want to include as much information as possible to set the stage for the procedure that follows. Then we include a bulleted list of “Prerequisites”. The single most common part of any procedure that gets skimped on is the prerequisites and they are also generally the most time consuming.

The meat of the SOP is the procedure itself. I strongly believe these must be in a “Step 1… Step 2… Step 3″ format; it must be easy and intuitive to follow and in some cases may be used as a checklist during sensitive procedures. Its important that these truly start at the beginning and go to the end. “Step 1: Login to server X” may be overly simplistic but necessary for clarity if multiple machines are involved. I also like to have the final step be “Done” to make it clear that you have reached the end.

Just as important as the procedure is the “Validation Steps”… to ensure a quality job we must not only preform the proceedure but validate it in one or more ways to ensure it was really done right. This has the added side effect of giving the person doing the work the satisfaction that it was done properly and they didn’t screw something up along the way.

Lastly is a place to include external links as appropriate. If possible I like to link in tickets (we use Jira) which have relied on the SOP before, so that if by chance there is some confusion they can find examples of the work being done in the past.

An optional section that I’ve used before is a “Rationale”. In this section you would include notes on why you chose to implement the procedure in the way that you did. This allows for continuous improvement of the SOP. In most cases there are many ways to solve a problem, conveying why you chose the method you did will help you hone the procedure in the future while learning from the past. Without it your likely to have regression or duplication crop up.

This is the model that we’ve used at Joyent for several years and it has stood the test of time. I believe it to be a very solid standard for writing SOP’s and sharing knowledge within the organization and avoiding any one single person becoming a constraint. If you have refinements or a better method, I’d love to learn about it.

Configuration Management on SmartOS

September 21st, 2012

Over the last couple days I added a bunch of SmartOS documentation on getting the major configuration management solutions working. Pointers for CFengine3 and Puppet are there with the basics on getting started. I added extensive documentation for Chef, suitable for even users entirely new to Chef. I’ve also populated a Github repo with cookbooks, Knife bootstraps, and a full framework for using Chef Solo with SmartOS.

Go find all the docs in the SmartOS Wiki: Configuration Management on SmartOS

A Return to Linux on the Workstation

September 20th, 2012

In my day to day work I rely on two systems, a MacBook Pro and a custom built PC workstation. My Mac is used for all my travel needs and communications (email, Jabber, Skype, etc). All my “real work” is done on the workstation which I refresh to the latest and greatest every 3-4 years, run dual headed, etc. Up until about 30 days ago my primary workstation ran some variety of Solaris for nearly 10 years, starting with Solaris 9 when X86 became viable on X86, then OpenSolaris and the various Solaris Express releases and finally Solaris 11 Beta. It was one month ago today that I finally re-installed it with Ubuntu, returning me to Linux officially. Times are a’ changin’… so I thought I’d share the tale of my long experience and the events that brought me back to Linux on the desktop.

As I stated in a recent talk, and then was humored to see quoted on Twitter a couple times since, I never really intended to run a “Solaris Desktop”. I didn’t want a desktop, rather I wanted a server on my desk. Building a desktop operating system is really hard, it involves supporting all manner of new and strange hardware. Its hard enough on desktop PCs but its absolutely redicuous when you consider all the variations of laptops. On my workstation I always installed a standard Intel e1000g dual port NIC, a Sound Blaster 16 or 128, and a well supported NVidia graphics card. So long as I could start an X server on dual displays and start Enlightenment, my window manager of choice, I was happy. The only apps I rely on are a browser and several dozen Eterms… little else. What was important to me was that I had a platform on my desk with which to experiment and prototype on Solaris for later implementation in the data center.

With the addition of ZFS, Solaris became an extremely powerful testing platform. Several large disks in my workstation formed a Zpool on which everything but the base OS was installed. The OS root itself was on a small 16GB SSD (it was bad ass once upon a time). This allowed me to frequently do fresh installs of new releases of Solaris and OpenSolaris. After install, I just imported the Zpool which put my home dir, /usr/local, /opt, etc back into place and I was running again.

What has always bugged me about Solaris is that the software packaging solutions have always been aweful. For a long time we were limited to whatever shipped with Solaris or was available from Blastwave. But Blastwave was little comfort because so frequently a single package install would have an absurd dependency on some very foundational package therefore forcing an upgrade of everything, like it or not, which invariably would break something. In my former Linux days I was fond of Linux from Scratch and latter became a fan of Gentoo, therefore my solution for Solaris was to hand build all my fundamental applications myself and then simply drag those binaries from release to release for a very long period of time. While I appreciated having the latest and greatest Solaris on my desk, I certainly missed the ease of simply installing an RPM and being done. The idea of trying the latest KDE was a seemingly insurmountable challenge and waste of time.

About 30 days ago two factors caused me to finally throw in the towel on Solaris as a workstation OS.

The first was that I finally joined the club of folks who have spilled liquid on their MacBooks. After 3 years of faithful service my Mac was dead. This happened on a Saturday and I suddenly realized that on Monday I’d be unable to join our corporate Jabber channels and I wouldn’t have Skype access. Suddenly I became aware of how much I was relying on my MacBook for daily communication and that I was essentially going to be cut off. Getting all these types of services working on my Solaris workstation was possible, but hardly seemed worth the effort and I only had a day to get back to full capability to be ready for Monday morning.

The second was that Solaris is dead. Illumos is the future of the platform and the desktop options there are very weak. All my work these days is on SmartOS, which is dedicated hypervisor platform, so there was no way I was going to whip it into a workstation platform in short order, not to mention that it’d be a fruitless exercise even if accomplished. It was clear that having a server on my desk that also possessed the basics required for a passable X environment was at an end. Besides that, thanks to KVM support in SmartOS it was becoming increasingly clear that I was completely out of touch with the Linux world which I was now supporting more frequently as a guest OS. And, last but not least, Linux now has ZFS support, so I could theoretically install Linux, get ZFS supported added, and then import all my important filesystems. It was time to return to a Linux workstation.

I’m getting older and lazier, so going back to the Gentoo lifestyle wasn’t interesting to me. Ubuntu continues to be all the rage, so I decided Ubuntu 12.04 was the way to go. And, I turned out to be right… within 4 hours of the MacBook toasting I had installed Ubuntu 12.04, gotten my displays working properly, installed all the software I needed, including Skype and Enlightenment, added ZFS support and mounted my home directory and was looking at my desktop environment as though nothing had happened. It was a wonderful experience.

Getting ZFS Support working with Ubuntu is very simple. Simply install the ZFS for Linux PPA packages and reboot. The only mistake I made was that I initially had installed Ubuntu 32bit, thanks to my outdated Linux knowledge of compatibility issues running a 64bit kernel. On the 32bit kernel ZFS took almost an hour to locate and import the pool… after I reinstalled Ubuntu 12.04 64bit and adding in the ZFS packages again, my Zpool imported just fine. One thing that helped me here was that my pools are very old; in order to provide maximum flexibility in which OpenSolaris release I used, I never allowed my pools to be upgraded, therefore allowing me to run older OS releases if needed, therefore ZFS for Linux had no problems importing my old version pools.

After using ZFS on Linux for some time now I can say that it works very well but the performance is less than stellar. The performance is good enough that I NFS export all my old file systems for use, but bad enough that I created a fresh home directory on ext4.

I did play with Unity a bit before switching back to Enlightenment DR16 (the best window manager ever created). Unity is a really excellent desktop and a first rate contender against Windows 7/8 and even OS X… but ultimately I still prefer the speed and minimalism of an old school window manager. The only thing that actually bugged me about Unity was the way they tried to be very clever about window titles… they sort of blur out from left to right. While I realize its a nifty visual device, to me it looked like a theming mistake and I disliked windows with the title “Firef…”.

One thing that did surprise me about my return to Linux was how little the desktop applications had changed. Finding that Pidgin was still the IM client of choice threw me for a loop. I experimented with Empathy but had horrific stability issues, which is a shame because its a much nicer client than Pidgin. Ultimately I found a theme mix that worked for me and settled on Pidgin was but was sad there weren’t more viable options (yes, there are alternatives, but they sucked more than Pidgin). Getting Skype running easily was a pleasant surprise, no pain not problems and people I called told me it was the best I’d ever sounded on Skype. The other various apps were less exciting than I had hoped, I was sad that Eye of Gnome hadn’t died a long time ago. I think the two high points were realizing that I could use the Arduino IDE on my workstation and looking at Shotwell. Shotwell is an amazing application, but its not enough to convince me to move all my photos out of iPhoto.

In the end, 3 days later I had been issued a replacement MacBook Pro which I got just as Mountain Lion released. Thankfully installing Mountain Lion and then recovering from my TimeMachine backup went well and I was back to my normal workflows. While I’m sad that, at least for me, the era of Solaris as a viable workstation had come to an end, I am glad at all the new life Illumos distros have as first class server OS’s. I may not have the server on my desk any more but the era of the all-things-to-all-people OS is, imho, done.

DevOps LA on Aug 27th

August 18th, 2012

I’ve been invited to speak at  DevOps LA on Monday, Aug 27th.  The title I’ve chosen is “The DevOps Transformation” but it will not be the talk I gave at LISA. Partly because I’ve already given that talk, and partly because I only have a 20-30 minute speaking slot.  I’ll be looking beyond those fundamental principles and considering some new material, including work flow, routing, and conversion with the LEAN world at large.  I will not discuss ITSM at length again. :)

I’ve also decided this is an amazing opportunity for me as an OpsDad… given that its a 24 hour trip for me (OAK to LAX is 1.5hrs flight time) I’ll be bringing my two eldest children (Nova 8yrs & Glenn 7yrs) along.  As professionals its not often we can bring our children with us on a “business trip”, so I’m looking forward to giving them a really kool adventure.  I strongly encourage all OpsDad’s included their kids whenever you have the ability to do so.

UPDATE: The event went great, thanks to everyone who attended.  For those wanting the slides, here is the deck: DevOps Demystified

BayLISA Comes to Joyent: A Night of SmartOS

August 13th, 2012

This Thursday night, Aug 16th at 7:30PM in Joyent’s HQ (9th Floor, Embarcadero One) Joyent will be hosting BayLISA for an evening of SmartOS.  I’ll be filling in for Ryan Nelson, talking for 20 mins about the practical issues of SmartOS deployment.  This is an excellent opportunity for any Solaris or SmartOS fans in the Bay Area to come an meet some amazing engineers and learn more about the future of the platform.

Register here. (If I know Joyent, beer will be provided!)  Come over and say hello!

UPDATE:  You can view the whole event on Ustream! My talk starts at 40m in. You can also download the slides.



Video streaming by Ustream

Back to Blogging

July 18th, 2012

My blog has certainly suffered a slow down in the last 2 years… I thought I’d provide a little insight as to why, give you a little insight into where I’m at these days, and ask for your suggestions on the future.

Once upon a time, my blog was a predominately Solaris blog.  In fact it became over time the most read Solaris blog.  Thanks to Google it actually still is, because I have verify few active readers, the vast majority come to the blog via some Google search for this problem or that and find what they are looking for.  As a result, many people don’t even realize I stopped blogging about Solaris some time ago, which I find a bit funny.  At Velocity this year several people came up to me and thanked me for the blog, whom I then would ask “Does it bother you that I’m talking about DevOps now instead of Solaris?”  Each of them gave me a blank look and said “You stopped blogging about Solaris?” :)

I stopped writing about Solaris for several reasons.  The first was that I’d covered so much ground that I would start to write about something and realize I’d already done so a year before.  Another was that some of the things I wanted to write about where simply too large or complex for a blog, but not quite enough for a book.  Yet another is that sometimes, as a writer, you can start to take yourself too seriously and give too much thought to critics and thus feel that many things you want to write about are “too basic” or “too dumb” to write about.

Another big reason was of course Oracle taking over Sun and there being a very unclear future for the community at large.  The Illumos project brought OpenSolaris back to life, but given that so many people in the Solaris community are from the enterprise space (directly or indirectly) it was unclear whether Illumos would truly provide an alternative to Oracle Solaris.  And besides that, I had become far too involved in Sun and OpenSolaris internal politics and governance and other non technical crap which I feared becoming involved with again under Illumos… thankfully the Illumos community actively stamped out any of the old politics before it took root again, but I was happy to provide a wide birth while it sorted out.

Yet another reason was that for a long long time I’ve wanted to change formats.  For at least 6 years now I’ve wanted to move from “blogging” to producing screen casts.  For many topics there is only so much you can digest from a written entry, at some point its easier to just show you.  I’ve started down that road many times but never gotten it off the ground.  Maybe one day it will.

However the largest reason was that about the time OpenSolaris imploded I was pretty well burned out on the whole thing anyway.  Using Solaris was far less a challenge than managing and operating a large environment.  I became obsessed with the question “How do you run a cloud?”  That’s the question that drove me into learning all sorts of strange things.  I blogged about some of them in the last 2 years, but held back quite a bit because it was unusual fare for my Solaris audience.  I could write about Deming and Ackoff and Ford and Ohno all day long… but who would want to read it?  Lucky for me, DevOps came along about the same time and a community of like minded individuals formed around these same ideas.   I’ve been thankful for that community and how its brought so many of us together who were each on our own individual journeys.

And so, there are my excuses for being a bad blogger… not that I actually consider myself a blogger in the first place.  I just like to help people and this is the best vehicle to do so.

Now for how you can help.  What would you like me write about?  Should I go back to writing about Solaris features?  Should I write about all the new Solaris variants (SmartOS, OmniOS, etc)?  Should I write more DevOps nuggets?  Are there “old” topics that still should be discussed that no one is talking about anymore?  At the end of the day, I still fundamentally believe in SA’s helping SA’s.  How can this SA help you?  Its time for me to get back in the game.