Friday, June 28, 2013

Repurposing an old laptop

I was looking to install a HTPC in the bedroom. I fall into a category not disimilar to the hobo-geeks. I have enough money to buy tech goodies, but am too tight fisted to spend it! I tried Raspberry Pi running raspbmc and openelec, but despite all the reviews I read, all the tips and advice, it just didn't cut the mustard for me. It's nowhere quick enough to tolerate my media library, and it's too flaky when it comes to SD card corruption.

What to do? I had an old Dell D620 laying around (i don't often through away machines) and thought it would do the job perfectly. I set about removing the screen, and extracting the wifi module/antenna to reuse. Here it is topless, and all screwed back together:

Next I needed an appropriate image that's easy to install, configure, quick to boot and reliable. I chose XBMCbuntu. You can get it here - I added  an old MCSE remote I had laying around which worked out of the box. The finished result was a very quick booting, powerful (enough) PC capable of 720p playback via wireless. Easy to use, and achieved a high WAF.

Configuring SNMP on multiple Solaris 10 machines

There was a requirement to configure SNMP on dozens of Solaris 10 servers. I took one server, modified the /etc/sma/snmp/snmpd.conf file, tested it worked using snmpwalk, then wrote the following script to deploy that snmpd.conf as a template to every server in servers.list. Here's the script:


for x in $(cat servers.list)
     echo "Server: $x"
     ssh root@${x} "mv /etc/sma/snmp/snmpd.conf /etc/sma/snmp/snmpd.orig"
     scp ./snmpd.conf root@${x}:/etc/sma/snmp/snmpd.conf
     ssh root@${x} "svcadm disable snmpdx; svcadm refresh snmpdx; svcadm enable sma; svcadm refresh sma; sleep 3; svcs -v sma"

Thursday, June 27, 2013

A practical use for Raspberry Pi

There are hundreds of Raspberry Pi projects online, each one interesting. I purchased my rpi a while ago in hopes it would replace my bedroom HTPC...unfortunately they're just not great at handling large media libraries. I did however find a very practical use for it when preparing for a family holiday.

We had rented an apartment at Noosa for the week and I knew whilst the accommodation was very nice, they only offered basic pay-tv. So I installed the latest openelec image using this guide:

I took the rpi and a spare external HDD with me loaded up with must watch holiday movies. For anyone interested the reason I chose openelec over raspbmc was because I tested both quite thoroughly and OpenElec dealt with displaying thumbnails much better (smoother) than raspbmc in XBMC's default confluence interface.

When we booked I asked what type of TVs they have in the living/bedroom and was delighted to find out they were relatively new Samsung models so the CEC function worked great. So I didn't even need to take a remote with me!

Here's what it looked like:

Australian Radio Plugins for XBMC

My wife was using the ABC website to listen to Triple J on our HTPC. I did a little research and realised writing a plugin to do this within XBMC was pretty straight forward. While I was at it I wrote one to listen to RRR too.

EDIT: I've just created and uploaded a plugin for Double J. Thanks everyone for the feedback and suggestions.

Double J Plugin - Download here
Triple J Plugin - Download here
RRR Plugin - Download here

As Zan has written in the comments section,  to add these plugins to the home screen (as displayed below) perform the following:

System -> Settings
Appearance -> Skin Settings
Add-on Shortcuts
Home Page Music Submenu
Addon 1 Triple J
Addon 2 Three Triple R

It looks like this:

Scripting LUN path count and device info

During a recent project I cut hundreds of LUNs to present to a few Solaris 10 servers. I wanted a way to check the total number of LUNs for each server, and that each LUN was properly dual pathed. To do this, I wrote the following shell script. It will list out the LUN device path and number of paths, comma seperated, and the total number of LUNs at the end.

Remember if you're running this on a machine which has hundreds of LUNs presented to it, you're best directing the output to a file to prevent the screen buffer refresh slowing down the return rate of your results.


print "Device_Path,Path_Count"

# probe for LUNS
luxadm probe|grep Logical|
     read CRAP DEV_PATH

     # increment LUN count
     let a+=1

     # print device path
     print -n "${DEV_PATH:##Path:},"

     # check we have dual paths on each LUN
     pathCount=`luxadm display ${DEV_PATH:##Path:}|grep State|wc -l|tr -d ' '`

     if [ $pathCount -lt 2 ]; then
          errorMessage=" - WARNING: LUN does not contain redundant path"

     # check for path status other than online
     offlinePath=`luxadm display ${DEV_PATH:##Path:}|grep State|grep -v ONLINE`

     if [ -z $offlinePath ]; then
           errorMessage="$errorMessage - WARNING: 1 or more paths detected as NOT ONLINE"

     # print number of paths and path error if an offline path was found
     print "$pathCount $errorMessage"


# print number of LUNS discovered
echo "$a LUNS presented."

Monitoring Solaris zpools with HP OMW

Recently, we've had a few degraded zpools go unnoticed. They went unnoticed because our HP agents weren't monitoring their state (seems fair enough). After having a poke around what logs were available natively (not much) I broached the subject with our Tools Admin. He's always happy to help, so we knocked up the following perl script that gets executed every 15 minutes and reports in the event a zpool is in any state other than ONLINE.

use strict;

sub get_zp_list {
     my $pool_names = `zpool list -H -o name`;
     if ($pool_names eq "no pools available\n") {
          return $pool_names;
     my @pool_names = split("\n",$pool_names);
     return @pool_names;

sub get_zp_health {
     my $pool_name = shift;
     my $result = `zpool list -H -o health $pool_name`;
     chomp $result;
     return $result;


if ( ! -f "/sbin/zpool") {
     $ConsoleMessage->MsgText("zpools not supported in this sun release");
     exit 1;


sub zpcheck {
     my @zpools = get_zp_list();
     if ($zpools[0] eq "no pools available\n") {
          $ConsoleMessage->MsgText("no pools defined!");
          return 0;

     foreach my $pool (@zpools) {
          my $health = get_zp_health($pool);
          if ( $health eq "ONLINE" ) {
               # do nothing
          } else {
               $health = "unknown" if (!$health);
               # alarm in HP OMW
               $ConsoleMessage->MsgText("DNP- Problem with zpool $pool detected, status is $health");

Launch SSH connections like RDP

I'm a sysadmin for a living, primarily dealing with UNIX and Windows servers.  Seeing as there's an everyday requirement to cross between these two platforms I've tried many solutions to better manage the connection process. I don't like any of them, and I'd much prefer to just launch a connection to a server when needed, do what's required, then exit.

To achieve this I'll use mstsc /v server_name to connect via RDP to a Windows Server, or Putty to connect to a UNIX or Linux server. Establishing Putty connections take too long so I sought for a shortcut similar to mstsc from the run dialog box, here's a quick and easy solution:

1) Modify your PATH variable
* Right click Computer and select Properties
* Select Advanced System Settings on the left pane
* Click the Advanced tab
* Click Environment Variables
* Select Path from System  Variables and click Edit
* At the end of the Variable value field add ;Your_Path_To_Putty
* Click OK and close the system properties window

2) Add a putty shortcut
* Browse to your putty path
* Right Click > New > Shortcut
* Enter the path to putty followed by -ssh (eg. C:\Putty\putty.exe -ssh)
* Click Next
* Enter a shortcut name of ssh and click Finish
* Right click your new shortcut and select Properties
* Select the Shortcut tab
* Change the Run dropdown box to reflect Maximized

Now bring up the run dialog box and type ssh server_name. If you followed along, Windows should launch a putty SSH session to your server.