forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsyslog.php
More file actions
executable file
·29 lines (23 loc) · 741 Bytes
/
Copy pathsyslog.php
File metadata and controls
executable file
·29 lines (23 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env php
<?php
/**
* LibreNMS
*
* This file is part of LibreNMS.
*
* @copyright (C) 2006 - 2012 Adam Armstrong
*/
$init_modules = [];
require __DIR__ . '/includes/init.php';
$keys = ['host', 'facility', 'priority', 'level', 'tag', 'timestamp', 'msg', 'program'];
// one processor for the life of this process, so its caches survive between messages
$processor = new LibreNMS\Syslog\Processor();
$s = fopen('php://stdin', 'r');
while ($line = fgets($s)) {
// Log::channel('log_file')->critical($line); // uncomment to log input to librenms.log
$fields = explode('||', trim($line));
if (count($fields) === 8) {
$processor->process(array_combine($keys, $fields));
}
unset($line, $fields);
}