Unix Technical Forum

is there a way to get the server MAC address through sql statement ?

This is a discussion on is there a way to get the server MAC address through sql statement ? within the Oracle Database forums, part of the Database Server Software category; --> Any clue appreciated ! Thanks. B....


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 07:15 AM
Benoit Delalande
 
Posts: n/a
Default is there a way to get the server MAC address through sql statement ?

Any clue appreciated !

Thanks.

B.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 07:15 AM
Kenneth Koenraadt
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

On Wed, 25 Feb 2004 18:15:50 +0100, "Benoit Delalande"
<b.delalandeNO@SPAMopsio.fr> wrote:

>Any clue appreciated !
>
>Thanks.
>
>B.
>
>


Hi B,

An Oracle DB does not hold information about MAC adresses and other
low-level server information in it's data dictionary.

You could load some hardware detecting Java Classes into the DB.

But if you really need to store hardware info in the DB, I think the
simplest and best solution is to write a small application to load
Hardware info into a User table in the DB.


- Kenneth Koenraadt

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-23-2008, 07:16 AM
Paul Drake
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

"Benoit Delalande" <b.delalandeNO@SPAMopsio.fr> wrote in message news:<c1il9s$pma$1@apollon.grec.isp.9tel.net>...
> Any clue appreciated !
>
> Thanks.
>
> B.


if you write the entire database/app in assembler, it should not be a problem.

Pd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-23-2008, 07:16 AM
srivenu
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

Try this out.
I tested it out on 2000 you need to make some changes for Unix.
I had taken the basic concept from ASKTOM.

create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;

public class Util extends Object
{

public static int RunThis()
{
Runtime rt = Runtime.getRuntime();
int rc = -1;

try
{
Process p = rt.exec("arp -a");

int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];

// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);

rc = p.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
}
finally
{
return rc;
}
}
}
/


create or replace
function RUN_CMD return number
as
language java
name 'Util.RunThis() return integer';
/

create or replace procedure RC
as
x number;
begin
x := run_cmd;
end;
/


set serveroutput on size 1000000
exec dbms_java.set_output(1000000)
exec rc;

regards
Srivenu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-23-2008, 07:17 AM
Niall Litchfield
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

select '00-B4-C2-0F-01-C2' from dual;



--
Niall Litchfield
Oracle DBA
Audit Commission UK
"Benoit Delalande" <b.delalandeNO@SPAMopsio.fr> wrote in message
news:c1il9s$pma$1@apollon.grec.isp.9tel.net...
> Any clue appreciated !
>
> Thanks.
>
> B.
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-23-2008, 07:20 AM
Douglas Hawthorne
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

"srivenu" <srivenu@hotmail.com> wrote in message
news:1a68177.0402260208.72882f33@posting.google.co m...
> Try this out.
> I tested it out on 2000 you need to make some changes for Unix.
> I had taken the basic concept from ASKTOM.
>
> create or replace and compile
> java source named "Util"
> as
> import java.io.*;
> import java.lang.*;
>
> public class Util extends Object
> {
>
> public static int RunThis()
> {
> Runtime rt = Runtime.getRuntime();
> int rc = -1;
>
> try
> {
> Process p = rt.exec("arp -a");
>
> int bufSize = 4096;
> BufferedInputStream bis =
> new BufferedInputStream(p.getInputStream(), bufSize);
> int len;
> byte buffer[] = new byte[bufSize];
>
> // Echo back what the program spit out
> while ((len = bis.read(buffer, 0, bufSize)) != -1)
> System.out.write(buffer, 0, len);
>
> rc = p.waitFor();
> }
> catch (Exception e)
> {
> e.printStackTrace();
> rc = -1;
> }
> finally
> {
> return rc;
> }
> }
> }
> /
>
>
> create or replace
> function RUN_CMD return number
> as
> language java
> name 'Util.RunThis() return integer';
> /
>
> create or replace procedure RC
> as
> x number;
> begin
> x := run_cmd;
> end;
> /
>
>
> set serveroutput on size 1000000
> exec dbms_java.set_output(1000000)
> exec rc;
>
> regards
> Srivenu


Srivenu,

The problem with this code is that it returns the wrong answer even if you
added extra code to extract the MAC address from the output stream. The
"arp -a" command may return some or all of the MAC addresses of the server's
neighbours on a LAN segment but not the MAC address of its interface card.
If you want to use this method, employ the "ipconfig /all" command for
Windows, or the "ifconfig -a" command for Linux.

Niall's solution is better because the only time the MAC address changes is
when the hardware changes through a new network interface card (NIC).

A question for the OP: why? I am curious to know the business requirement
for such a request.

Douglas Hawthorne


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-23-2008, 07:22 AM
srivenu
 
Posts: n/a
Default Re: is there a way to get the server MAC address through sql statement ?

> The problem with this code is that it returns the wrong answer even if you
> added extra code to extract the MAC address from the output stream. The
> "arp -a" command may return some or all of the MAC addresses of the server's
> neighbours on a LAN segment but not the MAC address of its interface card.
> If you want to use this method, employ the "ipconfig /all" command for
> Windows, or the "ifconfig -a" command for Linux.


Douglas,
I think ifconfig -a on Solaris will return the MAC address only if run as root.
i think you can use arp `hostname` to get the MAC for the server.
regards
Srivenu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-23-2008, 07:28 AM
Douglas Hawthorne
 
Posts: n/a
Default Re: [OT] is there a way to get the server MAC address through sql statement ?

"srivenu" <srivenu@hotmail.com> wrote in message
news:1a68177.0402292343.2e4f7ce0@posting.google.co m...
> > The problem with this code is that it returns the wrong answer even if

you
> > added extra code to extract the MAC address from the output stream. The
> > "arp -a" command may return some or all of the MAC addresses of the

server's
> > neighbours on a LAN segment but not the MAC address of its interface

card.
> > If you want to use this method, employ the "ipconfig /all" command for
> > Windows, or the "ifconfig -a" command for Linux.

>
> Douglas,
> I think ifconfig -a on Solaris will return the MAC address only if run as

root.
> i think you can use arp `hostname` to get the MAC for the server.
> regards
> Srivenu


Srivenu,

This is no longer an Oracle question.

On the SUNOS 5.8 system I have access to, neither the arp nor the ifconfig
commands are available to the non-administrators.

In some cases, it is possible to get the MAC address via arp x.x.x.x
command. IF you are running the command on a host that is on the same LAN
segment as the Oracle server AND IF that host IS NOT the Oracle server, then
the command will return the MAC address of the server.

However, running the arp command on the Oracle server does not return the
MAC address for the server itself. The purpose of ARP (see RFC 826) is to
translate an IP address into a MAC address so that the sender can transmit
the message over the LAN segment. If the IP address is that of the sender,
then there is no need to do a translation because the TCP/IP stack knows its
own set of IP addresses. Thus, it will avoid the overhead of sending a
message over the LAN segment to itself.

Douglas Hawthorne


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com