LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 09-10-2009, 01:56 AM   #1
usagi32
LQ Newbie
 
Registered: Sep 2009
Posts: 4

Rep: Reputation: 0
Hwaddr of all nodes on a cluster


Hi,

I need to create a list of all the hostnames and their HWaddr (hardware addresses [also called MAC address]) for all the nodes on my Linux cluster.

I know that all the hostnames can be found in /etc/hosts, but there doesn't seem to be a list of HWaddr numbers.

I guess one can write a script to ssh into all the hostnames found in /etc/hosts and execute the command

/sbin/ifconfig | grep 'HWaddr'

on each node and concatenate this into a single text file. My Linux skills are not good enough to do this though.

Does anyone know if there is a list of HWaddr numbers in system directory, or alternatively, does someone know how to write a script to generate the HWaddr lists?

Thanks,
Bryan
 
Old 09-10-2009, 03:52 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
You may want to do a simple loop over the cluster nodes and run the ifconfig command through ssh. Are the IP address of the nodes in numeric sequence (for example in a interval between 192.168.0.10 and 192.168.0.25)? Or have you a list of the IP addresses stored in a file? Are the machines set up for passwordless login?

If these conditions are met, you can try something like:
Code:
#!/bin/bash
while read ip
do
  mac=$(ssh -n user@$ip "/sbin/ifconfig | awk '/HWaddr/{print \$NF}'")
  printf "%s\t%s\n" $ip $mac
done < file_with_ips_one_per_line
 
Old 09-10-2009, 11:21 AM   #3
usagi32
LQ Newbie
 
Registered: Sep 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the help colucix!

I have a list of the IP addresses stored in a file. Suppose I have each of them listed on a separate line in a text file called "ip_addresses.txt". How would the above code look like using this text file?

Thanks
Bryan
 
Old 09-10-2009, 03:11 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Exactly as it is. Just substitute my dummy file name "file_with_ips_one_per_line" with the actual "ip_addresses.txt" (without quotes). Also substitute "user" with a real username for which you have set-up passwordless access for all the cluster nodes.
 
Old 09-11-2009, 12:21 AM   #5
usagi32
LQ Newbie
 
Registered: Sep 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks colucix! You're the man!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make an account across different nodes in a cluster muneebs123 Linux - Networking 2 08-26-2004 05:39 PM
Cluster....which distro is best for the Nodes? KaptinKABOOM Linux - Software 7 06-14-2004 09:34 PM
rsh on Cluster nodes rudy3107 Linux - Software 0 07-22-2003 07:53 AM
How do i create an a/c at all nodes in the cluster dogma Linux - Networking 4 05-19-2003 11:21 AM
rsh between 2 nodes on a Linux Cluster marxsmann Linux - General 2 01-26-2003 05:15 PM


All times are GMT -5. The time now is 03:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration