monitor.php,monitor.php

echo "[Monitor] Starting.....\n";

exec('mode con cols=30 lines=14');

exec('title Monitor');

echo "[Monitor] Loading Function Database\n";

include("include/function.php");

include("config/config.php");

Col_echo("[Monitor] Connecting to Redis\n",'yellow');

$redis = Redis_Link();

Col_echo("[Monitor] Connecting to Mysql\n",'yellow');

$db_link = DB_Link();

//

//

//子线程监控

//

//

start:

exec('title ['.date('H:i:s',time()).']');

//动态加载配置

$worker_thread = Get_Config('worker_thread');

Col_echo("Worker Status Monitor \n",'brown');

for ($i = 1; $i <= $worker_thread; $i++) {

$status = $redis->get('Worker_Status_' . $i);

if (empty($status)){

Col_echo("[".$i."] Free\n",'green');

}else{

$worker_step=$redis->get('Worker_Monitor_'.$i);

if (empty($worker_step)){

Col_echo("[".$i."] Worker Initialization\n",'yellow');

}elseif ($worker_step==1){

$cache = file_get_contents('cache\\worker_'.$i);

if (empty($cache)){

Col_echo("[".$i."] Read Cache Failed\n",'red');

}else{

preg_match("/Duration: (.*?), start: (.*?), bitrate: (\d*) kb\/s/", $cache, $match);

$arr_duration = explode(':', $match[1]);

$full_time = $arr_duration[0] * 3600 + $arr_duration[1] * 60 + $arr_duration[2];

preg_match_all("/time\=(.*?) bitrate/", $cache, $match);

$already_encode = $match[1][count($match[1]) - 1];

$already_encode = explode(':', $already_encode);

$already_encode = $already_encode[0] * 3600 + $already_encode[1] * 60 + $already_encode[2];

$encode_per=round($already_encode/$full_time*100,2);

Col_echo("[".$i."] Encoding (".$encode_per."%)\n",'light_green');

$redis->set('Monitor_Per_'.$i,$encode_per);

}

}elseif ($worker_step==2){

Col_echo("[".$i."] ScreenShot\n",'light_green');

}elseif ($worker_step==3){

Col_echo("[".$i."] Segmenting\n",'light_green');

}else{

Col_echo("[".$i."] Unknown\n",'red');

}

}

}

Col_echo("[".date('Y-m-d H:i:s',time())."]",'brown');

$cmd_end=14-$worker_thread-2;

for ($num=0;$num

echo "\n";

}

sleep(1);

goto start;

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值