GithubHelp home page GithubHelp logo

hpommetricsparser's Introduction

Class for parse HP OpenView Operations Manager metrics

License: MIT PHP: 7.0

Project structure

.
├── src
│   └── MetricParser.php      # Parser class file 
├── examples
│   └── example.php           # Use example
├── LICENSE.txt               # License
└── README.md                 # This text

Using

$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.

Rules

  1. 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 key 0 contains inner content. See LOGFILE and MSGCONDITIONS tags.
  2. Repeatable sequences are determined by the first level tag. See MSGCONDITIONS. Start of each sequence are determined by tag DESCRIPTION.

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' => '',
              ),
            ),
          ),
        ),
      ),
    ),
  ),
)

hpommetricsparser's People

Contributors

rjhdby avatar

Watchers

 avatar

Forkers

fizek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.