Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created February 5, 2014 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ableasdale/8824644 to your computer and use it in GitHub Desktop.
Save ableasdale/8824644 to your computer and use it in GitHub Desktop.
Extracting information from the Sysinternals "Process Monitor" tool and inserting selected nodes into MarkLogic
xquery version "1.0-ml";
(:
Step 1
Get the necessary data - around the two times where we see Journal Errors getting logged.
To extract all the nodes from the text files,
do something like this on the Performance Monitor output files:
grep -B3 -A7 "of_Day>8:48:54" Logfile-scrubbed > cut3.txt
grep -B3 -A7 "of_Day>7:34:28" Logfile-scrubbed > cut4.txt
:)
(:
Step 2
Parse the textfile as XML and then insert all nodes
declare variable $ele := <events>{xdmp:document-get("C:\tmp\cut4.txt",
<options xmlns="xdmp:document-get" xmlns:http="xdmp:http">
<format>xml</format></options>)}</events>;
for $e at $pos in $ele/event
return xdmp:document-insert($pos cast as xs:string, $e) :)
(: Step 3 - write out the XML doc containing just the nodes we're interested in :)
xdmp:save("C:\tmp\0734.xml",
<events>{
for $x in (//Path)
where contains($x, "PROJECT-HOSTNAME-1\Journals")
order by fn:number(xdmp:node-uri($x))
return doc(xdmp:node-uri($x))/node()
}</events>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment