LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-13-2009, 07:26 PM   #16
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54

If you have a router/nat you can just grep for 192.168 or which ever of the four natted adress spaces you use.
Without nat, your isp probably has the same first two octets every time, so grep for what you usually have.
 
Old 01-13-2009, 07:55 PM   #17
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You could use "getent hosts <hostname>" as well. Even if you use avahi for name resolution. You will still get the localhost IP address for the host you are running on since that is what is in the hosts file.

The freemem value might be useless. There will be memory used for cache that will be freed if the system needs it. Obtaining the load and memory values from a remote host, you probably need to have some kind of client running on those hosts or use ssh to run a command or script that will return the values. And running a client or script to monitor memory and load value will of course reduce the available memory and increase the load. As you would expect.

I find it convenient to use public key encryption for ssh. Using that and "AllowHosts" makes it more secure, I you don't need to deal with using expect to deal with authentication. Sometimes that can interfere with pipes and tees in your script. Having usernames and passwords in scripts is best to avoid as well.
 
Old 01-14-2009, 04:19 AM   #18
mmahulo
Member
 
Registered: Nov 2008
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by GazL View Post
IP=$(hostname -i)

may save you all that messing with ifconfig and sed to pull the ip address out.
Thanks Gazyl

That was fairly easy.
 
Old 01-14-2009, 08:05 AM   #19
GazL
Senior Member
 
Registered: May 2008
Posts: 4,181
Blog Entries: 5

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by colucix View Post
Unless there is a way to know which is the external interface and which is (are) the internal one(s), other than check the address itself after its extraction, of course. Moreover, there are a lot of different types of network interface. For example having my system at home connected via DSL modem and running OpenSuse I have
Code:
dsl0      Link encap:Point-to-Point Protocol
eth0      Link encap:Ethernet
lo        Link encap:Local Loopback
wlan0     Link encap:Ethernet
wmaster0  Link encap:UNSPEC
In the absense of an external reference such as dns, the simplest solution I could come up with would be to assume the interface associated with the default route is the correct one,
Code:
ifconfig $(route | grep default | awk '{print $8}')
And then parse that with the sed script you provided in your responses above. It's still not entirely foolproof, but at least you're not hard coding the interface name which is a step in the right direction.

Ofcourse, if the system is configured such that hostname -i returns the correct value, it avoids the need for all this shenanigans, but as you made clear, this cannot be relied upon on all distributions and setups.


This is why I enjoy hanging out on LQ. You can often find interesting insights in threads that you expect to be pretty straightforward on first viewing. Yes... I know, I'm Sad like that.
 
Old 01-14-2009, 08:07 AM   #20
GazL
Senior Member
 
Registered: May 2008
Posts: 4,181
Blog Entries: 5

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by mmahulo View Post
Thanks Gazyl

That was fairly easy.
You're welcome. Just keep in mind the issue that Colucix and I were discussing.
 
Old 01-14-2009, 08:15 AM   #21
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by GazL View Post
In the absense of an external reference such as dns, the simplest solution I could come up with would be to assume the interface associated with the default route is the correct one
This is a great advice! Well done!
Quote:
Originally Posted by GazL View Post
This is why I enjoy hanging out on LQ. You can often find interesting insights in threads that you expect to be pretty straightforward on first viewing.
Totally agree!
 
Old 02-07-2009, 03:38 AM   #22
slack12ware
Member
 
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46

Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
@slack12ware:

~ = tilde

` = backquote
ohps my bad, youre right there, was in a bit of a hurry.
 
  


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
Old/Tough PC. rvijay Linux - General 9 02-02-2005 09:59 AM
Anyone know Cg? How tough is it? R00ts Programming 0 11-11-2004 02:11 PM
Tough One gsibble Linux - General 1 02-01-2004 05:06 PM
Here's a tough one... GameboyHippo Linux - Software 4 10-21-2003 05:35 PM
Ok this one is a tough one so let's see what ya got! antihero Programming 2 08-29-2001 07:32 PM


All times are GMT -5. The time now is 06:08 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration