Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

mobiletulip/php-logparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple logfile parser for kannel SMPP logfiles that sends statistics to Graphite

Running the parser:

$ php parse.php --xml sample.xml

A simple cron script example parser:

$basePath = dirname(__DIR__);
require_once $basePath . '/lib/Parser.php';

$script = array_shift($argv);
$switch = array_shift($argv);
$xmlConfig = array_shift($argv);

try {
    $parser = LogParser::getInstance($xmlConfig);
    $parser->run();
} catch(Exception $e) {
    echo $e->getMessage();
}

Where ../config/sample.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <!-- With debugging enabled no data will be send to Graphite but instead pushed to stdout -->
    <debug>false</debug>
    
    <!-- Push output to stdout -->
    <verbose>true</verbose>
    
    <!-- Location where we should store the state file -->
    <state_file>/state/file/location.state</state_file>
    
    <!-- Location of the logfile -->
    <log_file>/log/file/location.log</log_file>
    
    <!-- Location of the logtail2 binary -->
    <logtail_bin>/usr/sbin/logtail2</logtail_bin>
    
    <!-- Regular expression to parse logfile lines -->
    <regexp>/^(\S+) (\S+) (\S+) FAILED .*/</regexp>
    
    <!-- The regex field number to use for graphite stats -->
    <regex_num>3</regex_num>
    
    <!-- Graphite settings -->
    <graphite>
        <enabled>true</enabled>
        <label>graphite.stats.string</label>
        <host>localhost</host>
        <port>2003</port>
        <timeout>30</timeout>
    </graphite>
</config>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages