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 03:04:49 -0800
Message-ID: <1112353489.330650.177420@l41g2000cwc.googlegroups.com>

Jack wrote:
> "Rauf Sarwar" <rs_arwar_at_hotmail.com> wrote in message
> news:1112345716.452938.165260_at_o13g2000cwo.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
> >
> > Don't pipe it to grep. Let the whole thing come thru the
InputStream
> > then do simple string parsing. e.g.
> >
> > while ((a = br.readLine()) != null) {
> > if (a.toLowerCase().startsWith("processors:"))
> > ....
> > }
> >
> > Or put the whole thing in the String[] buffer and work with that.
> >
> > Regards
> > /Rauf
> >
> Hi!

>

> Sorry my bad java, how would this goes?
>

> while ((a = br.readLine()) != null) {
> if (String.Compare(a.Substring(6,10), "oracle.exe") == 1
)
> sb.append(a.Substring(1,4) + "\n");
>

> Jack

If you want to program in java then I suggest you download java docs from java.sun.com.

First of all... Unlike PLSQL, java is case sensitive. Almost all java function names are either all lower case or start with a lowercase and then mixed case e.g. substring() or compareTo() etc. You have to use proper case when calling functions in java.

Secondly... If you want to take substring of a String and see if it compares to another String then,
if (a.substring(6, 10).compareTo("oracle.exe") == 0) Above will fail because substring in java works differently then in PLSQL. Both parameters to substring are offsets in String rather then start at 6 and go across 10 spaces as in PLSQL.

Best thing would be to download java docs and ask in comp.lang.java about other good java resources (URL, Books etc) also.

Regards
/Rauf Received on Fri Apr 01 2005 - 05:04:49 CST

Original text of this message

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