拉斯维加斯(3499-官方认证)浏览器-Made in Las Vegas /index.php/interflow/technology/11209?utm_source=rss&utm_medium=rss&utm_campaign=zabbix%25e6%258a%2580%25e6%259c%25af%25e5%2588%2586%25e4%25ba%25ab-%25e5%25a6%2582%25e4%25bd%2595%25e4%25bd%25bf%25e7%2594%25a8zabbix%25e7%259b%2591%25e6%258e%25a7%25e5%258d%258e%25e4%25b8%25ba%25e4%25ba%2591rds Tue, 06 Dec 2022 06:25:16 +0000 /?p=11209 鏈枃浠嬬粛濡備綍浣跨敤zabbix鐩戞帶鍗庝负浜慠DS

zabbix鎶€鏈垎浜€斺€斿浣曚娇鐢▃abbix鐩戞帶鍗庝负浜慠DS鏈€鍏堝嚭鐜板湪涔愮淮瀹樼綉銆侟/p> ]]> 鍦ㄦ暟瀛楀寲澶ц儗鏅笅锛屾暟鎹槸閲嶈鐨勭敓浜ц祫鏂欙紝杩欎簺鏁版嵁瀛樻斁鍦ㄥ摢閲岋紝濡備綍淇濋殰鏁版嵁瀹夊叏鏄墍鏈変紒涓氶兘瑕佽€冭檻鐨勪簨鎯呫€傚崕涓轰簯RDS鍑€熷畨鍏ㄥ彲闈狅紝鍙牴鎹笟鍔¤妯″姩鎬佹墿瀹圭殑鐗规€э紝鍙楀埌瓒婃潵瓒婂涓皬浼佷笟鐨勯潚鐫愶紝瀵瑰崕涓轰簯RDS鐩戞帶鐨勯渶姹備篃闅忎箣澧為暱銆傛湰鏂囧皢浠嬬粛濡備綍浣跨敤zabbix鐩戞帶鍗庝负浜慠DS銆侟/p>

涓€銆?strong>鎬濊矾

鈥㈤€氳繃鍗庝负浜慠DS瀹炰緥鍒楄〃鎺ュ彛鑾峰彇RDS瀹炰緥锛岀敤浜庤祫婧愮殑鑷姩鍙戠幇

鈥㈤€氳繃鍗庝负浜慍ES鑾峰彇鐩戞帶鏁版嵁鍑咟/p>

浜屻€?strong>鍑嗗宸ヤ綔

鈥㈢敤浜庤闂崕涓轰簯鐨凙K/SK

浜戠洃鎺? class=

鈥ython3鐜

鈥㈢敤浜庤皟鐢ㄥ崕涓轰簯api鐨勭浉鍏虫ā鍧椾緷璧 https://github.com/huaweicloud/huaweicloud-sdk-python-v3

涓夈€?strong>缂栧啓瀹炰緥鑷姩鍙戠幇鑴氭湰

#!/bin/python3
# coding: utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkrds.v3.region.rds_region import RdsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrds.v3 import *
import json
if __name__ == "__main__":
    #杩欓噷濉闂瘑閽
    ak = ""
    sk = ""

    credentials = BasicCredentials(ak, sk) \

    client = RdsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RdsRegion.value_of("cn-north-4")) \
        .build()

    try:
        request = ListInstancesRequest()
        response = client.list_instances(request)
        response = json.loads(str(response))
        #鎷兼帴鎴愮敤浜庤嚜鍔ㄥ彂鐜扮殑json鏁版嵁锛宨d涓篟DS鐨勫疄渚婭D锛宯ame涓篟DS鐨勫悕绉
        r = []
        for i in response['instances']:
              buf = {'{#INSTANCE}':i['id'],'{#INSTANCE_NANME}':i['name']}
              r.append(buf)
        print(json.dumps({"data":r}))

    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

鍥涖€?strong>缂栧啓鐩戞帶鏁版嵁鑾峰彇鑴氭湰

#!/bin/python3
# coding: utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkces.v1.region.ces_region import CesRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkces.v1 import *
import json
import time
import sys
#浼犲叆鐨勭洃鎺ч」
key = sys.argv[1]
#璇锋眰鏃堕棿鎴
from_time = int(round(time.time() * 1000)-300000)
to_time = int(round(time.time() * 1000))
if __name__ == "__main__":
    #杩欓噷濉闂瘑閽
    ak = ""
    sk = ""

    credentials = BasicCredentials(ak, sk) \

    client = CesClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CesRegion.value_of("cn-north-4")) \
        .build()

    try:
        request = BatchListMetricDataRequest()
        listDimensionsMetrics = [
            MetricsDimension(
                name="rds_cluster_id",
                #杩欓噷鏄疄渚婭D锛屽彲鏀逛负鍙橀噺锛屾ā鏉垮畯鍗硔HOST.HOST}
                value=""
            )
        ]
        listMetricsbody = [
            MetricInfo(
                namespace="SYS.RDS",
                metric_name=key,
                dimensions=listDimensionsMetrics
            )
        ]
        request.body = BatchListMetricDataRequestBody(
            to=to_time,
            _from=from_time,
            filter="max",
            period="1",
            metrics=listMetricsbody
        )
        response = client.batch_list_metric_data(request)
        res = json.loads(str(response))
        instance = json.dumps(res)
        instances = json.loads(instance)['metrics']
        for i in instances:
            #鍙栨渶鏂扮殑涓€涓€
              print(i['datapoints'][0]['max'])
              #print(i)

    except exceptions.ClientRequestException as e:
        print(0)
        #print(e.request_id)
        #print(e.error_code)
        #print(e.error_msg)

浜斻€?strong>鏂板妯℃澘

鈥㈡柊澧炶嚜鍔ㄥ彂鐜拌鍒欙紝鐢ㄤ簬瀹炰緥鑷姩鍙戠幇

zabbix鑷姩鍙戠幇

鈥㈣嚜鍔ㄥ彂鐜拌鍒欙紝閾炬帴鐩戞帶鏁版嵁鑾峰彇妯℃澘

zabbix妯℃澘
zabbix鐩戞帶

鍏€?strong>楠岃瘉

鈥㈤獙璇佹槸鍚﹀彲浠ユ甯稿彂鐜板疄渚

鏂板涓绘満锛岄摼鎺ュ崕涓轰簯RDS鑷姩鎵弿妯℃澘鍚庯紝鐐硅嚜鍔ㄥ彂鐜拌鍒欙紝鍙互姝e父鑾峰彇鍒版暟鎹?/p>

zabbix鑷姩鍙戠幇瑙勫垯

鈥㈤獙璇佺洃鎺ф暟鎹槸鍚﹁幏鍙栨甯

鐐瑰嚮鍙戠幇鍑烘潵瀹炰緥锛屾祴璇曠洃鎺ч」鍙互姝e父鑾峰彇鍒版暟鎹?/p>

鐩戞帶瀹炰緥

浠ヤ笂鍗充负浣跨敤zabbix鐩戞帶鍗庝负浜慠DS鐨勬搷浣滆繃绋嬨€侟/p>

杩欎竴鏈熺殑zabbix鐨勬妧鏈垎浜埌杩欏氨缁撴潫浜嗭紝鏇村zabbix鍐呭锛岃繕鍙互鏌ョ湅鎴戠殑寰€鏈熷唴瀹癸細zabbix鐩戞帶鏃ュ織鏂规硶鍒嗕韩锛汓a href="/index.php/anl/10962">zabbix鎶€鏈垎鏋忺/a>

鎴栬€呯洿鎺ュ叧娉?a href="https://forum.lwops.cn/">涔愮淮绀惧尯锛屼笓娉ㄨ繍缁存妧鏈垎浜紝鍏虫敞鎴戯紝杩愮淮鏇存棤蹇с€侟/p>

涔愮淮鍏紬鍙? class=

zabbix鎶€鏈垎浜€斺€斿浣曚娇鐢▃abbix鐩戞帶鍗庝负浜慠DS鏈€鍏堝嚭鐜板湪涔愮淮瀹樼綉銆侟/p> ]]>