Saturday, March 22, 2008

Finding The Fastest Host

I play on Server 3 of Travian UAE, and the domain name s3.travian.ae points at 19 different hosts, and most are slow for me.

The lines below show how to get the server with the lowest average ping time. This assumes the servers will reply to ping requests (only one doesn't), and that you're not blocking ping requests from your end.

for i in $(host s3.travian.ae | awk '{print $4}'); do echo -n "$i:" >> trav.txt \
&& ping -qc5 $i | tail -n1 | cut -d/ -f5 >> trav.txt; done
sort -t: -k2 trav.txt | head -n1
rm trav.txt

Put the result in /etc/hosts and you're all set! This should save you time when querying for DNS, and wouldn't depend on your luck at which server you get (even though Travian employ round robin)

* This is not to be used with any website, since most have MX records (mail server records) and the script above doesn't work in such cases.

* You can remove the backslashes above and write the whole thing in one line. I put on multiple lines to make it readable.

The script is no longer useful since they moved to one server now. Seems like they distribute to multiples during registration period.

Sunday, March 16, 2008

NFS Mapping and Mass Group Ownership Change

Right to the point: 2 Unix (AIX 5.3L) servers with NFS directory one needs to be mounted on the other. The catch? Both must have the same user & group, and both the user & group must have the same IDs.

Since the target server (NFS Client) must stay intact, I had to change the group ID (GID) on the other box, then apply the new ID to all the files & directories on the system.

I changed the GID from old to new using smitty, AIX's administration interface utility. Then I applied the following script to all files & directories on the NFS Server:
find / -group 206 -exec chgrp 320 {} \;


"find" will look for all files & directories with the old GID, which is 206*, and when found, it will run "chgrp" to change its group to 320.

* Since there is no longer a group name associated with the old GID, it shows as a number when "ls"

chgrp can take the group name: chgrp "groupname" -- but I used the numerical value anyway.

P.S.: I had a moronic idea of running chgrp recursively, that is:
find / -group 206 -exec chgrp -R 320 {} \;

Thank God, I had a wakeup call before running that, because if I did, it would change the GID of ALL files & directories under a directory that matched the old GID, so this would've changed directories & files that might have had a different GID.

After all that, mounting NFS worked like charm & I no longer had mapping issues. Mounting was done as:
mount blade6:/path/to/dir /path/to/dir


P.S.: mounting the directory, then running chown on it is a dumb idea, because it would change the GID on the NFS Server.

Thursday, March 13, 2008

RAM and BIOS Upgrade

I've been contemplating buying new RAMs for months and been looking for the proper brand, price, capacity & speed.

My machine, code name: Adrenalin, has 2x 1GB of Kingston RAM; they're beautiful, fast & do the job, but they're just not quite enough for my kind of [ab]usage.

I tried buying from NewEgg.com and TigerDirect.com, and as newegg was clear that they won't accept VISA, AFTER registering & reaching the payment page, TigerDirect.com failed at it, and not only that, my questions via email went unanswered for days and when got a response, it was totally irrelevant to my questions!!! The only quick response I got from them, is when I emailed them to cancel my order, in which they did within 2 hours!

Luckily, I found the same piece I was looking for on Amazon, at the same price of TigerDirect; In fact, Amazon gets the item from TigerDirect themselves!

I was after Corsair XMS2 DHX 2x 2GB kit RAM, and though the CAS latency is higher than the Kingston that I had, it wouldn't make much of a difference to me.
This piece of RAM is absolutely amazing: Not only do you get high-grade RAMs, you also get an amazing heat-sink design and a life-time warranty!

I ordered 2 kits, totalling in 8GB of RAM to fill all my 4 DIMMs, and have been waiting for them to arrive for 2 weeks, and today I got them, went back home and started the upgrade ritual.

0) Open a shell and write down the uptime: "up 42 days, 10:52"
1) Download memtest+ ISO file & burnt it
2) Shutdown machine & keep power cord connected
3) Clean dust & wash fan filter
4) Open case and touch internal metal body to discharge static electricity
5) Remove old RAMs & grab a pocket-knife & start cutting the cover of new RAMs before checking if it can be opened by hand
6) Open RAM cover by hand
7) Enjoy the beauty & smell the fresh scent of the hardware pieces
8) Anxiously & carefully install new RAMs
9) Power up & enter BIOS to make sure correct values for RAM are detected
A) insert memtest+ media to thoroughly test all RAMs -- passed

After that, I booted into Windows (XP 64-bit) to check for BIOS updates, which I found, and downloaded manually after the ASUSupdate program failed to download the needed file.
It was straight forward: Open AsusUpdate & choose "Update From File" then select the BIOS .BIN file and click away. Almost.

There was an option to reset the BIOS settings to the factory default after flashing the new BIOS version, and since I didn't want to go through the whole configuration process, I unselected it and flashed the new BIOS. After rebooting, the machine wouldn't start. PANIC ATTACK!
I thought the BIOS is being flashed after a reboot, which is not what used to happen before, and waited for 2 minutes, yet nothing happened, so I shutdown & powered up again, and nothing happened.

I run to my sister's room to find that she's not there, but her laptop is; PERFECT! I snag it and surf away to Asus's website and grab the manual, then I find that I'm downloading the Chinese manual, so I cancel & hunt for the English manual.
After the manual downloaded & unpacked, the BIOS has a recovery mode for cases where flashing the BIOS goes wrong (EXCELLENT!) -- the problem is that the screenshots assume that the machine would boot and I'd be able to see text on the monitor, which I didn't. Failure.

I go back to my room, calculating the cost of sending the motherboard to Asus and the time I'd have to spend without my baby -- then I remembered the option which I unselected.
I remove the BIOS battery & unplug the power for a minute, then put the battery back & hook the power. Power up. IT'S ALIVE!
Seems like the nwe BIOS wasn't fond of the old BIOS's settings! Anyway, I configure my stuff again and all goes smooth.

Lessons learned: None.

-> Pictures.