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....
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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 |
| |||
| "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 |
| |||
| 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 |
| |||
| 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. > > |
| |||
| "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 |
| |||
| > 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" <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 |