Jump to content

XML mit Logparser verwerten


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Empfohlene Beiträge

Geschrieben (bearbeitet)

Hallo zusammen,

 

ich kämpfe seid einiger Zeit mit der Auswertung von XML-Daten, und bekomme keine passende Lösung. Hoffentlich kann mir hier einer helfen!

Es geht um die Auswertung von virtuellen und physikalischen Hosts.

 

Meine XML-Datei sieht folgendermaßen aus:

 

<?xml version='1.0' encoding="UTF-8" standalone='yes'?>
<message>
<table name="server_table" >
<row><col col_name="Hostname" col_id="u.hostname" >p_host1</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host1</col>
<col col_name="status" col_id="u.status" >running</col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" >p_host1</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host2</col>
<col col_name="status" col_id="u.status" >running</col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" >p_host2</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host1</col>
<col col_name="status" col_id="u.status" >configured</col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" p_host2</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host2</col>
<col col_name="status" col_id="u.status" >configured</col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" >p_host2</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host3</col>
<col col_name="status" col_id="u.status" >running</col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" >p_host3</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" >v_host4</col>
<col col_name="status" col_id="u.status" ></col>
<col col_name="Server: data2" col_id="u.data2" >data2</col>
</row>
<row><col col_name="Hostname" col_id="u.hostname" >p_host4</col>
<col col_name="Server: data1" col_id="u.data1" >data1</col>
<col col_name="name" col_id="u.name" ></col>
<col col_name="status" col_id="u.status" ></col>
<col col_name="Server: data2" col_id="u.data2" ></col>
</row>
</table>
</message>

 

 

Als Endergebnis wünsch ich mir zwei Ausgaben:

1. Ausgabe in einer passenden Tabelle, wie:

  

u.hostname   u.name      u.status

------------ ------------ ------------

p_host1      v_host1     running

p_host1      v_host2     running

p_host2      v_host1     configured

p_host2      v_host2     configured

p_host2      v_host3     running

p_host3      v_host4

p_host4    

 

2. Die Ausgabe von "u.hostname" (physikalischer Host) auf der die gegebene "u.name" (virtueller Host) im Status ("u.status")  'running" ist.

Dies erledige ich dann durch dynamische Anpassung der SQL-Query - per Variable...

z.B. :

Eingabe: v_host1   Ausgabe: p_host1

Eingabe: v_host3   Ausgabe: p_host2

Eingabe: v_host4   Ausgabe: ' ' (leer)

 

Bisher habe ich eine Query, die der oben gezeigten Tabelle ansatzweise gleicht, aber ich komme nicht weiter...

 

- Meine Logparser-Kommandozeile lautet: logparser -i:XML -fNames:XPath -fMode:Auto -rootXPath:/message/table/row file:query.sql -o:datagrid

- Inhalt von query.sql:

select
  max(case 'u.hostname' when /row/col/@col_id THEN /row/col ELSE '' END) AS u.hostname,
  max(case 'u.name' when /row/col/@col_id THEN /row/col ELSE '' END) AS u.name,
  max(case 'u.status' when /row/col/@col_id THEN /row/col ELSE '' END) AS u.status
from D:\test\data.xml
group by /row/col

 

 

Ich hoffe auf eure Hilfe! :)

files.zip

bearbeitet von novabyte
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...