-
Notifications
You must be signed in to change notification settings - Fork 1
/
objects.go
100 lines (89 loc) · 1.86 KB
/
objects.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"github.com/Sirupsen/logrus"
)
// Args : command line args
var Args = struct {
configFile string
}{}
// GenericLog - generic log format
type GenericLog struct {
msg string
level string
msgtype string
}
// APILog - log format for API
type APILog struct {
msgtype string `default:"API"`
msg string
level string
uri string
method string
status int
query string
}
// DaemonLog - log format for daemon logging
type DaemonLog struct {
msgtype string `default:"daemon"`
msg string
level string
name string
command string
args []string
vital bool
env []string
pid int
}
// ProcessLog - log format for process logging
type ProcessLog struct {
msgtype string `default:"process"`
msg string
level string
daemon string
pipe string
}
// AppLog - log format for main
type AppLog struct {
msgtype string `default:"main"`
msg string
level string
event string
}
// Ping - ping/pong
type Ping struct {
Ping string `default:"pong" json:"ping"`
}
// Proc - process object
type Proc struct {
Name string `json:"name"`
Pid int32 `json:"pid"`
Command string `json:"command"`
MemoryVirtual uint64 `json:"memvirt"`
MemorySwap uint64 `json:"memswap"`
CPU float64 `json:"cpu_pct"`
CPUTimes CPUTimes `json:"cpu_times"`
Status string `json:"status"`
IsRunning bool `json:"running"`
}
// CPUTimes - cpu times struct
type CPUTimes struct {
User float64 `json:"user"`
System float64 `json:"system"`
Idle float64 `json:"idle"`
}
func getLogLevel(s string) logrus.Level {
switch s {
case "debug":
return logrus.DebugLevel
case "info":
return logrus.InfoLevel
case "warn":
return logrus.WarnLevel
case "error":
return logrus.ErrorLevel
case "fatal":
return logrus.FatalLevel
default:
return logrus.InfoLevel
}
}