Skip to content

Commit a78a884

Browse files
author
金山云SDK
authored
Merge pull request KscSDK#88 from KscSDK/trunk
Trunk
2 parents 1b8b15d + 3355924 commit a78a884

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

examples/ks3monitor.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# -*- encoding:utf-8 -*-
2+
3+
from kscore.session import get_session
4+
import json
5+
6+
if __name__ == "__main__":
7+
s = get_session()
8+
9+
10+
#ListMetrics
11+
12+
# client = s.create_client("monitor", "cn-beijing-6", use_ssl=True)
13+
# m=client.list_metrics(InstanceID="e564f8b3-f120-42cd-8b0e-084e66e73161",Namespace="kec",PageIndex="1",PageSize="10")
14+
# print json.dumps(m,sort_keys=True,indent=4)
15+
16+
17+
18+
#GetMetricStatistics
19+
client = s.create_client("monitor", "cn-beijing-6", use_ssl=True)
20+
21+
#获取一天的标准存储量总量
22+
m=client.get_metric_statistics(InstanceID="test-wn",Namespace="KS3",MetricName="ks3.bucket.capacity.total.sd",StartTime="2018-03-25T00:00:05Z",EndTime="2018-03-26T00:00:05Z",Period="86400",Aggregate="Max")
23+
print json.dumps(m,sort_keys=True,indent=4)
24+
'''
25+
#获取一天的标准存储量增量
26+
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")
27+
print json.dumps(m,sort_keys=True,indent=4)
28+
29+
# 获取一天的标准存储量删除量
30+
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")
31+
print json.dumps(m, sort_keys=True, indent=4)
32+
33+
# 获取一天的低频存储量总量
34+
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")
35+
print json.dumps(m, sort_keys=True, indent=4)
36+
37+
# 获取一天的低频存储量增量
38+
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")
39+
print json.dumps(m, sort_keys=True, indent=4)
40+
41+
# 获取一天的低频存储量增量
42+
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")
43+
print json.dumps(m, sort_keys=True, indent=4)
44+
45+
# 获取一天的标准存储的下载流量
46+
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")
47+
print json.dumps(m, sort_keys=True, indent=4)
48+
49+
# 获取一天的低频存储的下载流量
50+
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")
51+
print json.dumps(m, sort_keys=True, indent=4)
52+
53+
# 获取一天的标准存储的get请求数
54+
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")
55+
print json.dumps(m, sort_keys=True, indent=4)
56+
57+
# 获取一天的标准存储的put请求数
58+
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")
59+
print json.dumps(m, sort_keys=True, indent=4)
60+
61+
62+
# 获取一天的低频存储的get请求数
63+
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")
64+
print json.dumps(m, sort_keys=True, indent=4)
65+
66+
# 获取一天的低频存储的put请求数
67+
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")
68+
print json.dumps(m, sort_keys=True, indent=4)
69+
70+
# 获取一天的低频存储的数据取回量
71+
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")
72+
print json.dumps(m, sort_keys=True, indent=4)
73+
'''

0 commit comments

Comments
 (0)