Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop though all roots

Status
Not open for further replies.

vuacorona

IS-IT--Management
Jul 18, 2002
2
US
Hello ALL:

I need to use powershell to loop through all root nodes, and in each root search for type='INCEDENT_ERROR'.

Would you guide me how to start with powershell.

Thank you very much.
-andy

----------------------------------
Here is input sample.

<msg time='2010-04-02T19:26:28.468-07:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='SCRDCPKRNDB01C' host_addr='192.168.0.171' module='sqlplus.exe'
pid='4760' version='1'>
<txt>ALTER SYSTEM SET diagnostic_dest=&apos;J:\ORACLE&apos; SCOPE=BOTH;
</txt>
</msg>
<msg time='2010-04-02T19:44:50.972-07:00' org_id='oracle' comp_id='rdbms'
msg_id='ksb_shut_detached_process:2876:3107995654' client_id='' type='NOTIFICATION'
group='process end' level='16' host_id='SCRDCPKRNDB01C'
host_addr='192.168.0.171' module='sqlplus.exe' pid='4760'>
<txt>Stopping background process MMON
</txt>
</msg>
<msg time='2010-08-25T19:02:54.315-07:00' org_id='oracle' comp_id='rdbms'
msg_id='1257497642' type='INCIDENT_ERROR' group='Out of Memory'
level='1' host_id='SCRDCPKRNDB01C' host_addr='192.168.0.171'
prob_key='ORA 4031' upstream_comp='' downstream_comp='KGH'
ecid='' errid='691650' detail_path='J:\ORACLE\diag\rdbms\wfcprod\wfcprod\trace\wfcprod_m001_1000.trc'>
<attr name='IMPACT' value='POSSIBLE INSTANCE FAILURE'/>
<txt>Errors in file J:\ORACLE\diag\rdbms\wfcprod\wfcprod\trace\wfcprod_m001_1000.trc (incident=691650):
ORA-04031: unable to allocate 3936 bytes of shared memory (&quot;shared pool&quot;,&quot;insert into WRH$_RSRC_CONSUM...&quot;,&quot;sga heap(2,0)&quot;,&quot;kglsim object batch&quot;)
</txt>
</msg>
 
Is this supposed to be xml? Multiple roots are not valid for xml are they?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Suppose it comes as a text file, xyz.txt, with path if needed, one form to get them can look like this.
[tt]
[green]#source string $s, got one way or another
$s=get-content xyz.txt[/green];

$xdoc=[xml]("<root>"+$s+"</root>");
$nodelist=$xdoc.SelectNodes("//msg");
foreach ($node in $nodelist) {
$v=$node.GetAttribute('type');
write-host ("Attribute @type="+$v);
}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top