Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Hardware info from Oracle server?

Re: Hardware info from Oracle server?

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 1 Apr 2005 01:18:14 -0800
Message-ID: <1112347093.969993.279220@f14g2000cwb.googlegroups.com>

Jack wrote:
> "Rauf Sarwar" <rs_arwar_at_hotmail.com> wrote in message
> news:1112319934.955222.4860_at_l41g2000cwc.googlegroups.com...
> >
> > jackzhunj_at_gmail.com wrote:
> >> Is there any way I can get Oracle machine information (# of CPUs,
> > RAM,
> >> etc) from some Oracle system views or calling some Oracle
packages?
> >> (Oracle 9iR2)
> >>
> >> Thanks a lot!
> >
> > I don't know of any system view/package but if you have JServer
> > installed then you can use java stored procedure and a PLSQL
wrapper
> > function. I use psinfo.exe from www.sysinternals.com in my example
on
> > Windows to get system info. psinfo.exe must be in system path.
> >
> > SQL> create or replace and compile java source
> > 2 named "SysInfo"
> > 3 as
> > 4
> > 5 import java.io.*;
> > 6
> > 7 public class SysInfo {
> > 8
> > 9 public static String getInfo ()
> > 10 throws Exception {
> > 11
> > 12 Runtime r = Runtime.getRuntime();
> > 13 Process p = r.exec("psinfo.exe");
> > 14 BufferedReader br
> > 15 = new BufferedReader(new
> > InputStreamReader(p.getInputStream()));
> > 16 p.waitFor();
> > 17 String a;
> > 18 StringBuffer sb = new StringBuffer();
> > 19 while ((a = br.readLine()) != null) {
> > 20 sb.append(a + "\n");
> > 21 }
> > 22 br.close();
> > 23 return sb.toString();
> > 24 }
> > 25 }
> > 26 /
> >
> > Java created.
> >
> > SQL> create or replace function foo return varchar2
> > 2 is
> > 3 language java name 'SysInfo.getInfo() return java.lang.String';
> > 4 /
> >
> > Function created.
> >
> > SQL> set heading off
> > SQL> select foo from dual;
> >
> > System information for \\RASA:
> > Uptime: 0 days 3 hours 26 minutes 42 seconds
> > Kernel version: Microsoft Windows XP, Uniprocessor Free
> > Product type: Professional
> > Product version: 5.1
> > Service pack: 1a
> > Kernel build number: 2600
> > Registered organization:
> > Registered owner: RASA
> > Install date: 07/02/2004, 02:31:27
> > Activation status: Activated
> > IE version: 6.0000
> > System root: C:\WINDOWS
> > Processors: 1
> > Processor speed: 600 MHz
> > Processor type: Intel(R) Pentium(R) M processor
> > Physical memory: 1022 MB
> > Video driver: ATI MOBILITY RADEON 7500
> >
> > You can easily parse the return string.
> >
> > Regards
> > /Rauf
> >
> Hi!

>
>

> If I put
> Process p = r.exec("psinfo.exe | grep Processors:");
>

> It will give:
> ERROR at line 1:
> ORA-24345: A Truncation or null fetch error occurred
> ERROR:
> ORA-01002: fetch out of sequence
>

> How to fix it?

>
> Jack

Furhthermore... Pipe or Redirect is a function of the DOS or Unix shells like bash etc. If you want to do redirect then you have to do it inside cmd.exe. e.g this is untested.

r.exec("cmd /c psinfo.exe | grep Processors:")

Otherwise you already have a handle to stdin, stdout, stderr via Process streams.

Regards
/Rauf Received on Fri Apr 01 2005 - 03:18:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US