July 27, 2011

Display Twitter Feed on Polycom

Posted in Fun Hacks at 11:13 pm by trainridetothecity

Twitter feed on the Polycom

Twitter feed on the Polycom

Well I got this new IP Phone replacing our old PSTN phones. But the LCD screen on the phone looked bit boring.

There were few ideas how I can use this realestate to do something interseting.

  1. Display the train timetable (Metlink doesn’t give you a clean API to scrape the time tables, and I don’t have time to write a script scrape the data from its bulky website. )
  2. Weather (Kind of boring to watch it all the time)
  3. What’s people talking about your company on  Twitter, and thats what I did…..

My Ugly Bash Script

#!/bin/bash
text=`export http_proxy=http://xx.xx.xx.xx && /usr/local/extractSearch.pl`
convert -size 160x75 -monochrome -depth 1 -type Bilevel -gravity center caption:"Twitter Feed\n$text" /var/www/polycom/image.bmp

The Perl Script
#!/usr/bin/perl
# use module
use XML::Simple;
use LWP::UserAgent;
use Data::Dumper;
# create object
$xml = new XML::Simple;
my $url = "http://search.twitter.com/search.atom?q=<Your Query>&rpp=1&page=1&locale=en";
my $ua = LWP::UserAgent->new();
$ua->env_proxy;
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
$ua->timeout(30);
$ua->default_header('pragma' => "no-cache", 'max-age' => '0');
my $res = $ua->get($url);
$data = $xml->XMLin($res->content);
print "$data->{entry}->{title}"

January 29, 2011

Am I hacked?

Posted in Uncategorized tagged , , at 10:20 am by trainridetothecity

I found a very strange thing when I saw DNS queries for random servers on Wireshark. I am running Ubuntu 10.10 and I was pretty sure that no one is running malicious scripts on my Laptop. I was really worried when I saw DNS queries to www.ssa.gov and I had no idea what it was at the time. And when I googled to find out what it was the DNS queries increased.

So I had to get the bottom of this. “lsof” is a very useful program to see which process is responsible for the which network transaction. When I ran the following I found the culprit.

poo@SDT-TravelMate-8572G:~$ lsof -i udp
COMMAND    PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 1855 poo   42u  IPv4  27548      0t0  UDP SDT-TravelMate-8572G:41473->dns1.xxx.com.au:domain
firefox-b 1855 poo   62u  IPv4  27547      0t0  UDP SDT-TravelMate-8572G:35432->dns1.xxx.com.au:domain
firefox-b 1855 poo   63u  IPv4  27556      0t0  UDP SDT-TravelMate-8572G:34421->dns1.xxx.com.au:domain

So the culprit is Firefox doing DNS pre-fetching. Interesting article on that

 

December 13, 2009

Linux Bare Metal Restore

Posted in Uncategorized tagged , , , , , , at 2:27 am by trainridetothecity

At work I have been given the task of coming up with a procedure of bare metal restore of redhat servers. There were two requirments.

1) Hot backing up
2) Remote restore

After some researching this is the procedure I came up with. Please bear in mind this procedure has only been tested in model enviroment and do your own homework before using this as your DR plan.

A) Backup

Backup the mbr and the bootloader. First 512 bytes of the primary HD contains the partion table and the bootloader. Here is the command for that.

dd if=/dev/sda of=/backup/mbr.img bs=512 count=1

Ensure that you have the backup directory and correct HD.

Now we need to backup the filesystem. Linux is dynamically creating the following directories. So no need to take the backup of them.

1) /sys
2) /proc
3) /var/run
4) /lost+found
5) /tmp

You need to exclude the backup directories. You can use tar or rsync to take the backup, however if you use rsync ensure you preserve symlinks and file permissions. Here is the command to create the tar archive.

tar cvfpz /backup/root.tar.gz –exclude=sys –exclude=proc –exclude=var/run –exclude=tmp –exclude=lost+found –exclude=backup /

Take a backup of the /etc/fstab and partion table info from the following command.

fdisk -l > /backup/fdisk.txt

B) Restore

Okay before restore lets crash the HD. Please beware this command shall ruin your HD, do not run this in the production enviroment.

