<?php
if (substr(PHP_SAPI_NAME(), 0, 3) !== 'cli') {
    die("The program runs only in CLI mode!");
}

use AlibabaCloud\SDK\Cms\V20190101\Cms;
use AlibabaCloud\SDK\Cms\V20190101\Models\DescribeMetricLastRequest;
use Darabonba\OpenApi\Models\Config;

date_default_timezone_set('UTC');
$sid =$lid =1;
include_once dirname(__FILE__) . "/crontab.inc.php";
include_once dirname(__FILE__) . "/../com.php";
require_once dirname(__FILE__) . '/../vendor/autoload.php';
set_time_limit(0);
$tb = otable::vipPaymentLog();
$now = time();
$date = empty($argv[1]) ? date('Ymd', $now -  86400) : $argv[1];

$time = time();
$accessKeyId = 'LTAI5tANQSEUhQE9JAfwwHEY';
$accessKeySecret = 'b0FXaWdgUbWTm2cED0nhKfQAZhgrVN';
$config = new Config([
    "accessKeyId" => $accessKeyId,
    "accessKeySecret" => $accessKeySecret
]);
// 访问的域名
$config->endpoint = "metrics.cn-hangzhou.aliyuncs.com";

$client = new Cms($config);
$dimensions = [
    [
        'instanceId' => 'lb-0xit9qxfipdrir7mp7za3',
        'port' => '8282',
    ],
    [
        'instanceId' => 'lb-0xii7gpzz1yhoqwt6n54v',
        'port' => '8282',
    ],
];
$describeMetricLastRequest = new DescribeMetricLastRequest([
    "namespace" => "acs_slb_dashboard",
    "metricName" => "ActiveConnection",
    "dimensions" => json_encode($dimensions),
]);
// 复制代码运行请自行打印 API 的返回值
$result = $client->describeMetricLast($describeMetricLastRequest);
$json = $result->body->datapoints;
echo $json;