Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 83937b8

Browse files
committed
Minor fixes in the metric collector
1 parent c790eef commit 83937b8

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

cmd/monitor.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212
"time"
1313

1414
"github.com/fatih/color"
15-
"github.com/shirou/gopsutil/cpu"
16-
"github.com/shirou/gopsutil/disk"
17-
"github.com/shirou/gopsutil/host"
18-
"github.com/shirou/gopsutil/load"
15+
"github.com/shirou/gopsutil/v3/cpu"
16+
"github.com/shirou/gopsutil/v3/disk"
17+
"github.com/shirou/gopsutil/v3/host"
18+
"github.com/shirou/gopsutil/v3/load"
19+
"github.com/shirou/gopsutil/v3/mem"
1920

20-
"github.com/shirou/gopsutil/mem"
2121
"github.com/spf13/cobra"
2222
"github.com/spf13/viper"
2323
)
@@ -80,8 +80,6 @@ var actionCmd = &cobra.Command{
8080
// Get current system stats
8181
memory, _ := mem.VirtualMemory()
8282
loadAvg, _ := load.Avg()
83-
cpuHw, _ := cpu.Info()
84-
//percent, _ := cpu.Percent(time.Second, true)
8583
uptime, _ := host.Uptime()
8684
misc, _ := load.Misc()
8785
platform, family, version, _ := host.PlatformInformation()
@@ -113,7 +111,8 @@ var actionCmd = &cobra.Command{
113111
form.Add("procs[total]", fmt.Sprint(misc.ProcsTotal))
114112

115113
// Generic CPU HW
116-
form.Add("cpu", fmt.Sprint(cpuHw))
114+
form.Add("cpu[raw]", fmt.Sprint(cpu.Info()))
115+
form.Add("cpu[percent]", fmt.Sprint(cpu.Percent(time.Second, true)))
117116

118117
// Uptime
119118
form.Add("uptime_seconds", fmt.Sprint(uptime))
@@ -143,9 +142,9 @@ var actionCmd = &cobra.Command{
143142
log.Fatal(err)
144143
}
145144

146-
req.Header.Set("User-Agent", "DeployerAgent-v1.0.0;"+runtime.GOOS)
145+
req.Header.Set("User-Agent", "DeployerAgent-v2.0.0;"+runtime.GOOS)
147146
req.Header.Set("TeamApiKey", teamAPIKey)
148-
req.Header.Set("ServerApiKey", serverId)
147+
req.Header.Set("ServerId", serverId)
149148
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
150149
httpClient.Do(req)
151150
},

cmd/root.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package cmd
33
import (
44
"fmt"
55
"os"
6-
76
"github.com/spf13/cobra"
8-
97
"github.com/spf13/viper"
108
)
119

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require github.com/spf13/cobra v1.0.0
99
require (
1010
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
1111
github.com/go-ole/go-ole v1.2.4 // indirect
12-
github.com/shirou/gopsutil v2.20.6+incompatible
12+
github.com/shirou/gopsutil v2.20.6+incompatible // indirect
13+
github.com/shirou/gopsutil/v3 v3.21.2
1314
github.com/spf13/viper v1.7.0
14-
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 // indirect
1515
)

go.sum

+10
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
162162
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
163163
github.com/shirou/gopsutil v2.20.6+incompatible h1:P37G9YH8M4vqkKcwBosp+URN5O8Tay67D2MbR361ioY=
164164
github.com/shirou/gopsutil v2.20.6+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
165+
github.com/shirou/gopsutil/v3 v3.21.2 h1:fIOk3hyqV1oGKogfGNjUZa0lUbtlkx3+ZT0IoJth2uM=
166+
github.com/shirou/gopsutil/v3 v3.21.2/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw=
165167
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
166168
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
167169
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -185,8 +187,13 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
185187
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
186188
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
187189
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
190+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
188191
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
189192
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
193+
github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M=
194+
github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek=
195+
github.com/tklauser/numcpus v0.2.1 h1:ct88eFm+Q7m2ZfXJdan1xYoXKlmwsfP+k88q05KvlZc=
196+
github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8=
190197
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
191198
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
192199
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
@@ -261,6 +268,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193
261268
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
262269
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 h1:4Khi5GeNOkZS5DqSBRn4Sy7BE6GuxwOqARPqfurkdNk=
263270
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
271+
golang.org/x/sys v0.0.0-20210217105451-b926d437f341 h1:2/QtM1mL37YmcsT8HaDNHDgTqqFVw+zr8UzMiBVLzYU=
272+
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
264273
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
265274
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
266275
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
@@ -319,6 +328,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
319328
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
320329
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
321330
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
331+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
322332
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
323333
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
324334
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

0 commit comments

Comments
 (0)