|
@@ -1,5 +1,5 @@
|
|
|
<?php
|
|
|
-require './DahuaUtil.php';
|
|
|
+require 'DahuaUtil.php';
|
|
|
class InotifyMonitor {
|
|
|
|
|
|
const MONITOR_EVENT = IN_CLOSE_WRITE;
|
|
@@ -63,23 +63,22 @@ class InotifyMonitor {
|
|
|
$this->redis->auth($password); //设置密码
|
|
|
$this->redis->select(1);
|
|
|
$result = $this->redis->ping();
|
|
|
- if($result=='pong')
|
|
|
+ if($result=='+PONG')
|
|
|
{
|
|
|
- echo "redis连接成功";
|
|
|
+
|
|
|
DahuaUtil::rlog('redis连接成功');
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
DahuaUtil::rlog("redis连接失败=>".$result.PHP_EOL);
|
|
|
- echo "redis连接失败=>".$result.PHP_EOL;
|
|
|
+
|
|
|
}
|
|
|
//扫描未存起来的redis文件
|
|
|
DahuaUtil::rlog("扫描没有监听到的文件");
|
|
|
- $this->scan_file($paths[0]);
|
|
|
+ $this->scan_file();
|
|
|
+ DahuaUtil::rlog('已经调用了清理脚本');
|
|
|
}catch (Exception $e){
|
|
|
-
|
|
|
DahuaUtil::rlog("redis连接异常".$e->getMessage());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -171,9 +170,9 @@ class InotifyMonitor {
|
|
|
if ($event['mask']==IN_CLOSE_WRITE) {
|
|
|
echo 'create file->'.$file.PHP_EOL;
|
|
|
|
|
|
- //写入kafka
|
|
|
+ //写入redis
|
|
|
$this->set_redis($file);
|
|
|
- //$this->postData($data);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//echo $event['name'], ' --- ', self::EVENT_MASK[$event['mask']], PHP_EOL;
|
|
@@ -181,7 +180,8 @@ class InotifyMonitor {
|
|
|
}
|
|
|
}
|
|
|
if (!empty($except)) {
|
|
|
- //debug_log('push_vidieo_images_log',json_encode($except));//记录下异常事�?
|
|
|
+ DahuaUtil::rlog("监听异常".json_encode($except));
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
//echo '------------------', PHP_EOL;
|
|
@@ -213,8 +213,11 @@ class InotifyMonitor {
|
|
|
}
|
|
|
//扫描目录下所有没有上传到redis文件
|
|
|
public function scan_file()
|
|
|
- {
|
|
|
- echo shell_exec("php /home/wwwroot/nbfd_tp3/index.php listening_file_create/scan_no_listening");
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ shell_exec("/home/wwwroot/nbfd_tp3/clear_file_redis.sh > /dev/null 2>&1 &");
|
|
|
+ //echo shell_exec("/home/wwwroot/nbfd_tp3/clear_file_redis.sh");
|
|
|
return;
|
|
|
}
|
|
|
|