I have a plain text file with tabbed information inside which looks as follows
ADVMONITOR "WINOSSPI-RPCService-Win2k"
DESCRIPTION "Checks the 'Remote Procedure Call (RPC)' Windows 2000 service and its corresponding process"
INTERVAL "5m2s"
SCRIPTTYPE "VBScript"
MULTISOURCE
INSTANCEMODE ONCE
MAXTHRESHOLD
SEPARATORS " "
ICASE
PROGRAM "Process"
DESCRIPTION "Returns the number of running 'svchost.exe' processes;"
MONPROG "opcntprocs.exe WINOSSPI-RPCService-Win2k-Process svchost"
PROGRAM "Service"
DESCRIPTION "Returns values that correspond to different states of the service 'RPC Service'"
MONPROG "opcntservice_chk.bat RpcSs WINOSSPI-RPCService-Win2k-Service"
MSGCONDITIONS
INSTANCERULE "Combined Service and Process Monitor; suppress messages caused by same case;"
ID "d5ca6823-37d4-4581-886a-2aad3462d9e0"
DESCRIPTION "Checks the services and processes"
CONDITION_ID "0cdb88dd-0338-47d3-a5f5-e4d982e8a1a9"
CONDITION
And what I need is to get the information from each different block on a way that I can import such information into a db, but I cannot get a nice iteration through the different blocks to get the right data from each block on a nice and identifiable manner.
I tried identify the blocks as per the tabs using a class named tabbedLinesTree
, this converts all tabbed text into XML, which is useful as well, but the different fields aren't showed with fields name or any other way to identify which block are we going through.
Resuming... I'd like to go thru that file and get (as an example) for each PROGRAM
block an array with the PROGRAM
name, the DESCRIPTION
and the MONPROG
for that block...
Not sure how to conceptualize this, can you please help me out on this with any idea?
I'm good at PHP, but can implement any other solution if needed.
Ps: some blocks can have more tabs or more fields (lines) of information.
--- BELOW TEXT ADDED AFTER NIGEL'S ANSWER ---
Second text example...
SYNTAX_VERSION 5
LOGFILE "OvSvcDiscErrorLog"
DESCRIPTION "Self-Management OvService Discovery agent error log"
LOGPATH "<OvSvcDiscErrorLog>"
INTERVAL "5m"
CHSET ASCII
FROM_LAST_POS
NO_LOGFILE_MSG
CLOSE_AFTER_READ
SEPARATORS " "
MSGCONDITIONS
DESCRIPTION "[E01-001] EXCEPTION while installing policy"
SUPP_DUPL_IDENT "3m"
COUNTER_THRESHOLD 0
CONDITION_ID "17adc1d1-32cf-42ca-be5f-1cf784f19026"
CONDITION
TEXT "<*> \\[E01-001\\] EXCEPTION while installing policy <*.polname>" SEPARATORS " "
SET
SEVERITY Critical
APPLICATION "OVO/Win"
MSGGRP "OVO"
OBJECT "OvSvcDiscAgent"
TEXT "[E01-001]EXCEPTION while installing policy "`