-
Notifications
You must be signed in to change notification settings - Fork 1
/
messages.go
54 lines (46 loc) · 1.31 KB
/
messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package topidchart
import (
as "github.com/godevsig/adaptiveservice"
)
// SessionRequest is the message sent by client.
// Return SessionResponse.
// Client should send one or more Record after SessionResponse is received.
type SessionRequest struct {
Tag string
SysInfo SysInfo
ExtraInfo string
}
// SessionResponse is the message replied by server.
type SessionResponse struct {
ChartURL string
}
// ProcessInfo is process statistics.
type ProcessInfo struct {
Pid int
Name string
Ucpu float32
Scpu float32
Mem uint64 // in KB
}
// Record is sent by client periodically including target processes info,
// an optional snapshot such as process tree, and timestamp.
type Record struct {
Timestamp int64
Processes []ProcessInfo
Snapshot string
}
// SysInfo is part of SessionRequest used to initiate a collecting session.
type SysInfo struct {
CPUInfo string
KernelInfo string
}
func init() {
as.RegisterType((*SessionRequest)(nil))
as.RegisterType((*SessionResponse)(nil))
as.RegisterType((*Record)(nil))
}
//go:generate mkdir -p $GOPACKAGE
//go:generate sh -c "echo '// Code generated by original messages.go. DO NOT EDIT.\n' > $GOPACKAGE/$GOFILE"
//go:generate sh -c "grep -v go:generate $GOFILE >> $GOPACKAGE/$GOFILE"
//go:generate gofmt -w $GOPACKAGE/$GOFILE
//go:generate git add $GOPACKAGE/$GOFILE