Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: constant monitoring and enqueues?
Whoops, thanks for the link error info. It should work now.
I also started writing a monitor in JAVA just to play with JAVA but my mind just doesn't work like that and TCL/TK is easy so I did it in TCL/TK. Accessing the SGA directly is rarely done by anyone. Oracle Corp has no products that do it. One guy in particular at Oracle wrote an amaizing program that accessed the SGA directly over many versions of Oracle 7.0-8.0 but this he did on his own. One of the big problems of writing the program is having it work across versions and platforms. There is no way to do SGA direct access on NT as far as I know. You'd actually have to compile code into ORacle and have a separate thread. ON UNIX, the SGA is accessible by anyone who has the right UNIX permissions. Anyway it's hardly worth doing for most people unless you are a firefighter and that is all you do. Without knowledge of the underlying C structure we don't know the widths of the fields in the structure. Oracle often packs alot of bit flags into the same C-code integer variable, but a describe of the X$table doesn't say they are bit fields; it says they are numbers. So if we start at address X for field A, which is actually a bit value, and then try to find field B which is also a bit value, assuming we skip a byte to find the next "number" we have gone too far since A and B are bit values and only 1 bit wide, so B is at X+1 not X+8. It gets all the more complicated with pointers and longs and characters and 64 bit archictecture etc, but of course if we have access to the source this is easy. IT is great for times when the system is so heavly loaded no SQL works, but hopefully that isn't a situation most people get into. One thing accessing the SGA gives sometimes is access to data that wouldn't otherwise be externalized. I know people have used x$ksmem to get OPS lock info that wwould not otherwise be accessible. X$ksmmem allows you to get SGA data at any SGA address, but unless you have access to ORacle source code its hard to find out what is where and generally not worth the headache. So the long and short of it is SGA can only be accessed on UNIX by a process running on the UNIX box and hardly anyone out there does it, not even Oracle, but there are a few 3rd party tools apparently.
Best
Kyle
In article <979300578.8175.0.nnrp-07.c30bdde2_at_news.demon.co.uk>,
"andrew_webby at hotmail" <spam_at_no.thanks.com> wrote:
> Thanks Kyle.
>
> I know nothing of TCL either, but went to look at your web page and
was
> intrigued by the screenshot there. Tried to download the linux version
> (which no doubt I could adapt - if need be - for Solaris), but the
link
> wasn't found?
>
> All this looking directly into the SGA scares me, so it's not an
avenue I'm
> likely to explore.
>
> However, there is the question of how my running, for example,
Instance
> Monitor on my NT workstation can query the SGA on my Solaris box
(assuming
> that's what's going on...)?
>
> Andrew
>
> <hailey_kyle_at_my-deja.com> wrote in message
> news:93lo2k$9k0$1_at_nnrp1.deja.com...
> > Yeah, I like Instance Monitor. I wanted to be able to customize
it
> > so I put some of the funcionality together with TCL/TK on
> >
> > http://www.geocities.com/oraperf/oramon.html
> >
> > I sample every 10 seconds or so without any problem. It all depends
> > what you look at and what state the system is in.
> >
> > For some ideas on monitoring see:
> > http://www.geocities.com/oraperf/seminar/collect.html
> >
> > As far as accessing the SGA directly here is previous response I
sent
> > inside oracle:
> >
> >
> > Received: Sent: OCTOBER 20,
> > 1997 17:48
> > From: KHAILEY.FR.ORACLE.COM <KHAILEY.FR.ORACLE.COM>
> > Subject: Re: Precise/SQL
> >
> > Yeah, it looks pretty curious to me. I imagine its the same
> > story as SQL*TRAX where some x-oracle developers left and started a
> > company that read the redo logs. Of course they already new the
> > internal structure of the redo logs.
> >
> > It is possible of course that someone could write this from
> > scratch, but "Oscams Raisor's" would say that these people either
> > worked for Oracle or have a freind at Oracle who could answer some
key
> > questions. (My only question is why doesn't Oracle Corp provide
these
> > kind of tools at least to Oracle consultants, but then again Oracle
> > Corp is doing fine without them on the competative terain)
> >
> > How does a program like this work? Well Roger Saunders in the
> > UK who came up with the idea/program back in 1991 to sample the SGA
> > could probably explain it the best, but maybe as a rather neophyte
> > programer, I can provide a simple perspective.
> >
> > 1) The program needs to attach to the SGA. On Unix you need the
> > address and id of the shared memory segment to attach the segment
(and
> > permissions). The address and id can be gotten from the sgadef file,
> > whose structure is not too complicated, but a little help would go
> > along way.
> > On NT it sounds like a whole other ballgame.
> >
> > 2) The program needs to know where to get the information in
> > the SGA. This is pretty easy for X$ tables. The X$ table have an
> > address column which is the SGA memory address, so you just run a
> > preliminary sql statement to get the address of the first row of the
> > X$table. Once you have this address you run your C program to
attach to
> > the SGA and then read the data out of the address corresponding to
the
> > X$ table.
> >
> > 3) Its not that easy though. The x$ tables represent structures
> > in the C code. The x$ tables are just an externalisation of the
> > underlying C structure. The trick is, not all the contents of the
> > structure are externalised in the X$ table. So if one were reading
the
> > X$ table from the SGA they would expect field 2 to be next to field
1
> > in memory. Well maybe in the C structure there are several other
values
> > between the field 1 and field 2 that are not externised into the
> > X$table, so instead of finding field 2 we see some other value that
> > supposididly since we don't have access to the code, we don't
> > know what it is. Example
> >
> > strucutre foo
> > int id
> > int A
> > int B
> >
> > if struct foo is externalised as an x$ table with only B visible
then
> > we get
> >
> > desc x$foo
> > Column Name Null? Type
> > ------------------------------ -------- ----
> > ADDR RAW(8)
> > INDX NUMBER
> > ID NUMBER
> > B NUMBER
> >
> > select * from x$foo;
> > ADDR INDX ID B
> > ---------------- ---------- ---------- ----------
> > 000000000082E640 1 1 81
> > 000000000082E648 2 1 81
> > 000000000082E650 3 1 81
> >
> > address
> > 82E640
> > ||
> > \/
> > we expect:
> > ------------------------------------------------------------
Sent via Deja.com
http://www.deja.com/
Received on Fri Jan 12 2001 - 12:47:16 CST