强子静态

This commit is contained in:
“wanyongkang”
2023-05-14 17:35:11 +08:00
parent 1e6e3eb509
commit 57fbe214b9
4 changed files with 148 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
* @Author: kangkang
* @Date: 2020-11-03 11:04:15
* @LastEditors: “wanyongkang” “937888580@qq.com”
* @LastEditTime: 2023-04-24 23:53:47
* @LastEditTime: 2023-05-14 17:22:37
*/
$is_script = 1;
include_once __DIR__ . '/../../index.php';
@@ -14,18 +14,23 @@ include_once __DIR__ . '/auto_format.php';
// //测试用----------------------------------------------------------------------------------------------------------
// $url = 'http://int.linghangsoft.net:8000/sysadmin/useradmin/lineapi_admin1.php?secretId=108006113&secretKey=87085a351a64c116df09ebc07d5781sf';
// $yunniu = json_decode(file_get_contents($url), true);
// $time = time();
// $noce = md5(time());
// $apikey = 'a478ad5aa3079bbbef3cd45e2d55d61e';
// $sign = md5($time.$noce.$apikey);
// $url = "http://47.92.116.14:2222/api/getNodeList?agentid=admin1&ti=".$time."&nonce=".$noce."&sign=".$sign;
// $qiangzi = json_decode(file_get_contents($url), true)['data'];
// dump($qiangzi);
// if(!empty($yunniu)){
// $yunniu_f = fopen(__DIR__ . '/data/yunniu.csv', 'w');
// //写入火狐文件
// $yunniu_data = get_product(__DIR__ . '/data/yunniu.csv');
// huohu_getList($yunniu, $yunniu_f, $all,$yunniu_data);
// fclose($yunniu_f);
// if(!empty($qiangzi)){
// $qiangzi_data = get_product(__DIR__ . '/data/qiangzijt.csv');
// $qiangzi_f = fopen(__DIR__ . '/data/qiangzijt.csv', 'w');
// //写入强子文件
// qiangzijt_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data);
// fclose($qiangzi_f);
// }
// die;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//强子迅联特征码
@@ -81,6 +86,23 @@ $qiangzi_f = fopen(__DIR__ . '/data/qiangzi.csv', 'w');
qiangzi_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data);
fclose($qiangzi_f);
}
// 静态
$time = time();
$noce = md5(time());
$apikey = 'a478ad5aa3079bbbef3cd45e2d55d61e';
$sign = md5($time.$noce.$apikey);
$url = "http://47.92.116.14:2222/api/getNodeList?agentid=admin1&ti=".$time."&nonce=".$noce."&sign=".$sign;
$qiangzi = json_decode(file_get_contents($url), true)['data'];
if(!empty($qiangzi)){
$qiangzi_data = get_product(__DIR__ . '/data/qiangzijt.csv');
$qiangzi_f = fopen(__DIR__ . '/data/qiangzijt.csv', 'w');
//写入强子文件
qiangzijt_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data);
fclose($qiangzi_f);
}
@@ -214,6 +236,9 @@ function qiangzi_getList($data, &$file, &$all, $exit)
foreach ($data as $info) {
$record = [];
$record['name'] = '强子';
if ($info['areaname'] == '静态线路') {
continue;
}
//如果存在 不为空 则
$city_name = explode('-',$info['name']);
if (strpos($city_name[1], '混播') !== false) {
@@ -284,6 +309,95 @@ function qiangzi_getList($data, &$file, &$all, $exit)
}
//强子静态服务器解析规则
function qiangzijt_getList($data, &$file, &$all, $exit)
{
global $dnx_exit, $dnx_has_exit,$sp_qz_list;
$online = ['故障', '正常', '紧张','繁忙'];
$status = ['正常', '拥挤', '超载'];
$key = '';
$list1 = [];
$province_record = [];
foreach ($data as $info) {
$record = [];
$record['name'] = '强子静态';
if ($info['areaname'] != '静态线路') {
continue;
}
//如果存在 不为空 则
$city_name = explode('-',$info['name']);
if (strpos($city_name[1], '混播') !== false) {
//如果存在 不为空 则
if (!in_array( $city_name[1], $province_record)) {
$record['city'] = $city_name[1];
$province_record[] = $city_name[1];
$key = $record['city'];
$list1[$key][] = $record;
}
} else {
//如果存在 不为空 则
if (!in_array( $city_name[1], $province_record)) {
$record['city'] = $city_name[1];
$province_record[] = $city_name[1];
$key = $record['city'];
$list1[$key][] = $record;
}
$key = $city_name[1];
}
$record['city'] = $city_name[2];
$record['supply'] = isset($city_name[2]) ? $city_name[2] : '';
$daikuan = $info['bandwidth'];
$record['ip'] = $info['name2'];
$record['daikuan'] = $daikuan;
$record['onlineuser'] = '';
$record['maxuser'] = '';
$record['online'] = $online[$info['status']];
$record['status'] = $sp_qz_list[$record['city']];
if(!empty($info['host2'])){
$nas_list = explode(',',$info['host2']);
foreach ($nas_list as $nas) {
$record['nasname'] = trim($nas);
if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) {
fputcsv($dnx_exit, ['强子', explode('.',$record['nasname'])[0], $record['nasname'], date('Y-m-d H:i:s')]);
}
$list1[$key][] = $record;
}
}
$record['nasname'] = trim($info['host']);
if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) {
fputcsv($dnx_exit, ['强子', explode('.',$record['nasname'])[0], $record['nasname'], date('Y-m-d H:i:s')]);
}
$list1[$key][] = $record;
}
foreach ($list1 as $val) {
foreach ($val as $net_data) {
fputcsv($file, $net_data);
fputcsv($all, $net_data);
}
}
}
//火狐服务器解析规则
function huohu_getList($data, &$file, &$all, $exit)
{