Jay Holler’s Blog

Icon

A technologist living in Philadelphia

Air Video Server running on a Windows XP Guest OS in virtualbox on Ubuntu Linux

For years I have been trying to find a way to easily and elegantly stream video to multiple small devices in our home. We only have one TV, and not everyone wants to watch the same thing at the same time. This really isn’t the worst problem in the world, obviously, but something I have tried to solve using all manner of different software and hardware combinations. A few weeks ago I discovered an iPhone application that required a server application running on either WIndows or Mac OS X. I tried to install the Windows version on my Ubuntu box running under Wine, but the application would crash as soon as the iPhone app tried to read a file from the hard drive. As they say, Wine Is Not an Emulator, and in this capacity it wasn’t going to cut it. I also checked the forums for the iPhone app developers who provide the PC app, and they had no intention of making a Linux version available anytime soon. So, I did what any self respecting geek would do presented with a solution which could potentially work, made it more complicated.
I first went through the process of building a new virtual machine in VirtualBox to host the Windows XP machine. That was quick and easy, and I happened to have an old XP disc lying around which isn’t in use on any computer anymore, since I haven’t used Windows at home since about 2004. The most challenging part was getting the Windows XP Guest OS to join the same network as the rest of the machines on my internal LAN, because virtual machines create a software interface and the actual packets are actually coming in through the same physical NIC card on the Linux machine. Fortunately, not too much googling later provided me with exactly the solution I was looking for. After installing these two utilities and running the script, provided at this blog, I was able to make the WIndows XP Guest OS join the 192.168.1.0 network! Perfect.
Now, all I had to do was install Bonjour from Apple, the Air Video Server application provided at inmethod.com and start it up.

I had to share the local Linux directory that stores all of our media, and set that up through VirtualBox, but that was relatively painless, requiring only that I get the VirtualBoxGuestAdditions.iso and use that on the Windows XP Guest OS so that it would recognize the shared folders and I could mount them permanently.

Once it was all good to go, I just added the /storage directory (which I mounted under Windows as Z:/ using the command “net use z: \\vboxsvr\storage”) to the shared directories in the Air Video Server app.

Here’s a screenshot of what this all looked like on the Windows XP Guest OS:

Air Video running in a Windows XP Guest OS

Air Video running in a Windows XP Guest OS

Now it was time to fire up the iPhone application and test all this juicy new streaming goodness!

I had been messing with this most of the night so the app had already detected the Windows instance of Air Video Server using Bonjour, which is why I had to install it on the Windows XP Guest OS:

AirVideo app Servers

AirVideo app Servers

Once you tap on the servername, the next screen shows you available shares:

AirVideo app available shares

AirVideo app available shares

Tapping on the Z:/ drive I made available shows me the directories and files located there, including a count of folders and files next to the folder names:

AirVideo app directories list

AirVideo app directories list

Drilling down into the TV directory shows me the same thing, folders and the number of files/folders in each directory:

AirVideo showing the TV directory

AirVideo showing the TV directory

Here I have selected the Bored to Death directory, and you can see that the app grabs screenshots as well as displaying some pertinent file information for each file found, very nice:

AirVideo app Bored to Death

AirVideo app Bored to Death

After selecting a particular file, I am presented with a few different options. Since this file is an xvid encoded avi, the app won’t be able to play the file natively. Air Video Server will take care of transcoding the file on the fly so that the iPhone app can play it:

AirVideo app avi file options

AirVideo app avi file options

Now comes the good stuff, after selecting “Play with Live Conversion”, I am presented with the option to play from the previously played position, the beginning, or seek to a new position, very slick indeed:

AirVideo app Live Conversion options

AirVideo app Live Conversion options

After making my choice: “The Beginning”, the app begins the process of buffering the video to the iPhone app:

AirVideo app Preparing Video

AirVideo app Preparing Video

Now, I suspect that because I’m running Air Video Server inside Windows XP running as a guest OS inside VirtualBox on a Linux host on a older desktop machine, the app complains that it doesn’t have the power to actually play the file, but all is not lost:

AirVideo app lies to me

AirVideo app lies to me

I just tell the app to continue anyway, and I was able to play the entire show without interruption:

AirVideo app buffering video

AirVideo app buffering video

And boom, about 5-10 seconds later, my TV show begins playing in perfect stutter-free fashion:

AirVideo app playing Bored to Death S01E01.avi

AirVideo app playing Bored to Death S01E01.avi

Tapping on the screen while the video is streaming brings up controls, in this case a little different than playing an x264 encoded file because the Air Video Server app is transcoding on the fly:

AirVideo app streaming converted file controls

AirVideo app streaming converted file controls

If I wanted to seek to a different position, the app handles that too, which is pretty nice to have, although honestly I usually just watch a show straight through:

AirVideo app live conversion seek menu

AirVideo app live conversion seek menu

All in all this app kicks total ass! I can now stream to any and all of the three iPhones in our house running from a single instance on a Windows XP Guest OS on my Linux box! The app works so well and I couldn’t be more pleased to be able to have this ability, which means I can now watch stuff while lying in bed without using a laptop, which is very nice indeed.

Filed under: Linux, Media, iPhone

handleMedia.sh

Being partially incapacitated has given me the opportunity to make some tweaks to my personal scripts which deal with all the incoming media formats I pull in using SABnzbd on my Linux box. For a long time I have been using separate scripts to deal with different files types, and I finally decided to make one script that automatically chooses which actions to take based on the file type found in the Downloads folder that SABnzbd dumps its content into. Without further ado, here is the new master script!

#!/bin/bash

#/usr/local/bin/handleMedia.sh
#
# Jay Holler 09-10-2009
# Find files in the Downloads directory and move them to
# the appropriate folder on the NFS share or put them in the Dropbox directory for syncing to iTunes.

## Move to the Downloads directory that SABnzbd uses

cd /home/jayholler/Downloads

###############################################
## Start the avi matching portion of the script
###############################################

if [ -e *.avi ] || [ */*.avi ] || [ -e Movies/*.avi ] || [ -e Movies/*/*.avi ]; then

storageDir=/storage/TV

mv */*.avi /home/jayholler/Downloads
mv Movies/*.avi /home/jayholler/Downloads
mv Movies/*/*.avi /home/jayholler/Downloads
mv TV/*/*.avi /home/jayholler/Downloads
mv TV/*.avi /home/jayholler/Downloads

for i in *.avi
do
myFile=”$i”

shopt -s nocasematch
if [[ "$myFile" =~ ([A-Za-z0-9\.]*)\.(S..E..).*.avi ]] ; then
File=${BASH_REMATCH[2]}.avi
PreShowName=${BASH_REMATCH[1]}
ShowName=$(echo $PreShowName | sed ’s/\./ /g’)
echo “[*] A new episode of $ShowName is ready for your enjoyment: $File” > /tmp/emailmessage.txt && sleep 2
[ -d "$storageDir/$ShowName" ] || mkdir -v “$storageDir/$ShowName”
mv -v $myFile “$storageDir/$ShowName/$File”
ln -s “$storageDir/$ShowName/$File” “/storage/Unwatched/$myFile”
wget http://localhost:XXXXX/web/ushare.cgi?action=refresh -o /dev/null -P /dev/null
mumbles-send -g qu0x “`basename $0`” “`cat /tmp/emailmessage.txt`”
/usr/local/bin/prowl.pl -application=”`basename $0`” -event=”New Show!” -notification=”`cat /tmp/emailmessage.txt`” -priority=1 -apikey=NOTTODAY
/usr/local/bin/email.sh
else
echo “[+] $myFile does not match our TV shows, pushing it to /storage/Movies on lunchbox” > /tmp/emailmessage.txt
mv -v “$myFile” “/storage/Movies/$myFile”
/usr/local/bin/prowl.pl -application=”`basename $0`” -event=”New Movie!” -notification=”`cat /tmp/emailmessage.txt`” -priority=1 -apikey=NOTTODAY
/usr/local/bin/email.sh
fi
shopt -u nocasematch
done

fi

#########################################
## End avi matching portion of the script
#########################################

###########################################
## Begin mp3 matching portion of the script
###########################################

if [ -e *.mp3 ] || [ -e Music/*.mp3 ] || [ -e Music/*/*.mp3 ] ; then
mv */*.mp3 /home/jayholler/Dropbox
mv Music/*.mp3 /home/jayholler/Dropbox
mv Music/*/*.mp3 /home/jayholler/Dropbox
echo “Moved a new album of mp3s to your Dropbox folder!” > /tmp/emailmessage.txt
mumbles-send -g qu0x “`basename $0`” “`cat /tmp/emailmessage.txt`”
/usr/local/bin/prowl.pl -application=”`basename $0`” -event=”New mp3s!” -notification=”`cat /tmp/emailmessage.txt`” -priority=1 -apikey=NOTTODAY
f7f099
fi

#########################################
## End mp3 matching portion of the script
#########################################

###########################################
## Start mkv matching portion of the script
###########################################
if [ -e *.mkv ] ; then
### Transcode 720p H264 mkv files for the Apple TV

if [ -z "$1" ]; then
echo “Usage: `basename $0` filename”
exit 0
fi

# Wait while any other ffmpeg processes are running
while [ -n "$(ps -ef | egrep "ffmpeg|HandBrakeCLI" | grep -v grep)" ];
do
echo -e “\n[$(date +%b\ %d\ %Y:\ %H:%M:%S)]\nFound another instance of HandBrake or ffmpeg running, pausing 5 minutes…”
sleep 300
done

# Get the beginning time from the date cmd.
START=$(date +%D\ %T)

# Email us that the next process has begun
echo -e “About to start transcoding $1 at $START” > /tmp/emailmessage.txt
/usr/local/bin/email.sh

#HandBrakeCLI cmd
HandBrakeCLI -Z “QuickTime” -i “$1″ -o “$1.m4v”

# Get the ending time of the transcode process from the date cmd.
END=$(date +%D\ %T)

# Inform us with an email that transcoding is completed
echo “Transcoding of $1 was started on $START and completed on $END.” > /tmp/emailmessage.txt
/usr/local/bin/prowl.pl -application=”`basename $0`” -event=”Transcoding Complete” -notification=”`cat /tmp/emailmessage.txt`” -priority=1 -apikey=NOTTODAY

# Move the original mkv file to the backup at /mkvs
mv -v “$1″ /mkvs

# Chop off the .mkv from the file name
transcodedFile=`echo “$1.m4v” | sed -e ’s/\.mkv//’`
mv “$1.m4v” “$transcodedFile”

# Determine the appropriate place to move the file and do so
/usr/local/bin/moveMp4s.sh “$transcodedFile”
fi

#########################################
## End mkv matching portion of the script
#########################################

exit 0

Filed under: Uncategorized

Catheter: miracle of modern science

Filed under: Uncategorized

iCacti for iPhone ties into running cacti instances

I recently started setting up all kinds of different monitoring and alerting systems on my own Linux box I keep at home for media storage and as a playground/lab. About a week ago I installed cacti and started setting up all kinds of graphs and pollers to hit my localhost as well as the router which spans our internal and external networks. It was simple, and I started to think about how great it is going to be to have all this data logged so I can refer to the data at a later date. Of course, being the iPhone app junkie that I am, I went out looking for an iPhone app that ties into my running cacti instance, and that is exactly what I found.
iCacti only requires that you can supply a URL, username, and password to log into your own instance of cacti running somewhere either in your internal network or over the internet. Setting things up took about 10 seconds. I ran into a problem where the data wasn’t being read from my cacti server, but I worked with the developer Várkonyi Balázs through email and we were able to get everything working. To reward me for helping him get it working with my older version of cacti, he sent me a pre-release copy of the hotfix he sent to Apple. Now, some screenshots.

List of currently configured graphs for my cacti instance


LocalHost Load Average

LocalHost Load Average in landscape

You can also change the length of time that the graph displays, or refresh the graph you are currently viewing. The thing I like the most about this is that it uses existing technologies rather than making you have to run another open port in order to feed the app. It even supports SSL connections to your webserver of choice.

The app runs smoothly and provides the data I need in a beautiful little app. Well worth the $1.99!

Check it out: iCacti iTunes Link

Filed under: Linux, Review, iPhone

Done with Jailbreaking

I am giving up on jailbreaking my iPhone. It takes too much effort, the phone becomes too buggy, and I ultimately don’t need to do anything that jailbreaking provides for me. Yes, it is really awesome to have an app on my phone that automatically scrobbles all music or podcasts that I listen to in the iPod app up to my last.fm account, but totally not necessary. Yes, it is totally badass to be able to discriminately choose which apps will run in the background, but also not entirely necessary. The last straw was when I decided to remove WinterBoard, which is an application that lets you change interface elements such as icons, background images on the home screen and much more. I had decided to remove it because I wanted to speed my phone back up, it does take some resources to run, and I wanted those resources back. Well, after uninstalling WinterBoard I had to reboot my device because the application puts some really deep hooks into the system. It never turned back on. It would try, the Apple logo would appear and the phone stayed in that state for a minute or two, but then it just went dark. Subsequent attempts to start the phone just ended in frustration. I ultimately had to do a full restore to factory settings in order to recover my device. I will be sad to lose the additional functionality, most especially StatusNotifier, which places small icons that look like they were designed by Apple themselves in your taskbar for missed calls, emails, text messages, and IMs. I can’t have my phone running unstable software though, as it’s a pretty important communication device to me, especially since my wife and I don’t use a landline at all in our apartment. This also isn’t the first time that I have run into issues with a jailbroken iPhone. A few months ago I had filmed a short video clip, attempted to upload that video to youtube, and then my phone went into total brick mode. In this instance I was left having to do a full restore, just as was the case today.
Android is starting to look better and better, although I know that platform isn’t without it’s flaws as well, but at least they have a kickass notification system built in without having to hack anything.

Filed under: iPhone

Droid vs iPhone

I got a change to really dig into my friend Felix’s Droid this Thanksgiving. I wanted to write down my impressions here, not only to share with everyone but also to keep myself in check whenever I yearn to own this multitasking big screen monster of a phone.
First of all, let’s get the biggest pro the Droid has going for it, the screen. It’s a Backlit TFT 3.7-inch WVGA (480×854) 16:9 widescreen display (267 PPI) and it is amazingly beautiful. Holding the screen up to the iPhone and viewing the same content it is no contest as to which device is more pleasing to the eye. Under the casing the iPhone and Droid both use the same processor, and it wasn’t surprising to see that both OSes booted up within seconds of each other in our side by side contest.
Android has really come a long way, and it is refreshing as an iPhone user to have more granular control over how applications are used on your device. I was able to rip open six or more applications (Google Talk, Browser, Gmail, Android Market, Music, ConnectBot) and it was quick and easy to jump between the different applications using the home button hold method. I was really impressed with how easy it was to navigate between running apps this way, and the phone didn’t seem to have any issues with lag even though we were doing so much at once. That being said, it was extremely disappointing to see such heavy lag just swiping between the three default home screen panels and when pulling down the windowshade notification bar. I have read that you can replace these apps with third party applications that perform better, but honestly you shouldn’t have to do that just to get a good experience from basic functionality of OS navigation.
Another problem I ran into was that after connecting the Droid in USB mode, and unmounting the drive once we were done transferring some media, the SD card got in some kind of funky state that caused the entire phone to become unresponsive. After taking the battery out and putting it back in we got some white-text-on-black-background about a bootloader and instructions to connect the SD card to USB, but nothing undid the problem until we actually removed the SD card and put it back in.
I have been using an iPhone in various forms (original edge-only iPhone, iPhone 3G, and now iPhone 3GS) for over two years, and the responsiveness of the screen is hands down better than the Droid, I’m sad to say. The Droid screen seems to require either a little bit more pressure or a little bit more time to register where you are pressing. If it was my first touchscreen phone it probably wouldn’t even be something I would notice, but the iPhone sets a high bar with the effortless responsiveness of their screen. In line with that the software keyboard was pretty terrible at recognizing what keys I was pressing, especially in portrait mode. I am certain that I am partially to blame as it does take some time to adjust to how a particular phone reacts to your thumbpads tapping the screen, but it was really abominable at registering my intended key even when I was typing slowly and deliberately. The portrait keyboard actually takes up a much smaller amount of space than the iPhone portrait keyboard, making it more difficult to press the tiny targets.
The media features aren’t quite as robust as on the iPhone either, but it is definitely serviceable and of course with the Android Market you can replace the default media player with one of several available. It is a little disappointing that the SD card included is only a class 2 card so the speed is not exactly optimal for playing back large video files on that beautiful monster of a screen.
Not to get nitpicky, but the feel of the device also was not as organic and natural to me as holding the soft, rounded curves of the iPhone. It wasn’t uncomfortable by any means, but just didn’t match the same fit and finish. I would like to point out however that the slider has absolutely NO play whatsoever, which was something that really disappointed me about the Pre when I first put hands to it.
Of course, there are complaints I have about the iPhone as well. Android’s notification system is in my opinion the single best way to deal with incoming alerts from an unlimited number of applications. Icons populate the status bar indicating the number of alerts for a particular application, and when you drag down the windowshade you can select actions to be taken on the alerts which usually involves opening the application that generated the alert. On the iPhone, you are typically presented with a modal pop up dialog that REQUIRES your input prior to allowing you to move on. More than once I have received a push notification or text message during a call which required me to acknowledge the alert prior to having the ability to press the end call button beneath it. That is just piss poor design, and from Apple it is just not acceptable, knowing what they can accomplish.
The iPhone does not allow multitasking of any third party applications. However, many third party developers have begun to code their applications in such a way that the exact state of the application is stored when you press the home button, so when you relaunch the application again it is as though you never left in the first place. A perfect example of this in action is the newish Tweetie 2. Prior to the latest release if you exited the app and opened it again later you had to scroll back from the very top until you could find the tweet you were reading. Now, the list is exactly in the same place it was when you exited the app. Although this doesn’t help with apps that would require running in the background (ie a media streaming app like pandora) it does make the experience of using most data heavy apps much more enjoyable, and simulates multitasking as best as possible while still meeting Apple’s restrictions by sandboxing any third party applications.
I have jailbroken my iPhone so I can selectively chose which applications run in the background anyway, but I don’t take advantage of the feature that often, because it typically starts to negatively impact the performance of the foreground application I am currently using. The only essential thing I use the jailbreak software for is to add tiny notification icons to the statusbar with StatusNotifier, which is something every phone under the sun includes. I am hoping a future update will see Apple including something like that by default, so if you have a new email, you can tell without having to unlock your phone and look at the little red badge over the Mail icon.
Felix and I also took a quick drive so he could show off the Google Maps with navigation application. It was fucking awesome. Once we mounted the phone it switched into Map/GPS mode automatically. I pressed one button to begin the audio listener, and spoke the address of my proposed destination. The phone pulled up a route, locked in GPS, and started speaking directions. The GPS was pinpoint accurate as to our current location, and the directions we received were flawless. This is extremely well executed and I am hoping the rumors that this software will make its way over to the iPhone are true, because that was a truly badass experience.
All in all, the Droid is a very impressive phone, but the OS still felt a little too rough around the edges and unpolished for me to be tempted to switch devices. The iPhone has a consistency about it that is very hard to beat, plus the performance of native applications cannot be beat by java apps that Android runs. At this pace though, unless Apple really steps up their game (keep in mind all iPhones share the same exact screen size, this is going back over two years now) I could see the slew of Android devices coming out in 2010 to be a real threat. I am certainly going to keep a keen eye out for new Android headsets, but right now my iPhone still makes me the happiest. I use it more than I use my computer, which is saying a lot for me.

Side note: Last month we exceeded the number of minutes on our AT&T FamilyTalk plan. It came to the tune of an extra $100!! I called AT&T and explained that I wanted to increase the amount of minutes on our plan since we exceeded it last month and we were on track to exceed it again this month. The AT&T rep not only took care of this right away, backdated it so that we wouldn’t incur extra charges this month, but he also removed the extra charges from our overage last month!! He did this all without any prompting by me that this was something I was interested in. I thought this type of service was extremely excellent, and it makes me feel much better towards the company as a whole. I still hate having dropped calls, but that seems to have improved a tiny bit in the last week or so.

Filed under: Opinion, iPhone

Android

I have a problem. I have an addiction. It is a strong addiction. I am addicted to mobile phones/connected internet devices. Lately I have been jonesing for something better than the iPhone, which I love by the way. So today I installed the Android SDK on my Mac and this is the emulator running ConnectBot ssh’ed into my local Linux machine. I love technology.

Filed under: Uncategorized

Applescript for iPhoto

I was helping Anna pull some pictures off of our new camera so she could export them at a smaller size, and post them to her etsy shop: http://www.etsy.com/shop/mamaholler
So of course being the kind of guy that I am I decided to script the entire process, and ended up with a drop dead simple solution that only requires you to connect the camera to a USB port and press Yes/No on a single dialog box. It automatically launches when the camera is connected thanks to the setting being an option on Image Capture to launch any random script. Then it imports your photos into iPhoto (which is nice enough to recognize duplicates and ask what you want to do with them), then it asks if you want to export or not, and if you answer yes exports the photos to the dedicated Etsy directory on Anna’s desktop. Once that is complete it automatically unmounts the camera storage card so you can just pull the USB cable and get on with your life. I call it iPhoto_Magic.app:

– First we do the importing
tell application “iPhoto”
import from “/Volumes/DMC-FZ28/DCIM/101_PANA”
end tell
delay 3
– Then we do the exporting
property maxPixel : 800
property destinationFolder : “/Users/jayholler/Desktop/Etsy/” — the trailing slash is required

tell application “iPhoto”
select photos of album “Last Import”
set sel to selection
end tell
display dialog “Do you want to export these photos to Etsy?” buttons {“No”, “Yes”} cancel button 1 with title “Jay’s Awesome iPhoto Script” with icon stop
if result = {button returned:”Yes”} then
repeat with onePhoto in sel
tell application “iPhoto” to set {pLocation, pName} to {image path, title} of onePhoto
do shell script “sips -Z 800 -i -s format jpeg -s formatOptions best ” & quoted form of pLocation & ” –out ” & quoted form of (destinationFolder & pName & “.jpg”)
end repeat
end if

do shell script “hdiutil unmount /Volumes/DMC-FZ28″

if result = {button returned:”No”} then
do shell script “hdiutil unmount /Volumes/DMC-FZ28″
end if

This is how the dialog looks:

Filed under: Uncategorized

Nagios and iPhone push notifications

I have a friend who works for an ISP and a few months back he told me about how he had wrangled Nagios into monitoring their servers and networking equipment. His story piqued my interest, and last night I finally downloaded Nagios, and configured it to monitor my 24×7 Linux host that sits behind my TV providing a number of different services to my internal network. Installing Nagios from source was simple with the instructions at http://www.nagios.org, and within minutes I was up and running. I had a little trouble with setting up auth_digest authentication for apache2 but I think that was mostly because that module wasn’t enabled by default. After I got the main configuration up and running, and I was able to access the web interface, I began to poke around. While I was doing this I got an email notification that my disk space was over 20%. I then thought, wouldn’t this be cool if I could turn this into a push notification?
I already set up a script provided by http://prowl.weks.net/static/prowl.pl, and have that working to notify me when a new TV show is added to my Linux host. I found that the settings for notifications in Nagios were located at /usr/local/nagios/etc/objects/commands.cfg. In the notifications section, I added the following below the two entries for email notifications, which I included:

# ‘notify-host-by-email’ command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$
}

# ‘notify-service-by-email’ command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

# ‘notify-host-by-prowl’ command definition
define command{
command_name notify-host-by-prowl
command_line /usr/local/bin/prowl.pl -application=”Nagios” -event=”** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” -notification=”Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$” -priority=1 -apikey=THISISWHEREMYAPIKEYWOULDGO
}

# ‘notify-service-by-prowl’ command definition
define command{
command_name notify-service-by-prowl
command_line /usr/local/bin/prowl.pl -application=”Nagios” -event=”** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” -notification=”Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$” -priority=1 -apikey=THISISWHEREMYAPIKEYWOULDGO
}

So now, when Nagios sends a notification, I get a pop up instantly on my phone that looks something like this:

Nagios iPhone Prowl

Nagios iPhone Prowl

Righteous!!

Filed under: Linux, iPhone , ,

moveAvis.sh updated

UPDATE: I made some improvements and will now catch both shows that start with letters or numbers.
ANOTHER UPDATE: Turns out i was truncating the show name, it is fixed and I have updated the script and link to pastie.org too.

I updated my script to be totally generic now. It does not depend on matching the names of any specific TV shows now, since I know the filename will always contain SxxExx to indicate Season and Episode, I filter that way. If the directory for that show already exists it will simply move the file there, if it doesn’t it will create a new one. Otherwise, if it isn’t a TV show, it goes to the Movie directory. Also, since I’m now using ushare to serve media to my xbox 360, I put a wget call in to the ushare web port to update the files so the xbox picks them up immediately over uPnP.

#!/bin/bash
#
#/usr/local/bin/moveAVIs.sh
#
# Jay Holler 09-10-2009
# Find *.avi files in the Downloads directory and move them to
# the appropriate folder on the NFS share

storageDir=/storage/TV

cd /home/jayholler/Downloads

for i in *.avi
do
myFile=”$i”

if [[ "$myFile" =~ ([A-Za-z0-9\.]*)\.(S..E..).avi ]] ; then
File=${BASH_REMATCH[2]}.avi
PreShowName=${BASH_REMATCH[1]}
ShowName=$(echo $PreShowName | sed ’s/\./ /g’)
echo “[*] A new episode of $ShowName is ready for your enjoyment: $File” > /tmp/emailmessage.txt && sleep 2
[ -d "$storageDir/$ShowName" ] || mkdir -v “$storageDir/$ShowName”
mv -v $myFile “$storageDir/$ShowName/$File”
wget http://localhost:49153/web/ushare.cgi?action=refresh -o /dev/null -P /dev/null
/usr/local/bin/email.sh
else
echo “[+] $myFile does not match our TV shows, pushing it to /storage/Movies on lunchbox” > /tmp/emailmessage.txt
mv -v “$myFile” /storage/Movies/$myFile
/usr/local/bin/email.sh
fi
done
exit 0

Here’s the same thing in nicer formatting: http://www.pastie.org/612353

Filed under: Uncategorized , ,

Latest Tweets

  • Thanks in part to @jackmorales and in part to the excellent work being done in Banshee for Linux, I think I may be finally purging Apple. 2 days ago
  • All I have to say is I love the writers for Lost. Great material, even if all their ideas are recycled from science fiction novels. 1 week ago
  • Cannot believe that the final season of Lost is upon us. We've been watching the previous seasons in anticipation. Great show. 1 week ago
  • OK, so you're telling me that the iPad is essentially a giant iPod Touch?! No multitasking, no Flash, no non-App Store 3rd party apps?!?!?! 1 week ago
  • Back to work tomorrow for the first time in 2010. I wish that I was off on vacation that whole time or something. Working at home for now. 2 weeks ago