-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build failure under go 1.5.3, ubuntu 14.04 #14
Comments
Seeing the same problem on Ubuntu 16.04 with go1.6.2 on xLinux. |
That's because MemInfo changed to a struct. Before that, it was a |
This should fix it: diff --git a/pkg/memory/memory.go b/pkg/memory/memory.go
index 6f80b15..fc83197 100644
--- a/pkg/memory/memory.go
+++ b/pkg/memory/memory.go
@@ -1,5 +1,4 @@
-//
-// Memory resource.
+// Package memory defines Memory resource.
//
// This collector reports on the following meminfo metrics:
//
@@ -67,12 +66,12 @@ func (m *Memory) Report() {
m.client.Gauge("swap.percent", swapPercent(stat))
if m.Extended {
- m.client.Gauge("total", bytes(stat["MemTotal"]))
+ m.client.Gauge("total", bytes(stat.MemTotal))
m.client.Gauge("used", bytes(used(stat)))
- m.client.Gauge("free", bytes(stat["MemFree"]))
- m.client.Gauge("active", bytes(stat["Active"]))
- m.client.Gauge("swap.total", bytes(stat["SwapTotal"]))
- m.client.Gauge("swap.free", bytes(stat["SwapFree"]))
+ m.client.Gauge("free", bytes(stat.MemFree))
+ m.client.Gauge("active", bytes(stat.Active))
+ m.client.Gauge("swap.total", bytes(stat.SwapTotal))
+ m.client.Gauge("swap.free", bytes(stat.SwapFree))
}
case <-m.exit:
@@ -89,9 +88,9 @@ func (m *Memory) Stop() error {
}
// calculate swap percentage.
-func swapPercent(s linux.MemInfo) int {
- total := s["SwapTotal"]
- used := total - s["SwapFree"]
+func swapPercent(s *linux.MemInfo) int {
+ total := s.SwapTotal
+ used := total - s.SwapFree
p := float64(used) / float64(total) * 100
if math.IsNaN(p) {
@@ -102,8 +101,8 @@ func swapPercent(s linux.MemInfo) int {
}
// calculate percentage.
-func percent(s linux.MemInfo) int {
- total := s["MemTotal"]
+func percent(s *linux.MemInfo) int {
+ total := s.MemTotal
p := float64(used(s)) / float64(total) * 100
if math.IsNaN(p) {
@@ -114,8 +113,8 @@ func percent(s linux.MemInfo) int {
}
// used memory.
-func used(s linux.MemInfo) uint64 {
- return s["MemTotal"] - s["MemFree"] - s["Buffers"] - s["Cached"]
+func used(s *linux.MemInfo) uint64 {
+ return s.MemTotal - s.MemFree - s.Buffers - s.Cached
}
// convert to bytes. |
Thanks guys for fixing! Can you tell me how to apply the patch? I am not familiar with how go gets the packages from git before compiling. And I am unsure if your fix is already on git, or if I have to run it on the machine where I will compile it... |
As stated in statsd#14, MemInfo changed from a map to a struct, breaking the compilation of the project. Trying to make this commit to master so it's not published as a patch and formalizes the fix.
The text was updated successfully, but these errors were encountered: