-
Notifications
You must be signed in to change notification settings - Fork 91
/
syslog.php
executable file
·51 lines (43 loc) · 1.43 KB
/
syslog.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env php
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage syslog
* @author Adam Armstrong <[email protected]>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
chdir(dirname($argv[0]));
$scriptname = basename($argv[0]);
include_once("includes/sql-config.inc.php");
// Disable sql profiling, this is a background process without any way to display it
$config['profile_sql'] = FALSE;
$i = 1;
if (isset($config['syslog']['fifo']) && $config['syslog']['fifo'] !== FALSE)
{
// FIFO configured, try to grab logs from it
#echo 'Opening FIFO: '.$config['syslog']['fifo'].PHP_EOL; //No any echo to STDOUT/STDERR!
$s = fopen($config['syslog']['fifo'], 'r');
} else {
// No FIFO configured, take logs from stdin
#echo 'Opening STDIN'.PHP_EOL; //No any echo to STDOUT/STDERR!
$s = fopen('php://stdin', 'r');
}
while ($line = fgets($s))
{
if (isset($config['syslog']['debug']) && $config['syslog']['debug'])
{
// Store RAW syslog line into debug.log
logfile('debug.log', $line);
}
// host || facility || priority || level || tag || timestamp || msg || program
list($entry['host'], $entry['facility'], $entry['priority'], $entry['level'], $entry['tag'], $entry['timestamp'], $entry['msg'], $entry['program']) = explode("||", trim($line));
process_syslog($entry, 1);
unset($entry, $line);
$i++;
}
// EOF