2
0

ks3monitor.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*- encoding:utf-8 -*-
  2. from kscore.session import get_session
  3. import json
  4. if __name__ == "__main__":
  5. s = get_session()
  6. # 不同Region的bucket需要设置对应的参数去查询
  7. # 北京region cn-beijing-6
  8. # 上海region cn-shanghai-2
  9. # 杭州region cn-shanghai-2
  10. # 香港region cn-hongkong-2
  11. # 俄罗斯region eu-east-1
  12. #GetMetricStatistics
  13. client = s.create_client("monitor", "cn-beijing-6", use_ssl=True)
  14. #获取一天的标准存储量总量
  15. m=client.get_metric_statistics(InstanceID="test-wn",Namespace="KS3",MetricName="ks3.bucket.capacity.total.sd",StartTime="2018-07-03T00:00:05Z",EndTime="2018-07-04T00:00:05Z",Period="86400",Aggregate="Max")
  16. print json.dumps(m,sort_keys=True,indent=4)
  17. '''
  18. #获取一天的标准存储量增量
  19. m=client.get_metric_statistics(InstanceID="test-wn",Namespace="ks3",MetricName="ks3.bucket.capacity.add.sd",StartTime="2018-03-18T00:00:00Z",EndTime="2018-03-19T00:00:00Z",Period="86400",Aggregate="Max")
  20. print json.dumps(m,sort_keys=True,indent=4)
  21. # 获取一天的标准存储量删除量
  22. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.capacity.del.sd",StartTime="2018-03-18T00:00:00Z",EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  23. print json.dumps(m, sort_keys=True, indent=4)
  24. # 获取一天的低频存储量总量
  25. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.capacity.total.ia",StartTime="2018-03-18T00:00:00Z",EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  26. print json.dumps(m, sort_keys=True, indent=4)
  27. # 获取一天的低频存储量增量
  28. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.capacity.add.ia",StartTime="2018-03-18T00:00:00Z",EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  29. print json.dumps(m, sort_keys=True, indent=4)
  30. # 获取一天的低频存储量增量
  31. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.capacity.del.ia",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  32. print json.dumps(m, sort_keys=True, indent=4)
  33. # 获取一天的标准存储的下载流量
  34. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.flow.down.sd",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  35. print json.dumps(m, sort_keys=True, indent=4)
  36. # 获取一天的低频存储的下载流量
  37. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.flow.down.ia",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  38. print json.dumps(m, sort_keys=True, indent=4)
  39. # 获取一天的标准存储的get请求数
  40. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.getcount.sd",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  41. print json.dumps(m, sort_keys=True, indent=4)
  42. # 获取一天的标准存储的put请求数
  43. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.putcount.sd",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  44. print json.dumps(m, sort_keys=True, indent=4)
  45. # 获取一天的低频存储的get请求数
  46. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.getcount.ia",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  47. print json.dumps(m, sort_keys=True, indent=4)
  48. # 获取一天的低频存储的put请求数
  49. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.putcount.ia",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  50. print json.dumps(m, sort_keys=True, indent=4)
  51. # 获取一天的低频存储的数据取回量
  52. m = client.get_metric_statistics(InstanceID="test-wn", Namespace="ks3", MetricName="ks3.bucket.putcount.ia",StartTime="2018-03-18T00:00:00Z", EndTime="2018-03-19T00:00:00Z", Period="86400",Aggregate="Max")
  53. print json.dumps(m, sort_keys=True, indent=4)
  54. '''