Xymon Mailing List Archive search

MAC address in the client data?

4 messages in this thread

list Martin Ward · Wed, 21 Jul 2010 17:10:43 +0100 ·
All,

 
I don't know if this quirk is peculiar to Solaris or is the same on
other flavours of UNIX, but if you are not the root user and you run the
ifconfig(1m) command it does not show the MAC address assigned to the
interfaces. Here is what I see in Xymon's client data view for one host:

 
[ifconfig]

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1

        inet 127.0.0.1 netmask ff000000 

ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

 
If I login as root and run the command I see:

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1

        inet 127.0.0.1 netmask ff000000

ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

        ether 0:3:ba:96:e6:4f

 
I am currently writing a script to retrieve information from the stored
client data and to populate a database with that info. In this manner
when I install Xymon on a new server the configuration information is
automatically updated in my server database. The question is: How can I
get the MAC address? By default the Xymon client is installed and run
under the hobbit user ID. Is there any way I can configure the
hobbitclient-sunos.sh script to run as root?  I guess I could run the
ifconfig command using sudo and configure sudo so that it doesn't
require a password, but is there any other/better/easier/more elegant
ways of doing this?

 
|\/|artin

--  

 
Martin Ward

Manager, Technical Services

 
DDI:+44 (0) 20 7863 5218 / Fax: +XX (X)XX XXXX XXXX /  www.colt.net
<http://www.colt.net/>; 

Colt Technology Services, Unit XX, Powergate Business Park, Volt Avenue,
Park Royal, London, NW10 6PW, UK.

 
Help reduce your carbon footprint | Think before you print. Registered
in England and Wales, registered number 02452736, VAT number GB 645 4205
50

 
[Colt Disclaimer]
The message is intended for the named addressee only and may not be disclosed
to or used by anyone else, nor may it be copied in any way. The contents of
this message and its attachments are confidential and may also be subject to
legal privilege. If you are not the named addressee and/or have received this
message in error, please advise us by e-mailing user-51905b889b93@xymon.invalid and delete the
message and any attachments without retaining any copies. Internet
communications are not secure and Colt does not accept responsibility for this
message, its contents nor responsibility for any viruses. No contracts can be
created or varied on behalf of Colt Technology Services, its subsidiaries,
group companies or affiliates ("Colt") and any other party by email
communications unless expressly agreed in writing with such other party.
Please note that incoming emails will be automatically scanned to eliminate
potential viruses and unsolicited promotional emails. For more information
refer to www.colt.net or contact us on +44(0)20 7390 3900
Attachments (1)
list Vernon Everett · Thu, 22 Jul 2010 11:00:40 +0800 ·
Hi Martin

I believe this to be a Solaris feature. And looks like it is also the case
on others.
See here http://www.coffer.com/mac_info/locate-unix.html

And yes, I think sudo is the simplest way of getting round it.
However, if you have conscientious objections to using root and/or sudo, you
could try messing about with the output of arp -a.
A bit of creative scripting, and you should get something you could tack
onto the output of ifconfig -a.
YMMV.

Cheers
      Vernon
quoted from Martin Ward


On Thu, Jul 22, 2010 at 12:10 AM, Ward, Martin <user-2d33a6eb6a05@xymon.invalid> wrote:
 All,


I don't know if this quirk is peculiar to Solaris or is the same on other
flavours of UNIX, but if you are not the root user and you run the
ifconfig(1m) command it does not show the MAC address assigned to the
interfaces. Here is what I see in Xymon's client data view for one host:


[ifconfig]

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232
index 1

        inet 127.0.0.1 netmask ff000000

ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63


If I login as root and run the command I see:

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232
index 1

        inet 127.0.0.1 netmask ff000000

ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

        ether 0:3:ba:96:e6:4f


I am currently writing a script to retrieve information from the stored
client data and to populate a database with that info. In this manner when I
install Xymon on a new server the configuration information is automatically
updated in my server database. The question is: How can I get the MAC
address? By default the Xymon client is installed and run under the hobbit
user ID. Is there any way I can configure the hobbitclient-sunos.sh script
to run as root?  I guess I could run the ifconfig command using sudo and
configure sudo so that it doesn't require a password, but is there any
other/better/easier/more elegant ways of doing this?


|\/|artin

--

[image: Colt email signature FINAL]
quoted from Martin Ward

Martin Ward

*Manager, Technical Services*


DDI:+44 (0) 20 7863 5218 / Fax: +XX (X)XX XXXX XXXX /  www.colt.net

Colt Technology Services, Unit XX, Powergate Business Park, Volt Avenue,
Park Royal, London, NW10 6PW, UK.


Help reduce your carbon footprint | Think before you print. Registered in
England and Wales, registered number 02452736, VAT number GB 645 4205 50


 [Colt Disclaimer] The message is intended for the named addressee only and
may not be disclosed to or used by anyone else, nor may it be copied in any
way. The contents of this message and its attachments are confidential and
may also be subject to legal privilege. If you are not the named addressee
and/or have received this message in error, please advise us by e-mailing
user-51905b889b93@xymon.invalid and delete the message and any attachments without
retaining any copies. Internet communications are not secure and Colt does
not accept responsibility for this message, its contents nor responsibility
for any viruses. No contracts can be created or varied on behalf of Colt
Technology Services, its subsidiaries, group companies or affiliates
("Colt") and any other party by email communications unless expressly agreed
in writing with such other party. Please note that incoming emails will be
automatically scanned to eliminate potential viruses and unsolicited
promotional emails. For more information refer to www.colt.net or contact
us on +44(0)20 7390 3900
list Tim McCloskey · Wed, 21 Jul 2010 20:33:41 -0700 ·
From a Solaris 10 ifconfig man page:

ether [ address ]
         If no address is given and the user is root or has  suf-
         ficient  privileges  to open the underlying device, then
         display the current Ethernet address information.

Vernon is right, arp is probably your friend here. There are other ways of doing this, arp being one of them.  If it were me, I would not want to run sudo or change anything to run as root when the same information is already available to the hobbit user.  For displaying information, arp will work in child zones as well.
 
Certainly you would do something a bit more sane than the following, laziness provides the following example, there are better ways to do this:

for ip in `ifconfig -a | gegrep -A1  "bge0: " | tail -1 | awk '{print $2}'`; do arp -na | grep $ip | awk '{print $NF}'; done

some:mac:addres:displayed:here

Regards, 
quoted from Vernon Everett


From: Vernon Everett [user-b3f8dacb72c8@xymon.invalid]
Sent: Wednesday, July 21, 2010 8:00 PM
To: xymon at xymon.com
Subject: Re: [xymon] MAC address in the client data?

Hi Martin

I believe this to be a Solaris feature. And looks like it is also the case on others.
See here http://www.coffer.com/mac_info/locate-unix.html

And yes, I think sudo is the simplest way of getting round it.
However, if you have conscientious objections to using root and/or sudo, you could try messing about with the output of arp -a.
A bit of creative scripting, and you should get something you could tack onto the output of ifconfig -a.
YMMV.

Cheers
      Vernon


On Thu, Jul 22, 2010 at 12:10 AM, Ward, Martin <user-2d33a6eb6a05@xymon.invalid<mailto:user-2d33a6eb6a05@xymon.invalid>> wrote:
All,

I don't know if this quirk is peculiar to Solaris or is the same on other flavours of UNIX, but if you are not the root user and you run the ifconfig(1m) command it does not show the MAC address assigned to the interfaces. Here is what I see in Xymon's client data view for one host:

[ifconfig]
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

If I login as root and run the command I see:
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63
        ether 0:3:ba:96:e6:4f

I am currently writing a script to retrieve information from the stored client data and to populate a database with that info. In this manner when I install Xymon on a new server the configuration information is automatically updated in my server database. The question is: How can I get the MAC address? By default the Xymon client is installed and run under the hobbit user ID. Is there any way I can configure the hobbitclient-sunos.sh script to run as root?  I guess I could run the ifconfig command using sudo and configure sudo so that it doesn't require a password, but is there any other/better/easier/more elegant ways of doing this?

|\/|artin
--

[cid:image001.jpg at 01CB28F6.36AD1610]
Martin Ward
Manager, Technical Services

DDI:+44 (0) 20 7863 5218 / Fax: +XX (X)XX XXXX XXXX /  www.colt.net<http://www.colt.net/>;
quoted from Vernon Everett
Colt Technology Services, Unit XX, Powergate Business Park, Volt Avenue, Park Royal, London, NW10 6PW, UK.

Help reduce your carbon footprint | Think before you print. Registered in England and Wales, registered number 02452736, VAT number GB 645 4205 50

[Colt Disclaimer] The message is intended for the named addressee only and may not be disclosed to or used by anyone else, nor may it be copied in any way. The contents of this message and its attachments are confidential and may also be subject to legal privilege. If you are not the named addressee and/or have received this message in error, please advise us by e-mailing user-51905b889b93@xymon.invalid<mailto:user-51905b889b93@xymon.invalid> and delete the message and any attachments without retaining any copies. Internet communications are not secure and Colt does not accept responsibility for this message, its contents nor responsibility for any viruses. No contracts can be created or varied on behalf of Colt Technology Services, its subsidiaries, group companies or affiliates ("Colt") and any other party by email communications unless expressly agreed in writing with such other party. Please note that incoming emails will be automatically scanned to eliminate potential viruses and unsolicited promotional emails. For more information refer to www.colt.net<http://www.colt.net>; or contact us on +44(0)20 7390 3900
list Martin Ward · Mon, 26 Jul 2010 10:17:59 +0100 ·
Thanks gents for your replies and directions.  I decided to use arp(1m)
rather than sudo to avoid having to mangle the sudoers file.

So for anyone else that needs to implement the same solution, below is
the three-step solution. I followed the Xymon standard of using an
environment variable to re-point the ifconfig(1m) command elsewhere.
Could we get this change to the ifconfig command use put in to the next
version?

Step 1:

I modified the ~xymon/client/bin/hobbitclient-sunos.sh file and changed:
echo "[ifconfig]"
ifconfig -a

to be:
echo "[ifconfig]"
$IFCONFIG -a

Step 2:

I modified the ~xymon/client/etc/hobbitclient.cfg, appending the
following to the bottom:
IFCONFIG="/opt/hobbit/client/ext/ifconfig.pl"

Step 3:

I created the file ~xymon/client/ext/ifconfig.pl. This script uses arp
to get the MAC address and prints it out in a similar format to the real
ifconfig command and the source is at the bottom of this email.

The only difference between this and the output of "ifconfig -a" is that
Solaris does not put leading zeroes in to the MAC address whereas
arp(1m) does:

arp -> 00:08:7c:bb:04:c0
ifconfig -> 0:8:7c:bb:4:c0

I left the code out to remove leading zeroes for the sake of speed. I
will add it in later so if you want this functionality email me, or feel
free to hack the code yourself.

Here is the source code:
----
#!/usr/bin/perl -w

# A perl script that emulates the "ifconfig" output but puts the MAC
# address in the right place if the executing user is not root.
#
# v1.0 - Author: |\/|artin (user-2d33a6eb6a05@xymon.invalid)
#
# On Solaris servers you only see the MAC address in the ifconfig -a
# output if you are root. This script emulates that by using the output
# from arp -an.

my $IFCONFIG='/sbin/ifconfig';
my $ARP='/usr/sbin/arp';

my ($iface, $curriface, $inet, $ipaddr, $arpip, $mac);

# Check if we are root.
if ($> == 0) {
        # Simmply execute ifconfig with the command line parameters
        exec $IFCONFIG, @ARGV;
}

# The user is not root, so run IFCONFIG but catch the output
open(IFC, "$IFCONFIG @ARGV |") or die "Unable to run $IFCONFIG:". $!;

# Output from ifconfig looks like this:
quoted from Tim McCloskey
# ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index
2
#         inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

$curriface = '';

while (<IFC>) {
        # First print the current line out though.
        print $_;

        chomp;
        ($iface, $ipaddr, undef) = split/ +/, $_, 3;

        if ($iface =~ /\tinet/) {
                # We have an IP address so use it to get the MAC address
                open(ARP, "$ARP -an |") or die "Unable to run arp:" .
$!;
                while(<ARP>) {
                        chomp;
                        (undef, $arpip, undef, undef, $mac) = split;
                        print "\tether $mac\n" if ($arpip eq $ipaddr);
                }
                close(ARP);
        }
}
close(IFC);
quoted from Tim McCloskey

----

|\/|artin
--  
Martin Ward
Manager, Technical Services

DDI:+44 (0) 20 7863 5218 / Fax: +XX (X)XX XXXX XXXX /  www.colt.net
Colt Technology Services, Unit XX, Powergate Business Park, Volt Avenue,
Park Royal, London, NW10 6PW, UK.

Help reduce your carbon footprint | Think before you print. Registered
in England and Wales, registered number 02452736, VAT number GB 645 4205
50

-----Original Message-----
From: Tim McCloskey [mailto:user-440820cc07d6@xymon.invalid]
Sent: 22 July 2010 04:34
To: xymon at xymon.com
Subject: RE: [xymon] MAC address in the client data?

From a Solaris 10 ifconfig man page:

ether [ address ]
         If no address is given and the user is root or has  suf-
         ficient  privileges  to open the underlying device, then
         display the current Ethernet address information.

Vernon is right, arp is probably your friend here. There are other
ways of
doing this, arp being one of them.  If it were me, I would not want to
run
sudo or change anything to run as root when the same information is
already
available to the hobbit user.  For displaying information, arp will
work in
child zones as well.

Certainly you would do something a bit more sane than the following,
laziness
provides the following example, there are better ways to do this:

for ip in `ifconfig -a | gegrep -A1  "bge0: " | tail -1 | awk '{print
$2}'`;
do arp -na | grep $ip | awk '{print $NF}'; done

some:mac:addres:displayed:here

Regards,


From: Vernon Everett [user-b3f8dacb72c8@xymon.invalid]
Sent: Wednesday, July 21, 2010 8:00 PM
To: xymon at xymon.com
Subject: Re: [xymon] MAC address in the client data?

Hi Martin

I believe this to be a Solaris feature. And looks like it is also the
case on
others.
See here http://www.coffer.com/mac_info/locate-unix.html

And yes, I think sudo is the simplest way of getting round it.
However, if you have conscientious objections to using root and/or
sudo, you
could try messing about with the output of arp -a.
A bit of creative scripting, and you should get something you could
tack onto
the output of ifconfig -a.
YMMV.

Cheers
      Vernon


On Thu, Jul 22, 2010 at 12:10 AM, Ward, Martin
<user-2d33a6eb6a05@xymon.invalid<mailto:user-2d33a6eb6a05@xymon.invalid>> wrote:
All,

I don't know if this quirk is peculiar to Solaris or is the same on
other
flavours of UNIX, but if you are not the root user and you run the
ifconfig(1m) command it does not show the MAC address assigned to the
interfaces. Here is what I see in Xymon's client data view for one
host:

[ifconfig]
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232
index 1
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index
2
        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63

If I login as root and run the command I see:
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232
index 1
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index
2
        inet 10.5.2.46 netmask ffffffe0 broadcast 10.5.2.63
        ether 0:3:ba:96:e6:4f

I am currently writing a script to retrieve information from the
stored client
data and to populate a database with that info. In this manner when I
install
Xymon on a new server the configuration information is automatically
updated
in my server database. The question is: How can I get the MAC address?
By
default the Xymon client is installed and run under the hobbit user
ID. Is
there any way I can configure the hobbitclient-sunos.sh script to run
as root?
I guess I could run the ifconfig command using sudo and configure sudo
so that
it doesn't require a password, but is there any
other/better/easier/more
elegant ways of doing this?

|\/|artin
--
[cid:image001.jpg at 01CB28F6.36AD1610]
Martin Ward
Manager, Technical Services

DDI:+44 (0) 20 7863 5218 / Fax: +XX (X)XX XXXX XXXX /
www.colt.net<http://www.colt.net/>;
Colt Technology Services, Unit XX, Powergate Business Park, Volt
Avenue, Park
Royal, London, NW10 6PW, UK.

Help reduce your carbon footprint | Think before you print. Registered
in
England and Wales, registered number 02452736, VAT number GB 645 4205
50
[Colt Disclaimer] The message is intended for the named addressee only
and may
not be disclosed to or used by anyone else, nor may it be copied in
any way.
The contents of this message and its attachments are confidential and
may also
be subject to legal privilege. If you are not the named addressee
and/or have
received this message in error, please advise us by e-mailing
user-51905b889b93@xymon.invalid<mailto:user-51905b889b93@xymon.invalid> and delete the message and any
attachments without retaining any copies. Internet communications are
not
secure and Colt does not accept responsibility for this message, its
contents
nor responsibility for any viruses. No contracts can be created or
varied on
behalf of Colt Technology Services, its subsidiaries, group companies
or
affiliates ("Colt") and any other party by email communications unless
expressly agreed in writing with such other party. Please note that
incoming
emails will be automatically scanned to eliminate potential viruses
and
unsolicited promotional emails. For more information refer to
www.colt.net<http://www.colt.net>; or contact us on +44(0)20 7390 3900