.
├── src
│ └── MetricParser.php # Parser class file
├── examples
│ └── example.php # Use example
├── LICENSE.txt # License
└── README.md # This text
$parser = new hpom\MetricParser($rawMetric);
$array = $parser->parse();
Where $rawMetric
must be a string contains value of policy_body
field of opc_op.opc_policy_body
table.
- All tags with inner content parsed as array with two keys
[ '_value' => '', 0 => [ ] ]
, even if they don't have explicit value. In this case element with key_value
set to empty string. Element with key0
contains inner content. SeeLOGFILE
andMSGCONDITIONS
tags. - Repeatable sequences are determined by the first level tag. See
MSGCONDITIONS
. Start of each sequence are determined by tagDESCRIPTION
.
Input text
SYNTAX_VERSION 5
LOGFILE "online_log"
DESCRIPTION "log online.log"
LOGPATH "/usr/LOGS/online.log"
INTERVAL "5m"
CHSET ASCII
FROM_LAST_POS
SEVERITY Critical
NODE IP 172.1.1.1 "server.address"
APPLICATION "DB"
MSGGRP "Informix"
OBJECT "OnlineLog"
MSGCONDITIONS
DESCRIPTION "out of virtual"
CONDITION_ID "405966b8-fcd0-71e1-0c09-ac19be040000"
CONDITION
TEXT "out of virtual"
SET
SEVERITY Critical
MSGTYPE "sms"
TEXT "<$LOGFILE>: <$MSG_TEXT>"
NOTIFICATION
DESCRIPTION "Server Stopped"
CONDITION_ID "4059678a-fcd0-71e1-0c09-ac19be040000"
CONDITION
TEXT "Server Stopped"
SET
SEVERITY Critical
MSGTYPE "sms"
TEXT "<$LOGFILE>: <$MSG_TEXT>"
NOTIFICATION
Output array
array (
'SYNTAX_VERSION' => '5',
'LOGFILE' =>
array (
'_value' => 'online_log',
0 =>
array (
'DESCRIPTION' => 'log online.log',
'LOGPATH' => '/usr/LOGS/online.log',
'INTERVAL' => '5m',
'CHSET' => 'ASCII',
'FROM_LAST_POS' => '',
'SEVERITY' => 'Critical',
'NODE' => 'IP 172.1.1.1 "server.address',
'APPLICATION' => 'DB',
'MSGGRP' => 'Informix',
'OBJECT' => 'OnlineLog',
'MSGCONDITIONS' =>
array (
'_value' => '',
0 =>
array (
0 =>
array (
'DESCRIPTION' => 'out of virtual',
'CONDITION_ID' => '405966b8-fcd0-71e1-0c09-ac19be040000',
'CONDITION' =>
array (
'_value' => '',
0 =>
array (
'TEXT' => 'out of virtual',
),
),
'SET' =>
array (
'_value' => '',
0 =>
array (
'SEVERITY' => 'Critical',
'MSGTYPE' => 'sms',
'TEXT' => '<$LOGFILE>: <$MSG_TEXT>',
'NOTIFICATION' => '',
),
),
),
1 =>
array (
'DESCRIPTION' => 'Server Stopped',
'CONDITION_ID' => '4059678a-fcd0-71e1-0c09-ac19be040000',
'CONDITION' =>
array (
'_value' => '',
0 =>
array (
'TEXT' => 'Server Stopped',
),
),
'SET' =>
array (
'_value' => '',
0 =>
array (
'SEVERITY' => 'Critical',
'MSGTYPE' => 'sms',
'TEXT' => '<$LOGFILE>: <$MSG_TEXT>',
'NOTIFICATION' => '',
),
),
),
),
),
),
),
)