Telegraf: Binary for Windows 32bits (386)

Created on 7 Jun 2016  路  6Comments  路  Source: influxdata/telegraf

Feature Request

It's possible to generate a telegraf build for windows 386? I've tried by myself but without luck.

Proposal:

Provide a binary for windows 32 bits

Current behavior:

I've changed the build-windows to export GOARCH=386 before start building.

build-windows:
        GOOS=windows GOARCH=386 go build -o telegraf.exe -ldflags \
                "-X main.version=$(VERSION)" \
                ./cmd/telegraf/telegraf.go

But unfortunetly I've go the following errors:


GOOS=windows GOARCH=386 go build -o telegraf.exe -ldflags \
        "-X main.version=1.0.0-beta1" \
        ./cmd/telegraf/telegraf.go
# github.com/influxdata/telegraf/plugins/inputs/procstat
plugins/inputs/procstat/spec_processor.go:74: p.proc.Times undefined (type *process.Process has no field or method Times)
plugins/inputs/procstat/spec_processor.go:89: p.proc.Percent undefined (type *process.Process has no field or method Percent)
# github.com/influxdata/telegraf/plugins/inputs/system
plugins/inputs/system/cpu.go:14: undefined: cpu.TimesStat
plugins/inputs/system/ps.go:16: undefined: cpu.TimesStat
plugins/inputs/system/ps.go:17: undefined: disk.UsageStat
plugins/inputs/system/ps.go:18: undefined: "github.com/shirou/gopsutil/net".IOCountersStat
plugins/inputs/system/ps.go:19: undefined: "github.com/shirou/gopsutil/net".ProtoCountersStat
plugins/inputs/system/ps.go:20: undefined: disk.IOCountersStat
plugins/inputs/system/ps.go:23: undefined: "github.com/shirou/gopsutil/net".ConnectionStat
make: *** [build-windows] Error 2

Use case:

To be able to monitor old windows machines.

bug platforwindows

Most helpful comment

:+1: for Win 32bit binary. I have old windows machines to monitor.

I think the cause of above error is that Godeps_windows has wrong reference to github.com/shirou/gopsutil
I Changed it to the same version with linux like this.

diff --git a/Godeps_windows b/Godeps_windows
index cc3077f..b256791 100644
--- a/Godeps_windows
+++ b/Godeps_windows
@@ -43,7 +43,7 @@ github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
 github.com/prometheus/common e8eabff8812b05acf522b45fdcd725a785188e37
 github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
 github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
-github.com/shirou/gopsutil 1f32ce1bb380845be7f5d174ac641a2c592c0c42
+github.com/shirou/gopsutil 586bb697f3ec9f8ec08ffefe18f521a64534037c
 github.com/shirou/w32 ada3ba68f000aa1b58580e45c9d308fe0b7fc5c5
 github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
 github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744

That led to next error...

$ GOOS=windows GOARCH=386 make windows
<snip>
go build -o telegraf.exe -ldflags \
        "-X main.version=1.0.0-beta1-6-g06cb5a0" \
        ./cmd/telegraf/telegraf.go
# github.com/shirou/gopsutil/process
../../shirou/gopsutil/process/process_windows.go:260: cannot use mem.WorkingSetSize (type uint32) as type uint64 in field value
../../shirou/gopsutil/process/process_windows.go:261: cannot use mem.PagefileUsage (type uint32) as type uint64 in field value
Makefile:20: recipe for target 'build-windows' failed
make: *** [build-windows] Error 2

It seems that the types of variables are inconsistent. (uint32 vs uint64)

https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process_windows_386.go#L9
https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process.go#L40
https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process_windows.go#L260

I tried to handle it like following.

diff --git a/process/process.go b/process/process.go
index 4b69224..a59191d 100644
--- a/process/process.go
+++ b/process/process.go
@@ -37,8 +37,8 @@ type OpenFilesStat struct {
 }

 type MemoryInfoStat struct {
-       RSS  uint64 `json:"rss"`  // bytes
-       VMS  uint64 `json:"vms"`  // bytes
+       RSS  uint32 `json:"rss"`  // bytes
+       VMS  uint32 `json:"vms"`  // bytes
        Swap uint64 `json:"swap"` // bytes
 }

And finally, I could get the binary. But It crashes soon after I start it.

<snip>
unexpected fault address 0x2d33f754
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0x2d33f754 pc=0x488315]

goroutine 25 [running]:
runtime.throw(0xe799e8, 0x5)
        /usr/local/go/src/runtime/panic.go:547 +0x7f fp=0x12487e48 sp=0x12487e3c

runtime.sigpanic()
        /usr/local/go/src/runtime/signal_windows.go:164 +0x116 fp=0x12487e60 sp=0x12487e48
syscall.UTF16ToString(0x2d33f754, 0x20000000, 0x20000000, 0x0, 0x0)
        /usr/local/go/src/syscall/syscall_windows.go:51 +0x35 fp=0x12487e88 sp=0x12487e60
github.com/lxn/win.UTF16PtrToString(0x2d33f754, 0x0, 0x0)
<snip>

Do you have any advise on this?

All 6 comments

:+1: for Win 32bit binary. I have old windows machines to monitor.

I think the cause of above error is that Godeps_windows has wrong reference to github.com/shirou/gopsutil
I Changed it to the same version with linux like this.

diff --git a/Godeps_windows b/Godeps_windows
index cc3077f..b256791 100644
--- a/Godeps_windows
+++ b/Godeps_windows
@@ -43,7 +43,7 @@ github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
 github.com/prometheus/common e8eabff8812b05acf522b45fdcd725a785188e37
 github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
 github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
-github.com/shirou/gopsutil 1f32ce1bb380845be7f5d174ac641a2c592c0c42
+github.com/shirou/gopsutil 586bb697f3ec9f8ec08ffefe18f521a64534037c
 github.com/shirou/w32 ada3ba68f000aa1b58580e45c9d308fe0b7fc5c5
 github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
 github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744

That led to next error...

$ GOOS=windows GOARCH=386 make windows
<snip>
go build -o telegraf.exe -ldflags \
        "-X main.version=1.0.0-beta1-6-g06cb5a0" \
        ./cmd/telegraf/telegraf.go
# github.com/shirou/gopsutil/process
../../shirou/gopsutil/process/process_windows.go:260: cannot use mem.WorkingSetSize (type uint32) as type uint64 in field value
../../shirou/gopsutil/process/process_windows.go:261: cannot use mem.PagefileUsage (type uint32) as type uint64 in field value
Makefile:20: recipe for target 'build-windows' failed
make: *** [build-windows] Error 2

It seems that the types of variables are inconsistent. (uint32 vs uint64)

https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process_windows_386.go#L9
https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process.go#L40
https://github.com/shirou/gopsutil/blob/586bb697f3ec9f8ec08ffefe18f521a64534037c/process/process_windows.go#L260

I tried to handle it like following.

diff --git a/process/process.go b/process/process.go
index 4b69224..a59191d 100644
--- a/process/process.go
+++ b/process/process.go
@@ -37,8 +37,8 @@ type OpenFilesStat struct {
 }

 type MemoryInfoStat struct {
-       RSS  uint64 `json:"rss"`  // bytes
-       VMS  uint64 `json:"vms"`  // bytes
+       RSS  uint32 `json:"rss"`  // bytes
+       VMS  uint32 `json:"vms"`  // bytes
        Swap uint64 `json:"swap"` // bytes
 }

And finally, I could get the binary. But It crashes soon after I start it.

<snip>
unexpected fault address 0x2d33f754
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0x2d33f754 pc=0x488315]

goroutine 25 [running]:
runtime.throw(0xe799e8, 0x5)
        /usr/local/go/src/runtime/panic.go:547 +0x7f fp=0x12487e48 sp=0x12487e3c

runtime.sigpanic()
        /usr/local/go/src/runtime/signal_windows.go:164 +0x116 fp=0x12487e60 sp=0x12487e48
syscall.UTF16ToString(0x2d33f754, 0x20000000, 0x20000000, 0x0, 0x0)
        /usr/local/go/src/syscall/syscall_windows.go:51 +0x35 fp=0x12487e88 sp=0x12487e60
github.com/lxn/win.UTF16PtrToString(0x2d33f754, 0x0, 0x0)
<snip>

Do you have any advise on this?

Hi @sparrc @notok any idea on how to fix this issue? I will need telegraf also for Win32 machines.

Thank you very much

Forget to mention that my workaround inside the Makefile worked fine after upgrading to go 1.6

@toni-moreno , could you test making this change on Makefile?

build-windows:
        GOOS=windows GOARCH=386 go build -o telegraf.exe -ldflags \
                "-X main.version=$(VERSION)" \
                ./cmd/telegraf/telegraf.go

After that execute:

 make windows

PS: This is just a workaround.

@bernardoVale can you post your entire makefile? I cannot seem to get a exe out of this.

I'm having issues building for x86 as well. Creating telegraf.exe works fine, but when running it crashes on the first attempt to gather metrics.

This is the log:

http://pastebin.com/nUyMShcw

Any idea what's going on? I'm not getting an error anywhere while building.

@notok How do you solve the problem of crash ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SongYg picture SongYg  路  3Comments

efficks picture efficks  路  3Comments

veerendra2 picture veerendra2  路  3Comments

timhallinflux picture timhallinflux  路  3Comments

hluaces picture hluaces  路  3Comments