1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ___ _ |
5
|
|
|
* | _ \ __ _ _ _ ___ ___ | | ___ __ _ |
6
|
|
|
* | _// _` || '_|(_-</ -_)| |/ _ \/ _` | |
7
|
|
|
* |_| \__,_||_| /__/\___||_|\___/\__, | |
8
|
|
|
* |___/ |
9
|
|
|
* |
10
|
|
|
* (c) Kristuff <[email protected]> |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please view the LICENSE |
13
|
|
|
* file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* @version 0.2.0 |
16
|
|
|
* @copyright 2017-2020 Kristuff |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Kristuff\Parselog\Software; |
20
|
|
|
|
21
|
|
|
use Kristuff\Parselog\Core\LogEntryFactoryInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Aug 15 10:39:01 domain CRON[25038]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi) |
25
|
|
|
*/ |
26
|
|
|
class SyslogParser extends SoftwareLogParser |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Constructor |
30
|
|
|
* |
31
|
|
|
* @access public |
32
|
|
|
* @param string $format |
33
|
|
|
* @param LogEntryFactoryInterface $factory |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function __construct(string $format = null, LogEntryFactoryInterface $factory = null) |
38
|
|
|
{ |
39
|
|
|
$this->software = 'Syslog'; |
40
|
|
|
$this->prettyName = 'Syslog'; |
41
|
|
|
|
42
|
|
|
$this->addFormat('default', '%t %h %s %m'); |
43
|
|
|
$this->defaultFormat = '%t %h %s %m'; |
44
|
|
|
|
45
|
|
|
$this->addPath("/var/log/"); |
46
|
|
|
$this->addFile("syslog"); |
47
|
|
|
//todo |
48
|
|
|
|
49
|
|
|
$this->addColumn('%t', 'time', 'Date', '(?P<time>(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2} \d{2}:\d{2}:\d{2})'); |
50
|
|
|
$this->addColumn('%h', 'hostaname', 'Hostname', '(?P<hostname>.+?)'); |
51
|
|
|
$this->addColumn('%s', 'service', 'Service', '(?P<service>(\S+|\[\d+\])):'); |
52
|
|
|
$this->addColumn('%m', 'message', 'Message', '(?P<message>.+)'); |
53
|
|
|
|
54
|
|
|
parent::__construct($format, $factory); |
55
|
|
|
} |
56
|
|
|
} |