Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm-mysql-exporter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
system
gm-mysql-exporter
Commits
0f33f775
Commit
0f33f775
authored
Apr 19, 2019
by
胡凯旋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
e0947312
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
exporter.py
exporter.py
+8
-3
No files found.
exporter.py
View file @
0f33f775
...
...
@@ -2,6 +2,8 @@
import
abc
import
math
import
pprint
import
time
import
json
from
prometheus_client.core
import
GaugeMetricFamily
...
...
@@ -66,8 +68,12 @@ class TencentExporter(Exporter):
'rds_name'
,
'type'
,
'service_provider'
,
'project'
])
if
len
(
instance_data_list
)
!=
len
(
self
.
instances
):
print
(
time
.
ctime
(),
label
,
u"取得监控数据的机器数量与配置的机器数量不一致"
,
len
(
instance_data_list
))
pprint
.
pprint
(
instance_data_list
)
for
instance_data
in
instance_data_list
:
timestamp_value_dict
=
dict
(
zip
(
instance_data
[
'Timestamps'
],
instance_data
[
'Values'
]))
value
=
instance_data
[
'Values'
][
-
1
]
instance_id
=
instance_data
[
'Dimensions'
][
0
][
'Value'
]
instance
=
self
.
instances
[
instance_id
]
instance_name
=
instance
[
'name'
]
...
...
@@ -75,7 +81,6 @@ class TencentExporter(Exporter):
instance_project
=
instance
.
get
(
'project'
,
'gengmei'
)
# 当前queryname,当前rds实例的因子,若没有配置,默认为1
rds_factor
=
instance
.
get
(
factor
,
1
)
for
value
in
timestamp_value_dict
.
values
():
avg_metric_family
.
add_metric
([
instance_name
,
instance_type
,
service_provider
,
instance_project
],
value
)
with_factor_metric_family
.
add_metric
(
[
'{}*{}'
.
format
(
instance_name
,
rds_factor
),
instance_type
,
service_provider
,
instance_project
],
...
...
@@ -91,7 +96,7 @@ class TencentExporter(Exporter):
for
instance
in
instance_data_list
:
# 腾讯云CPU利用率/内存使用率返回的是0-100(%), 转化成 0-1
if
label
in
[
"CPUUseRate"
,
"MemoryUseRate"
]:
instance
[
'Values'
][:]
=
map
(
lambda
v
:
v
/
100
,
instance
[
'Values'
])
instance
[
'Values'
][:]
=
map
(
lambda
v
:
v
/
100
.0
,
instance
[
'Values'
])
class
AliyunExporter
(
Exporter
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment