12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- // 离线故障处理
- ini_set('display_errors', 1);
- require_once './DB.php';
- date_default_timezone_set('Asia/Shanghai');
- $config = [
- 'hostname' => 'rm-wz98r5cn33zq4ou980o.mysql.rds.aliyuncs.com',
- 'username' => 'idcol20',
- 'password' => 'idcol@1234',
- 'dbname' => 'idcol',
- ];
- function send_cmd($cmd,$type = 0, $timeout = 30, $ms_timeout = 200) {
- $ip = '123.57.20.89';
- $port = '6800';
- $client = @stream_socket_client("tcp://{$ip}:{$port}", $errno, $errstr, 30);
- if ($client) {
- fwrite($client, $cmd);
- stream_set_timeout($client, $timeout, $ms_timeout);
- $result = fread($client, 8196);
- fclose($client);
- return $result;
- } else {
- sleep(1);
- send_cmd($cmd,$type, $timeout, $ms_timeout);
- }
- }
- $begin = date('H:i',time());
- while (1) {
-
- $db = new Db($config);
- // 生成离线故障
- $sql = 'SELECT L.id FROM lampinfo as L left join warning_info_log AS WI on WI.lampid = L.id and WI.onlinestatus = 1 and WI.status = 0 where L.netstatus = 0 and WI.id is null';
- $list = $db->query($sql);
- var_dump($list);die;
- foreach ($list as $value) {
-
- }
- $db->close();
- $end = date('H:i',time());
- if ($end == $begin) {
- sleep(1);
- continue;
- }
- $begin = $end;
- }
|