Starting Out Small

ethernet cablesThere is an issue I have at work, something I’ve written about before in my logs that I’ve found a solution for that I feel I can blog about. I can’t really talk about the why behind all of this, but I can share a technical explanation of how I am addressing this problem. It’s a half-thing, bear with me.

At Western, I’m very interested in the number of open TCP connections that a workstation has open at any one time. I don’t care what state the connection is in, ACK_WAIT to any of the others, if there is a line, I want to know about it. Specifically I want to know how many lines there are. Mac OSX is based on Darwin, and Darwin is based on BSD – so you get a shell to work with when you start Terminal.app. There is a lot of power in the command line interface and once you get the hang of it, it’s really quite useful.

So remote stations, at least two of them I have turned on “Remote Login” in their Sharing applet in System Preferences which enables the machines SSH servers to answer incoming connections. I can use SSH to call up a command line window to those remote stations, feeding them commands. I have done this for a long while for our servers in the office but this is the first time I’ve seriously done this for workstations. So, with this connection established I want to collect the number of TCP connections that machine has established. On the command line there are lots of pieces to get this to work:

First, you need a loop structure so that the command happens regularly: 

while true; do [command]; sleep 60; done

This will run a command every 60 seconds and it will never end unless I send a Control-C character which represents “Break” to the shell.

At first I just needed to count how many connections. You get this number, or at least an approximation of it this way:

netstat -p tcp|wc -l

That calls netstat to list out all the TCP connections, which then I pipe, using the pipe character ‘|’ to another command called wc, which calculates word-counts. I make wc ignore words and just count lines by using the -l switch. I don’t really care what other stations my targets are communicating with, just a count of how many. And yes, technically the SSH connection inflates this by at least one connection, it’s not intended to be forensic.

But something was missing. I need a date stamp. In BSD, there is a command called date, and you can give it a format so you can make date write out the Hours, Minutes, and Seconds the way you want to see them, but date has an annoyance to it. The command date always inserts a ‘newline’ character at the end, so what you’d get is a date, a new line, and your count. It’s okay, but it’s annoying. It would be far better to get rid of that newline character altogether. Enter in the ‘tr’ command, which translates characters. In this case, we tell tr to just delete the newline character, so ask date for the right sort of date, have tr nail off that newline at the end because it’s annoying and…

while true; do date '+%H:%M:%S '|tr -d '\n'; netstat -p tcp|wc -l; sleep 60; done

This outputs a very nicely formatted report on a remote workstation. So now I have datestamps, connection count levels, and when the count gets to a certain number and things happen, I can be faux-psychic.

UPDATE: Apparently I just can’t leave well enough alone. Seeing a slow parade of numbers trot by is rather dull when all I really want to know is when these numbers say, get over 70. So…

while true; do test "$(netstat -p tcp|wc -l)" -gt 70 && (date '+%H:%M:%S '|tr -d '\n'; netstat -p tcp|wc -l;); sleep 60; done

 

photo by: Bull3t

Encrypted Time Machine Drive Botch in Mac OSX 10.8.2 Mountain Lion

We had a Firewire 800 drive botch when it came to whole-volume encryption in Mac OSX 10.8.2 Mountain Lion. We lost the password and couldn’t recover it. The drive refused to erase, all the options were grayed out. I refuse to believe that a software change can render hardware junk, so there had to be a way, and I found it. Here’s the procedure:

  • Attach botched drive to computer, since the password won’t work, cancel the unlock dialog box
  • Open Terminal
  • Enter command: diskutil CoreStorage list
  • You will get a long list, you are looking for the UUID of the “Logical Volume Group” at the very top of the list, for the drive that is affected.
  • Enter command: diskutil CoreStorage delete [UUID]
  • The system will eject the volumes, destroy the grouping, erase the disk, then initialize the disk, mount it and finish.
  • Done!

For the want of pgrep on Mac OSX

I’ve got an issue at work, of course. I’ve got a Mac OSX xServer that has grown crotchety and so I’ve gotten to making things better by using killall on various running processes in order to “clean up the mess”. This is all fine and good and these processes respawn and the world goes back to normal and everything is fine, however I also want to renice this pesky command and give it a lower priority. While killall can do a search by name, renice requires a pid. The way you get pids is to run the ‘ps’ command, but this gives you a big pile of data and really all you want is just the pid itself, so you can pass that to renice.

So here’s how to get your cake and eat it too on Mac OSX Leopard Server:

1) First, change your shell – the default for root is /bin/sh, do this by issuing this command:

chsh -s /bin/bash root

2) Then you’ll need to give bash a profile, create a new file call it .bash_profile and fill it with this text:

[[ -s ~/.bashrc ]] && source ~/.bashrc

3) Next you’ll need to fill out that .bashrc because that contains the function you need to replicate pgrep:

pgrep() for arg; do ps aux|grep $1|grep -v grep|awk '{print $2}';done;

4) Log out and log back in and you’ll end up in bash, not sh, and you’ll have a new command at your disposal, pgrep. You can then use pgrep CommandName and it’ll spit out the pid related to what you are after.

5) Then you can use this new function with renice this way:

renice 20 `pgrep CommandName`

One thing to note here is that the ` character is the backtick character. You’ll find this hiding out in the upper left corner of your keyboard, it’s the unshifted tilde button.

Importing Plain Text into Mountain Lion Reminders App

I have created a new project to enrich the tags in my WordPress blog using the WP Calais Auto Tagger that I mentioned in this previous blog post. To do this I am working on pages of old posts in my WordPress dashboard and so I wanted to track just which pages I had completed and which ones still need my attention. I’ve got 48 pages of blog posts and so this is going to take some time to complete.

The first step was to create a list of text lines going from Page 48 to Page 1 like a countdown. I did that in OpenOffice using the Spreadsheet app. All you need to do here is type in two lines where the number series example can be made and then you can select these two cells and then grab the autonumbering control on the spreadsheet and draw it down, this is a great way to quickly create very repetitive lines where the only thing that changes is a number at the end. With this list, I copied it into a plain text file with each line on it’s own and saved it as “tagging.txt” on my desktop.

The next step is to use AppleScript to tell the Mountain Lion Reminders app to create entires automatically based on the file you just made in OpenOffice. Technically the Reminders app has an import mechanism but that’s only meant for ICS files, and that’s more trouble than it’s worth as far as I care to pursue it as a solution. Here’s the AppleScript:

 

set theFileContents to read file "Users:andy:Desktop:tagging.txt"
set theLines to paragraphs of theFileContents

repeat with eachLine in theLines
tell application "Reminders"
tell list "Tagging Project"
make new reminder with properties {name:eachLine}
end tell
end tell
end repeat

The only part you’d have to fix is the file location part and the list name part. Otherwise it works well. The only gotcha is it doesn’t seem to import the tasks in order, but at least they are in there.

Here are some helpful sites where I got a lot of this code and hints on how to talk to Reminders instead of iCal:

Benguild.com Page

MacScripter Page

PAD 2/9/2013 – Childhood Revisited

Sure, you turned out pretty good, but is there anything you wish had been different about your childhood? If you have kids, is there anything you wish were different for them?

Every time I think about this kind of question it brings up the tangled web of the consequences of living. Would you do anything over again? How could anyone answer this question honestly? Could you be anything other than what you are? I think, at least for me, the answer is no. Looking back on everything that I experienced, the good things, and the bad things, that all the things were needful. I love who I am and I don’t need someone outside of myself to remind me of that fact. I get a lot of flak for being who and what I am but I’m very fond of, and repeat to myself regularly one of the best quotes from Dr. Seuss. “Be who you are and say what you feel, because those who mind don’t matter and those who matter don’t mind.” and I try to live with this great piece of wisdom every day of my life. It’s a figurative life preserver that keeps me afloat when I’m beset by banal trolls who would rather I just be flat, plain, and featureless.

So, back to childhood. Everything that happened in your past all gets added up and results in what you are now. What kind of life would it be if I doubted myself now? It would be fake, and it would do a disservice to all the things that have come before. It would shame all the good things and it would render meaningless all the suffering that I endured. I refuse to accept either of those conditions so in a way, through my own convoluted logic I am who I am and I can’t be anything else. As if anyone could go back in time and change things, which you can’t, so it’s academic. This sort of thing, musing about changing your past is the height of uselessness. Pondering the impossible – and I would say changing your past is impossible, is a waste of effort, time, and thinking. For all the good that happened, I am happy for it. For all the bad that happened, I am happy for that as well. It’s only in enduring suffering and outlasting it that you defeat it and that singular win, defeating suffering, makes the rewards that much sweeter. So live in the now, bless and release the past, and try to do your best – because:

Be who you are and say what you feel, because those who mind don’t matter and those who matter don’t mind.

 

 

PAD – DP Challenge : Mind The Gap

“This week’s Mind the GapHow do you prefer to read, with an eReader like a Kindle or Nook, or with an old school paperback in hand?”

Ever since I laid my hands on my first tablet, which was my first generation iPad from Apple I’ve been a fan of digital reading. I’ve moved on as my preferences shifted. The iPad is still a great platform for comic books but not really so much for long-form reading of eBooks. I used to use a Nook Simple Touch but the side buttons started to fail and it lacked the backlight that I like to have at night when I read so I don’t have to upset Scott with stray lights so I can read. I’ve since switched to a Nook HD, using the money I got as a gift last Christmas. I have to admit that the Nook HD is a wonderful device for reading. I don’t really use the Nook service from B&N because I have all the books I want to read as not-online ePub files, and B&N doesn’t let you put your own files in their system so I load everything into the MicroSD card and then open the books from that memory device instead, all on the Nook HD. The key for me is the weight. The iPad is just too heavy to keep a hold of for an extended period of time. I thought I would be up for the iPad Mini, but my original idea that I could be fine using my iPad 3 with its Retina display and be okay with an iPad Mini which doesn’t have Retina turned out to be the stumbling block for me. The Nook HD has a Retina-like display and is only a few percent heavier than the iPad Mini.

I recently had a bit of irritation about books. I wanted to read “A Memory Of Light” by Robert Jordan and Brandon Sanderson and TOR only released the book as a hardcover. I understand why they did that, but I didn’t like it. I want to read books on my Nook HD and I don’t appreciate being meaninglessly inconvenienced just to satisfy the publishers designs. So I just dealt with it and hauled around the giant block of wood until I was done reading it. I do not like big books like that, they are heavy, bulky, and their bindings always take a beating when I’m reading and I just don’t know why. I’m not mean to books, but almost invariably they will become frayed or damaged. None of that happens on my Nook HD. I can carry it easily anywhere I like, it keeps my place, I can use highlighting and set bookmarks and I don’t have to haul around a heavy chunk of wood to do it. I think what upsets me most about the last Wheel Of Time book is that it was such a meaningless bit of inconvenience. That book started out being on a word processor. It started life as a digital file, then it was printed and bound and sold. So, the wood came out first, but in reality they could have if they really wanted to just dress the file that went to the printer up as an ePub and sold that instead. But no, they insisted that the wood beat the eBook. I don’t think the eBook will even go on sale until April, while the wood has been out since January. It pays honor and respect to wood, but irritates the consumer. I vowed that after Wheel of Time I wouldn’t read another book that wasn’t available as an eBook edition. I don’t need pictures or any of the surrounding miscellany, just give me the text. I’ll set my own font and font size and margins and page backgrounds.

So, onwards and upwards with eBooks. It shouldn’t really concern B&N, as I do enjoy reading my Nook HD there and it’s at my local B&N where I would go to talk to people who know books about books. The only thing I wouldn’t do is buy wood from them any longer. I would still buy books though. eBooks. Sometimes people mention that libraries can do eBooks, but that’s a joke. Sure, a library might have eBook editions available for lending, but they only have two “files” to lend out and a waiting list that is months if not years long. So, for the libraries I can wait until they get around to making sense. eBook editions for lending might as well be infinite, it’s not like the files themselves take any actual resources at all – just organized electrons is all. So, much like books themselves, at first they are valuable and rare, but over time the eBook editions will be just as common as their woody counterparts and lending them out through libraries will end up being just as plentiful and easy. Or at least so we can hope. In the meantime I can buy what I want and have the benefit of not having to haul around a big heavy chunk of wood.

Explaining Things Simply — The Lone Sysadmin

Explaining Things Simply — The Lone Sysadmin.

I read this article and started to really think about why it is that I find myself saying over and over again that Hell is Other People. I’ve faced this pressure in my professional life, the clamor to “write simpler” ends up being a 22 caliber bullet that ends up ricocheting around inside my head. The requirements for communication are straightforward, you need a common language with a common syntax, grammar and vocabulary. In my experience with IT the biggest tripping point is that vocabulary trap at the end.

When you are in IT, sometimes you have no choice but to write in a complicated fashion because the core issue is a complicated one. Usually there is fiscal risk, sometimes legal risk, sometimes even personal risk. The messages are often times important and the combined issue of complicated subject matter and limited shared vocabulary really makes communication impossible. This is where I think a lot of my particular cassandras tears originate from. I can’t hope to communicate with others about technology as the spiraling reduction of complexity required to reach a successful instance of real communication ends up making the entire statement devolve into “That is bad. We should not do it. It is not safe.” which ends up being thrown in the bin because your reasons aren’t good enough – those reasons you left on the chopping room floor because they were too complicated and there was no shared vocabulary.

After reading this article, which I can appreciate, I can’t help but get the image of Morlocks and Eloi out of my head. I’ve frequently made reference to these characters in HG Wells’ ‘The Time Machine’ story, but I think the comparison is apt and getting more so as time goes on. There are people who understand, there are people who do not, and it could lead to a fundamental separation between people – maybe even enough to be something that could cause speciation. There is another aspect of this that rankles me deeply, and that is that there is a deficit in vocabulary to start with! What ever happened to self-improvement, learning, or being curious with your average person? Years ago we all could have said that understanding technology wasn’t a necessity, but in the 21st century? Can we really say that still? Everyone needs to understand technology. Even a dog-catcher needs to understand some technology to do his work! So, if there is nothing to do that doesn’t involve some sort of technology then why do people avoid it so? Why do they remain so ignorant and incurious and so unwilling to learn?

I’ve said it many times and it’s likely going to be either a part of my memoirs or my epitaph even, that when someone ceases to learn, they begin to die. If you don’t want to know, perhaps living isn’t for you. Let a machine do it, what’s the difference?

Administrator’s Eyes

Working in IT in Higher Education for the past 14 years has taught me many key survival tactics. Life in Higher Education is special because of the unique specialness of the needs that many of my coworkers have. I don’t want to call anything specific out, I’m not here to hurt anyones feelings.

One of the first things you learn is that no matter what the patina is that people do their level best to project, right underneath it is some of the most kinky, clever, sneaky freaks you will ever meet. I hate to be picky but there is quite literally a 10 out of 10 chance that the truly kinky will be the boys. Perhaps this is higher education, perhaps not, but gentlemen, you are filthy. Damn.

When I started working in my profession I made some basic decisions which have saved my bacon more times than I care to even contemplate. First and foremost of those is cultivating “Administrator’s Eyes” which is the very state that I enter into when I help anyone with their technology. I started it as a habit and now it’s become a perception-altering meditative practice, nearly. When I am helping a client (I don’t call them customers, that’s inappropriate, they are clients) and I am sitting down where they normally sit I will focus my entire attention on the parts of the screen that contain only those pieces that enable me to render assistance. I do not let my eyes wander. It’s not out of some lofty sense of propriety that I picked up over time but more specifically battle-earned knowledge. I cannot, I will not handle the kinky freakish things that my fellow human beings get themselves into. Often times people will say “Oh, certainly nobody does that in a professional setting!” and I point them to teenage boys that spend way too much time in the bathroom with flimsy Scientific American magazines that appear to be on their last legs to keep their covers from falling off… these boys grew up into men and being a boy who grew up to be a man, I can say with authority that the only thing that honestly changed was that our hair started to thin or fall out.

It’s a habit that I recommend every IT professional adopt. It saves you from social embarrassment, even by proxy, and at the core of it stands this central question which each one of us in the IT field must eventually answer: “Can you handle the answers?” This is the first thing I consider before I even allow the questions to occur to me. Almost always the answer is no. A huge orchestra-blaring no. I can’t handle knowing anything. I can’t handle knowing usernames, passwords, websites, or anything at all beyond the thin border of a web browser. It’s not that knowing would endanger my professional life, but it would change my relationship with my clients and I simply cannot risk that. I have relationships that I must preserve, beyond everything else. I cannot perceive porn webpages, anything blah-Tube, even if it’s just online banking, trips to Amazon.com, or the stray Solitaire game being played. I have a deeply rooted and vested interest in knowing as little about my clients as I can manage beyond their presentation to me in the professional setting at work. It really is self-preservation. I do not perceive anything that would naturally be upsetting to anyone else so that the material in question does not change the fundamental relationship between IT professional and client. I suppose in a way, medical doctors take a “Do No Harm” oath, and I suppose I am advocating for IT professionals to take a similar oath “Do Not See”. Help with getting whatever it is up and working properly with sample data or bogus Lorem Ipsum if you can manage it, and even if you can’t and you have to look directly at the entire screen, once you engage the habit of “Do Not See” hard enough you might be able to pull off maintaining this state of blissful ignorance the entire way through your day.

This is something I encourage in all my assistants and people who work with me on IT tasks. I try to impress upon them that their coworkers may not be as pure as the driven snow and that through the adoption of Administrator’s Eyes they can learn a way to avoid the awkwardness that comes when you accidentally stumble onto a terabyte of stored data that people ought to keep at home, under a blanket, probably with a hot shower at the ready. It saves you from ever having to ask yourself that most torturous question “Can you handle the answers?” because I know I cannot. Therefore not only do I not ask the questions, but I don’t even consciously perceive anything that would lead me down that dark alley.

If there are any IT admins that read my blog, what are your thoughts on Administrator’s Eyes? Do you agree or do you think differently? Please comment here or on Facebook, I would love to know, as long as you’ve washed your hands in hot soapy water for a count of twenty. 🙂

PAD 2/3/13 – Writing Room

“A genie has granted your wish to build your perfect space for reading and writing. What’s it like?”

I’ve got the room, which is the library in the house I currently own. Right now this room is a makeshift guest bedroom with a library that has accumulated along the walls. There is a great design for a modular stackable bookshelf that really intrigues me and I imagine the library would feature this along the walls, improving on the current cheap particle-board bookcases that we currently use. I would also build these into the built-in closet in this room and take the doors off of it. In the center I would place an overstuffed leather chair with an ottoman for the legrests and behind it a floor lamp with multiple lights attached to a central body, much like this lamp. If the room was just a little bit larger I would also like a old-fashioned secretary desk to do writing and composition. I’ve written before about my affection for mixing up the traditional and the technological.

Truth to be told, if I got my hands on a Genie I’d likely not ask for these things, but instead relief from debt.

PAD 1/12/2013 – Inside vs. Outside

“Run outside. Take a picture of the first thing you see. Run inside. Take a picture of the second thing you see. Write about the connection between these two random objects, people, or scenes.”

2013-01-30 10.02.022013-01-30 10.02.26

These two images are from my workaday world. On the left is the view out of my office window, as the weather is quite awful outside I chose not to just dash outside. The picture on the right is inside my office and features one of my favorite things on my desk, my very evocative Edison bulb desk lamp. It’s cold outside, the weather is just beginning to demonstrate how surprisingly variable it can be, thanks in no small part to climate change. It’s not that the world will actually warm up, although it very well might just do that very thing, I rather suspect we’ll see more variability in the weather patterns instead.

Cold and Hot, as well, perhaps even impersonal and inviting. Once you start spotting dualities they can sometimes just carry you off. It’s not that there are just a finite set of dualities either, and I’m sure including more pictures would just add to this particular sense of contrast that we see here. I don’t really find the outside to be that compelling except during the spring, or I should say the true spring and not the false springs that appear now midway through winter on accident. There is more stability and comfort in the Edison bulb. This simple and anachronistic bit of technology emits a very warm yellow glow that in the early mornings and late evenings gives my office a very subtle old-world atmosphere. I’ve written before about my affections for both the bleeding edge of technology and the anachronistic throwback technology of the deep past living contemporaneously together and I will always posit that the very old and the very new belong together and that there is wisdom in keeping things that are throwbacks around because you never know when something that has been well-tested may become all important when conditions change and the newest technology cannot cope with changing environments. The classic example i use is how an electromagnetic pulse could render all my bleeding edge technology useless but my Edison bulb and my mechanical hand-wound pocket watch will continue on. This mixing of the newest and oldest makes a lot of sense and speaks to infinite diversity in infinite combinations, something that everyone should take away from Star Trek if you are as earnest about that series as I am. That respecting diversity, even when it comes to levels of technology are vital for survival because you may not have the neat whiz-bang working all the time while the older bits of tech continue to chug along. I keep a fountain pen in my bag because I trust the classics more, as there are no moving parts to a fountain pen other than it’s ink. Older items, or items that harken back to the bygone days are also important to remind you that the world still has room for elegance and simplicity and that complexity, while dazzling isn’t the pinnacle of living.

This connection between the new and the old also is playing out in another part of my life, as I am using something very new, my Day One app,  to do something that at least speaks to the past, which is journaling. I write everything in the journal and then selectively share either on my blog or on social media, depending on the level of security and privacy that my writings require. I’ve discovered that over the past few years I’ve accidentally logged every day of my life in Twitter, at 140 characters at a time and including these bits in my Day One journal is cementing my past so that years from now I won’t have to ever wonder about what I’ve experienced and when it happened, there will be a log of it. I’ve found journaling to be a very mixed bag of motives, right now I feel like a digital squirrel bounding all over collecting and burying bits of my past in a safe place – but eventually I will browse this resource and think about what has happened to me and perhaps I’ll learn more about myself or at least remember more of what it was like to be me during that time in my life. On an expanded tangent I sometimes wish I could include journaled stories from my parents and their generation. The things they experienced and the feelings they felt, shared with the younger ones amongst us. I’m very enamored of the idea of learning this way, not from prepared texts that have been curated and vetted, but from personal experience with all its rich colors and opportunities for interpretation and even its foibles and pitfalls. Much of this resembles the StoryCorps project, where the stories of the past are recorded. This is a wonderful place to start browsing, if you are engaged with this idea, and I think the power of journaling speaks to this and maybe someday I’ll get enough bravery to publish all that I have written, maybe some of it will be useful to someone else in the future.