是限速?
还是断网?
还是按流量收费?
话说如果是按流量收费,岂不是好坑,MJJ是咋避免的?
江西网友:
- <?php
- function percentEncode($str){
- $res = urlencode($str);
- $res = preg_replace(‘/\+/’, ‘%20’, $res);
- $res = preg_replace(‘/\*/’, ‘%2A’, $res);
- $res = preg_replace(‘/%7E/’, ‘~’, $res);
- return $res;
- }
- function computeSignature($parameters, $accessKeySecret){
- ksort($parameters);
- $canonicalizedQueryString = ”;
- foreach($parameters as $key => $value)
- {
- $canonicalizedQueryString .= ‘&’ . percentEncode($key)
- . ‘=’ . percentEncode($value);
- }
- $stringToSign = ‘GET&%2F&’ . percentencode(substr($canonicalizedQueryString, 1));
- $signature = base64_encode(hash_hmac(‘sha1’, $stringToSign, $accessKeySecret . ‘&’, true));
- return $signature;
- }
- function get_action($data){
- date_default_timezone_set("GMT");
- $dateTimeFormat = ‘Y-m-d\TH:i:s\Z’;
- $publicdata = array(
- ‘Format’ => ‘JSON’,
- ‘Version’ => ‘2014-05-26’,
- ‘AccessKeyId’ => ‘AccessKeyIdXXXXXXXX’,
- ‘SignatureVersion’ => ‘1.0’,
- ‘SignatureMethod’ => ‘HMAC-SHA1’,
- ‘SignatureNonce’=> uniqid(),
- ‘TimeStamp’ => date($dateTimeFormat)
- );
- $data = array_merge($publicdata,$data);
- $data[‘Signature’] = computeSignature($data, ‘AccessKeySecretXXXXXXXXXXXXXXXXXXXXXXXXX’);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, ‘https://ecs.aliyuncs.com/?’ . http_build_query($data));
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- $res = curl_exec($ch);
- date_default_timezone_set(‘PRC’);
- return $res;
- }
- function get_(){
- $data = array(
- ‘Action’ => ‘DescribeEipMonitorData’,
- ‘AllocationId’ => ‘eip-xxxxxxxxxxx’,
- ‘StartTime’ =>"2019-04-17T00:00:00Z",
- ‘EndTime’ => "2019-06-01T00:00:00Z",
- ‘Period’ => "3600"
- );
- $res = (string)get_action($data);
- $jsonarray = json_decode($res,true);
- //echo $jsonarray[‘EipMonitorDatas’][‘EipMonitorData’][1][‘EipTX’];
- //echo count($jsonarray[‘EipMonitorDatas’][‘EipMonitorData’]);
- $temp_all_EipTX=0;
- for ($i = 0; $i < count($jsonarray[‘EipMonitorDatas’][‘EipMonitorData’]); $i++) {
- $temp_all_EipTX=$temp_all_EipTX+$jsonarray[‘EipMonitorDatas’][‘EipMonitorData’][$i][‘EipTX’];
- }
- echo $temp_all_EipTX/1024/1024/1024;
- if($temp_all_EipTX>=950*1024*1024*1024){
- StopInstance();
-
- }
- }
- function StopInstance(){
- $data = array(
- ‘Action’ => ‘StopInstance’,
- ‘InstanceId’ => ‘i-xxxxxxxxxx’,
- ‘ForceStop’ =>"true",
- ‘StoppedMode’ => "keepcharging",
- ‘ConfirmStop’ => "false"
- );
- $res = (string)get_action($data);
- echo $res;
- }
- get_();
- ?>
复制代码
上海网友:套外流量收费
辽宁网友:国际版会继续计费,并自动扣钱
国内版直接断网
四川网友:这个月被扣了6刀了,心疼
山西网友:有没有那种监控流量,用到99%自动关机的脚本?
湖南网友:标记下~!
湖南网友:技术大佬现身,这个脚本咋用呢?求指点