Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
a8a5fe7a
Commit
a8a5fe7a
authored
Mar 04, 2019
by
Node- 门 忠鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 添加部分数据
parent
4c8a82af
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
83 deletions
+99
-83
agent_msg_process.go
service/agent_msg_process.go
+22
-6
chunk_msg.go
service/end_points/chunk_msg.go
+77
-77
No files found.
service/agent_msg_process.go
View file @
a8a5fe7a
...
...
@@ -5,20 +5,27 @@ import (
"fmt"
"git.quantgroup.cn/DevOps/enoch/service/end_points"
"github.com/influxdata/influxdb/client/v2"
"math/big"
"net"
"time"
)
var
sysNameIndex
=
make
(
map
[
int64
]
bool
)
func
AgentMsgProcess
(
msg
string
)
{
chunkMsg
:=
en
n
_points
.
ChunkMsg
{}
chunkMsg
:=
en
d
_points
.
ChunkMsg
{}
err
:=
json
.
Unmarshal
([]
byte
(
msg
),
&
chunkMsg
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
buildMetricsInfluxMsg
(
chunkMsg
)
}
func
buildMetricsInfluxMsg
(
chunkMsg
enn_points
.
ChunkMsg
)
{
func
buildMetricsInfluxMsg
(
chunkMsg
end_points
.
ChunkMsg
)
{
var
ip
=
inetAtoN
(
chunkMsg
.
Ip
)
println
(
"ip:%d"
,
ip
)
sysNameIndex
[
ip
]
=
true
var
sysNameCount
=
len
(
sysNameIndex
)
for
_
,
p
:=
range
chunkMsg
.
EndPoints
{
tags
:=
make
(
map
[
string
]
string
,
)
tags
[
"sys_name"
]
=
chunkMsg
.
AppName
...
...
@@ -62,15 +69,24 @@ func buildMetricsInfluxMsg(chunkMsg enn_points.ChunkMsg) {
fields
[
"gc_concurrent_mark_sweep"
]
=
metrics
.
GcConcurrentmarksweepCount
fields
[
"gc_concurrent_mark_time"
]
=
metrics
.
GcConcurrentmarksweepTime
fields
[
"processors"
]
=
metrics
.
Processors
fields
[
"uptime"
]
=
metrics
.
Uptime
fields
[
"instance_uptime"
]
=
metrics
.
InstanceUptime
fields
[
"system_load_average"
]
=
metrics
.
SystemloadAverage
unix
:=
time
.
Unix
(
0
,
p
.
Timestamp
)
if
(
len
(
pointSlice
)
==
batchSize
)
{
unix
:=
time
.
Unix
(
0
,
p
.
Timestamp
*
1000000
)
println
(
p
.
Timestamp
)
if
len
(
pointSlice
)
>=
sysNameCount
{
go
batchWrite
(
pointSlice
)
pointSlice
=
make
([]
*
client
.
Point
,
0
,
batchSize
)
}
println
(
len
(
pointSlice
))
point
,
_
:=
client
.
NewPoint
(
"machine_info"
,
tags
,
fields
,
unix
)
pointSlice
=
append
(
pointSlice
,
point
)
}
}
func
inetAtoN
(
ip
string
)
int64
{
ret
:=
big
.
NewInt
(
0
)
ret
.
SetBytes
(
net
.
ParseIP
(
ip
)
.
To4
())
return
ret
.
Int64
()
}
service/end_points/chunk_msg.go
View file @
a8a5fe7a
This diff is collapsed.
Click to expand it.
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