dd if=/dev/random of=/dev/sda bs=512 count=100

Okay let’s start restoring.

You need a lInux live cd. Well I prefer a knoppix since it has all the useful tools.

Boot the server with the knoppix cd and restore the partion table. Since I am soundf this remotely I will be using iLo virtual media to mount the knoppix live cd.

dd if=/backup/mbr.img of=/dev/sda bs=512 count=1

Linux will not identify the HD until you reboot, however you can do the following as well. Run fdisk and write the partion table by pressing ‘w’.

Okay now let’s format the partions. This is where the copy of fstab helps. You can run the following command for each partion.

mkfs.ext3 /dev/sda2 -L /
mkfs.ext3 /dev/sda1 -L /boot

Now your partions are ready for the data. Let’s mount the devices. First create the mount point by running the following command. I am killing two birds with one command. I am creating rootfs and boot directories.

mkdir -p /rootfs/boot

Okay change directories, into cd /rootfs

Let’s extract the archive

tar xvzp /backup/root.tar.gz

Okay now we need to create the following directories.

mkdir /sys; mkdir /tmp; mkdir /lost+found; mkdir /proc; mkdir /var/run

Okay now you need to chroot into the /rootfs

mount -t proc /proc /rootfs/proc
mount -o loop /dev /rootfs/dev

chroot /rootfs -c /bin/bash

Now you have mounted the filesystem. Run the following command to reinstall grub

grub-install /dev/sda

Okay fingers cross you have recovered your crashed server. Reboot the box you have resurrected your Linux box.

Things you need to know. This won’t work if you have a LVM. If your fstab has uid rather than block devices, you need to change it to block devices.

If you have grub2 grub reinstallation might change a bit.
I will cover that in another post.

Okay something you might notice that I didn’t cover the backup directory. You have several options here. You can use a nfs or samba mount for that. Please keep in mind if you are using rsync as your backup method you cannot have the symlinks in a samba mount. So you need to use tar if you are using the samba option.

If you have a better way or see a mistake please comment.

December 10, 2009

On a conference bridge at 4am

Posted in Uncategorized tagged , at 5:11 pm by trainridetothecity

Damn it is a long conference call tonight, five people on the bridge and trying to figure out what to do with a faliure.

Not going to work tommorow.

Saving is the new spending

Posted in Uncategorized tagged , , , at 6:16 am by trainridetothecity

Photo by torugatoru

Since we moved to Australia, we were thinking whether to ride the mortgage bandwagon or not. But we are struggling to find the right house for the right price. These are our requirements.

1) Within 25 I’m radius of the city.
2) 3 bedroom
3) Just enough garden
4) South eastern suburbs.

But after months of looking around we still haven’t found the house that will take our breath away. So we have to compromise at least one of the requirements. We have seen some nice houses in the northern and western suburbs. But right now it’s not an option for us with N’s work. And one more special reason. Anyway our savings are getting bigger which effectively will increase our buying power.

Anyway this is an advice for all those people who are renting. Rent money is dead money as well as the interest payments of the mortgage. If you are not in a position to buy make sure that you increase your savings. This will increase your buying power as well as your deposit.

Saving is the new spending.

December 9, 2009

iLo through SSH tunnel

Posted in Uncategorized tagged , , , , at 9:23 pm by trainridetothecity

Photo by the_Linux_Cauldron

This is for geeks and for my future reference.

I am quite used to tunneling port on hosts in remote networks. I thought iLo is using only http and http for it’s management. But if you need to to access the intergrated remote console with virtual media you need lot more ports than that. These are the ports you need to forward.

22 Secure Shell (SSH)
23 Remote Console / telnet
80 Web Server Non-SSL (HTTP)
443 Web Server SSL (HTTPS)
3389 Terminal Services
17988 Virtual Media
9300 Shared Remote Console
17990 Console Replay
3002 Raw Serial Data

Thanks to Karlo

Driving to the city

Posted in Uncategorized at 8:54 pm by trainridetothecity

Photo by Age

Since I needed to grab some servers from a data center to my office, I had to drive to city yesterday. This was the first time I drove to the city. I was in a dilema whether to take the toll or not. Citylink in Melbourne will cost you $12 for a day pass. It will take you from M1 directly to Exhibition street if you take the Batman Avenue exit. Since my friend was worried that he will be late to work we thought of taking the citylink option an expensive one but it took me directly to the exhibition street without a hassle.

Picking the servers became quite a heavy task. I thought I can use a trolly but it was not the case. I had to lift the servers from the 2nd floor to the street twice. Well now I pay the price for it. My arms and shoulders hurt like hell now. I am quite used to lift heavy things. Few years back I used to unload 20ft containers in four hours, I quite enjoyed doing that. But now my body has been quite lazy.

Our office building has it’s own carpark, it is very convenient . And if you park the car before 10am you will only have to pay $11 for the whole day.

Driving back home was a different story. I had to wait 20 minutes in the exhibition street. But it was ok and enjoyable. I was able to do some siteseeing without leaving the comfort of my car. No complaints after I entered the M1. It took me directly to South Eastern suburbs in 15 min.

Ok now the comparison.

Cost Car Train
Fuel (70km) $8.5 $0
Toll $12.50 $0
Parking $11 $0
Ticket $0 $9.86
Total $32 $9.86

As you see it was a quite expensive drive.

December 7, 2009

The Fuel Economy

Posted in Uncategorized tagged , , at 10:23 pm by trainridetothecity

Eversince we got our new Holden Viva, I had big hopes about the four cylinder having good fuel economy. But it never performed the according to the Holden specifications.  Fuel economy was one of the main reasons we went for a mid sized car, but I am dissapointed.

Average 7.4 litres/100km was promised on the Daewoo Lacetti with Holden fur. But for the last one year I never achived that. The best I got was 9.9 liters/100km. So I was thinking, I should change my driving habits to see whether I can hit the 7.4 mark. According to the couple who drove from Melbourne to Canberra on less than half a tank, hypermiling is the way to increase the fuel economy.

So for the next few weeks I will be following these guidelines.

BE A HYPERMILER

  • Avoid brake usage, or sharp acceleration whenever safely possible.
  • Drive at or slightly under the speed limit.
  • Switch off your air-conditioning.
  • Plan your journey and avoid rush hour when possible.
  • Avoid carrying unnecessary weight, such as roof racks, tool kits or golf clubs.
  • Don’t leave the engine idling.
  • Keep your tyres at the right pressure.
  • Tune and service the engine.
  • Use higher manual gears.

Keep an eye on the chart on the main page.

Metro vs Connex

Posted in Uncategorized tagged , , , , at 12:24 pm by trainridetothecity

Photo by zed.fitzhume

Here I am at the station waiting for another train. Since the new operator has taken the responsibility of running Melbourne metropolitan train system, there has been this big argument who is better. Metro or Connex.

Connex was managing the metro train lines for the past ten years. State government took the decision to get rid of the old operator and get a new one from Hong Kong. Which is said to be ultra effecient in running of HK metro.

Personally I didn’t see major issues with Connex. I might have low expectation because Melbourne Metro System is thousand times better than the Sri Lankan one. Travelling in Sri Lankan public transport system is health and safety issue. To those who are unfamilier with Sri Lankan transport system, it like the Bathurst V8 with cars replaced with aluminum bodied buses. Drivers of these buses compete with each other in the same route to pick up more passengers. So you will never know when you will end up in major crash. Coming back to Connex everybody thought changing the operator shall revolutionize the train system and will make it look like HK metro. But reality is far from it, state government has failed to identify the needs of these passengers, what we need is not change of logo or metro in front of every announcment. What we need is more trains in peak hours and reduce the time people have to wait for a train in non peak hours.

To make this a reallity what we need is more trains, more drivers, more tracks and effecient signalling system. New operator cannot provide this without the backing of the government.

Time to get off in Melbourne Central.

Blogging from iTouch

Posted in Uncategorized tagged , , at 12:22 pm by trainridetothecity

Photo by Kai

Found an interesting app for offline blogging on wordpress. No brainer look for wordpress in iTunes. I might use my iTouch to blog rather than a netbook.

Next page

Follow

Get every new post delivered to your Inbox.