A headless system is something which don’t have a monitor connected to it, or neither have a remote access console. Usually such systems are assigned statically configured IPs so that the IP don’t change over machine reboots and hence the system don’t lose access. But what do you do when you have a headless system in a network where the IPs are assigned through DHCP. If the system is not often booted often, then its fine. Again, DHCP keeps the lease for some days or even up to weeks and you end up getting the same IP even over multiple reboots. But consider a case where you are in a busy network, where people connects multiple devices to the network and IPs are leased through DHCP. You may lose the IP even in the next reboot. So, a headless system is a big pain in the arse.
If you are using a UNIX/Linux system, you are lucky. Just write a simple shell script where you get your current IP address and mail it through sendmail or other email utilities through your SMTP server. You can include this script in your rc scripts which gets executed during system startup and you conveniently get an email in your inbox with the IP address of your headless workstation. Life is simple in the UNIX/Linux world for these tasks. But, what do you do when you have a headless Windows box? We can do something similar. Lets see.
A major part of the following content is attributed to the following blog post:
1. Download SendMail for Windows.
2. Put the following content into a Windows Batch file, say ip.bat:
ipconfig > ipaddress.txt
SendEmail.exe -f FROMADRESS -t TOADDRESS -u SUBJECT -m MESSAGE -s SMTPSERVER -a ipaddress.txt
Now, if you link the above script to Start Menu\Startup, our problem is not solved fully. Because mostly the programs specified under Start Menu\Startup is executed after user logon. But if you don’t know the IP address of the system, you can’t connect and so you cant login. So, we are no good with this. At this point, you can do two things, or may be more. I am aware of just Two🙂
1. Create a task using task scheduler, to run the task at system startup and link ip.bat as the program which should run every time this task is executed. Pretty straight forward. You can go to Task Scheduler from Administrative Tools menu in Windows 7.
2. Include ip.bat under startup scripts using the group policy editor.
execute gpedit.msc, go to Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown)
Startup -> Right Click (Properties) -> Add your script ip.bat
Be careful about the paths etc. in your script, you are done!
But, frankly you are not fully done here. There is a catch. It might so happen that by the time your script ip.bat gets executed as a part of the startup scripts , your network configuration may not have completed, so you might get an email with incomplete ipconfig data. To get around of this issue, just sleep for some time before you ipconfig is executed in ip.bat. May be 15 – 20 seconds by using timeout command. But, by default, the startup scripts are executed in order and so waiting for 15 – 20 seconds may increase your boot time significantly. So avoid such an issue, we can execute the startup scripts asynchronously.
Just enable a policy, again using gpedit.msc
Enable Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> Scripts -> Run startup scripts asynchronously
While researching on internet about distributed systems and designing a cluster of distributed nodes, I came across a set of very cool tutorials on the topic. Meant for beginners, with all the fundamental concepts, the tutorials act as a great starting point on the distributed systems design.
The bibliographical notes points to very nice slides, papers on the topic.
The web is a vast ocean of information. But, are all these information useful to everyone? May be NO. Take my example. I was so irritated with the hot summer and everyday I kept longing for a day, cooler than yesterday. So, I’ would visit weather.yahoo.com or msn weather to know about the weather info for the day and may be for the next few days. Everyday, opening a browser window, typing the URL address and getting the information was getting bit monotonous. Yes, you are right. I could have bookmarked the URL and click it whenever I want it. But, if I want weather info for 10 other cities of the world, where my relatives, friends live, bookmarking 10 URLs is not a good option. So, being a sole UNIX user, I thought why not a command line tool to get the weather info !!! The idea clicked and I wrote a small python program to do this using Yahoo Web Services.
The steps I followed:
1. Take the name of the city as user input from command line.
2. Find the Latitude / Longitude using Yahoo Map API.
3. Get the Where On Earth ID (WOEID) of the city using the info from Step 2. using Flicker API
4. Get the weather details using the WOEID using Yahoo Weather API.
As simple as that …
The program is tested with Python 2.5, 2.6. It wont work in Python 3.
[ mausam is a Hindi word meaning Weather ]
Cloud Computung !!! A hot cake in today’s technology trend. As everyone is talking about it, I thought, let me give a try too. But the apathy to buy an account with Amazon led me to go for free, open source alternative as Amazon clones. I was more interested in cloud storage, so looked for an Amazon S3 clone. And ya, its Eucalyptus Walrus. Eucalyptus, or more precisely Open Eucalyptus is free open source solution for forming your own provate cloud. There is a community cloud hosted in University of California at Santa Barbara, and is a Eucalyptus based cloud. Even Ubuntu One, the free cloud with Ubuntu 10.04 (Lucid Lynx) is also hosted on Eucalyptus. There is an enterprise version where you pay for the support and is being used by many organizations including NASA for having its own origanizational provate cloud.
The best part of Eucalyptus is that its fully Amazon AWS compatible. So, whatever applications you developed for Amazon is supposed to work with Eucalyptus too. Its supports both SOAP and REST APIs.
Some of the common apps of Amazon S3 like S3CMD, S3FS and S3Curl also works with Eucalyptus. I hosted my private cloud is a DELL 64bit machine with a CentOS 5.4 and Eucalyptus 1.6.2. Installation and configuration was quite easy, and in no time I could have my buckets in the cloud with my files. All commands of S3CMD worked perfectly well. But when I tried to mount my Walrus buckets in my local filesystem of my desktop using FUSE and S3FS, I encountered some problems. While I was able to mount the buckets, cd into the mount points and even touch, cp and create/save files with vi in it, the most basic commands like ls, ll, du etc were not working. Finally, hacked into the code of S3FS and with few changes in it, I could make it work. Thanks to Randy Rizun, the developer of S3FS for writing such a fantastic software and relasing the code in open.
I am attaching my unofficial changes here, with which I could made S3FS r188 work with Eucalyptus 1.6.2. I haven’t tested it extensively, so don’t really know if the changes I made breaks s3fs anywhere else. Just an advice, don’t use my changes in production.
Change the extension of the attached file from .odt to .patch and patch the source of S3FS r188 by doing patch -p1 -i s3fs_r188.patch and then do a make.
My brother gifted me a book called The Developer’s Edge, a book on selected blog posts and articles by a number of experts from Sun Microsystems. Compiled by Darryl Gove, a performance engineer in Sun’s compiler team. Read through a few chapters and found the book to be too good. The material of the book is very much practical in natures and not easily to be found in conventional books. One had to google it otherwise. Its very much Solaris specific and as the book is by a performance engineer, it very much suits my interests and tastes. The topics ranged from a wide variety of stuffs like performance tools, programming techniques, compiler directives, insights into hardware like Sun’s UltraSPARC T1 / T2. I would recommend this book for anyone who works in Solaris OS and wants to have a deep dive.
The book is available at Amazon.
Today, one of my colleagues pointed me to a online book on python. Written by an young professional, fulfilling the needs of a novice. I loved the book so much that I almost read half of it in one sitting. The language is simple and easy to comprehend. A must for any python beginner. The online version is available from the following link.
Ahh.. my CPUs are HT enabled. Processor hyper threading is not a new term. However, while writing programs for multi core processors which are again HT enabled, it need thoughts. For example, two threads of a processor core although believed to do more work, but they might be contending for the same resources, which will fully mask the benefits of hyper threading. I read an interesting article on this which I am sharing here: