...
|
...
|
@@ -3,8 +3,12 @@ |
|
|
error_reporting(E_ALL);
|
|
|
ini_set('display_errors',true);
|
|
|
|
|
|
require_once __DIR__.'/Config.php';
|
|
|
require_once __DIR__.'/InfluxdbLog.php';
|
|
|
/**
|
|
|
* 读取配置信息
|
|
|
*/
|
|
|
$Config = new Lua();
|
|
|
$Config->include(__DIR__.'/Config.lua');
|
|
|
|
|
|
require_once __DIR__.'/Rabbitmq.php';
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -13,20 +17,6 @@ require_once __DIR__.'/Rabbitmq.php'; |
|
|
class Sender{
|
|
|
|
|
|
/**
|
|
|
* 添加记录
|
|
|
* @param array $data
|
|
|
* @param array $tags
|
|
|
* @return type
|
|
|
*/
|
|
|
static function add($type,array $data,array $tags = []){
|
|
|
$tags = $tags + array(
|
|
|
'ip'=>'',
|
|
|
'hostname'=>'',
|
|
|
);
|
|
|
return InfluxdbLog::handle($type,$data,$tags);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加到队列中
|
|
|
* @param array $data
|
|
|
* @param array $tags
|
...
|
...
|
@@ -46,12 +36,13 @@ class Sender{ |
|
|
* @return type
|
|
|
*/
|
|
|
static function log($message){
|
|
|
global $Config;
|
|
|
echo $message."\n";
|
|
|
if (!Config::log_file){
|
|
|
if (!$Config->log_file){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$fp = @fopen(Config::log_file,'a');
|
|
|
$fp = @fopen($Config->log_file,'a');
|
|
|
if (!$fp){
|
|
|
return;
|
|
|
}
|
...
|
...
|
|