Cluster Management in VisLab/Archive

From ISRWiki
Revision as of 14:10, 12 May 2009 by Giovanni Saponaro (talk | contribs) (explanation of "uname" alias on Cortex)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Some obsolete information is kept here, for the sake of history.

Cortex and the uname command

Prior to 2009-05-12, the command

  uname -n

(which normally outputs the unique, alphabetic name of the current machine you are logged in) was not working as we wanted on Cortex. This happened because all the machines in the cluster share the same network disk. In particular, the file /etc/hostname is also shared among all of them; it contains the string "source", which is the real result of "/bin/uname -n" but it is of little information for our "yarp run" script, which sometimes needs to answer the question "where am I?".

Forcing uname to give the desired output

Since we want each machine of the cluster to provide its unique name (i.e., cortex[1..5]) as the output of "uname -n", we can use the following command to do the job:

  ifconfig eth0 | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}' | awk -F. '{print $4}'

Basically, this command extracts the last byte from the current machine IP address. For example, if you type it on cortex3 you will get "3" (the last byte of 10.10.1.3) as output.

The idea is to enforce that custom command as a system-wide behaviour in the cluster, by setting an alias called "uname -n" (to be more accurate, the alias is just called "uname", with every additional parameter to be ignored).

In bash scripting syntax, dollar signs have to be escaped, so the final alias is

  alias uname="ifconfig eth0 | grep 'inet addr' | awk '{print \$2}' | awk -F: '{print \$2}' | awk -F. '{print \$4}'; echo > /dev/null"

We added this in

  • /etc/bash.bashrc (it sets the alias correctly on interactive shells, we need to check non-interactive sessions)