騰訊雲SDK獲取CDB相關資訊範例 實操系列

2021-10-02 20:58:17 字數 2574 閱讀 7910

tencentcloud-sdk-python

from tencentcloud.common import credential

from tencentcloud.common.exception.tencent_cloud_sdk_exception import tencentcloudsdkexception

from tencentcloud.cdb.v20170320 import cdb_client, models

try:

cred = credential.credential(

"secretid"

,"secretkey"

) client = cdb_client.cdbclient(cred,

"ap-shanghai"

) req = models.describedbinstancesresponse(

) req.limit=

100# 預設只會展示20條資訊

resp = client.describedbinstances(req)

print

(resp.to_json_string())

except tencentcloudsdkexception as err:

print

(err)

當然輸出的資料是一堆json,自然想到是jq命令過濾出需要的資訊

➜  ~ python getcdblist.py  |jq '.items |.|'

# -*- coding: utf-8 -*-

from tencentcloud.common import credential

from tencentcloud.common.exception.tencent_cloud_sdk_exception import tencentcloudsdkexception

from tencentcloud.cdb.v20170320 import cdb_client, models

try:

cred = credential.credential(

"secretid"

,"secretkey"

) client = cdb_client.cdbclient(cred,

"ap-shanghai"

)# 慢查詢日誌

req = models.describeslowlogsrequest(

) req.limit=

1 req.instanceid=

"xx-instanceid"

resp = client.describeslowlogs(req)

resp = resp.to_json_string(

)print

(resp)

except tencentcloudsdkexception as err:

print

(err)

➜  ~ python getcdbslowlog.py  | jq

]}

from tencentcloud.common import credential

from tencentcloud.common.exception.tencent_cloud_sdk_exception import tencentcloudsdkexception

from tencentcloud.cdb.v20170320 import cdb_client, models

try:

cred = credential.credential(

"secretid"

,"secretkey"

) client = cdb_client.cdbclient(cred,

"ap-shanghai"

) req = models.describedevicemonitorinforequest(

) req.instanceid=

'xx-instanceid'

req.count=

1 resp = client.describedevicemonitorinfo(req)

print

(resp)

except tencentcloudsdkexception as err:

print

(err)

➜  ~ python getcdbmon.py

[tencentcloudsdkexception] code:operationdenied.actionnotsupport message:該介面暫只支援最高配置例項查詢 requestid:******xx

很可惜,窮,買不起頂配的

Grafana監控騰訊cdb物理資源資訊

grafana版本version 7.1.5 基於promethuse的方案 基於雲監控api的方案 需求,監控mysql所有物理機相關指標 cpu 記憶體 磁碟等 qcloud exporter的配置 grep ev qcloud cdb product.yml credential access...

SDK接入步驟 騰訊雲摘抄

1.準備工作 引入初始化指令碼 2.html裡放置容器 var player new tcplayer id test video 2 pc上實現更低的延遲,pc瀏覽器支援flash var player new tcplayer id test video 3.失敗原因分析 如果是直播url,檢查...

獲取Wifi相關資訊

當前已連線的wifi的訊號強度 2012 04 12 15 37 21 分類 歷程 標籤 舉報 字型大小大中 小訂閱1.得到當前已連線的wifi資訊 wifimanager wifi service wifimanager getsystemservice wifi service wifiinfo...