{{tag>Windows i386 Prometheus Go}} # Prometheus windows_export i386 compilation go lang **Brouillon** Nous avons besoin de récupérer le maximum de métriques sur un OS XP 32bits. Une solution est d'utiliser ''windows_export'' (ancienement ''wmi_exporter'') de Prometheus, cependant nous n'avons pas de version 32 bits compilée fournie par le projet. // Source : https://github.com/prometheus-community/windows_exporter // ** Ca ne marche pas en compilant ** ** Go 1.10 is the last release to support Windows Vista or below ** Voir : * https://github.com/golang/go/issues/23380 * https://github.com/prometheus-community/windows_exporter/issues/486 * https://github.com/prometheus-community/windows_exporter/issues/521 La dernière version compatible Win32 : * https://github.com/prometheus-community/windows_exporter/releases/tag/v0.9.0 * https://github.com/prometheus-community/windows_exporter/releases/download/v0.9.0/wmi_exporter-0.9.0-386.msi ## Usage C:\Program Files\windows_exporter\ ## Command line Usage ~~~ --config.file=CONFIG.FILE --collectors.enabled="cpu,cs,memory,logical_disk,physical_disk,net,os,service,system" --collector.tcp.enabled="metrics,connections_state" --collector.performancecounter.objects="" --collector.netframework.enabled="clrexceptions,clrinterop,clrjit,clrloading,clrlocksandthreads,clrmemory,clrremoting,clrsecurity" --collector.process.include=".+" --collector.scheduled_task.include=".+ --collector.service.include=".+" --collector.net.enabled="metrics,nic_addresses" --collector.net.nic-include=".+" --collector.time.enabled="system_time,ntp" ~~~ ### Usage old version wmi_exporter-0.9.0 ~~~winbatch msiexec /i wmi_exporter-0.9.0-386.msi ENABLED_COLLECTORS=cpu,cs,logical_disk,logon,memory,net,os,process,service,system,tcp,vmware ~~~ On test : http://localhost:9182 ## Other https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md ~~~ time=2025-04-03T11:27:26.836Z level=WARN source=cs.go:75 msg="The cs collector is deprecated and will be removed in a future release. Logical processors has been moved to cpu_info collector. Physical memory has been moved to memory collector. Hostname has been moved to os collector." time=2025-04-03T11:27:26.836Z level=WARN source=os.go:108 msg="The os collect holds a number of deprecated metrics and will be removed mid 2025. See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information." collector=os ~~~ ---------- ## Old ## Compile sur Windows ~~~ set http_proxy=http://192.168.1.221:3128 set https_proxy=http://192.168.1.221:3128 go install github.com/prometheus/promu@latest set GOARCH=386 go install github.com/prometheus-community/windows_exporter@latest cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter promu build -v ~~~ ### Compiled on GNU+Linux WSL ~~~ sudo apt-get install gcc-multilib sudo apt-get install gcc-mingw-w64 go install github.com/prometheus/promu@latest export http_proxy=http://192.168.1.221:3128 export https_proxy=http://192.168.1.221:3128 GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-gcc export GOOS GOARCH CGO_ENABLED CXX CC go install github.com/prometheus-community/windows_exporter@latest cd ~/go/pkg/mod/github.com/prometheus-community/windows_exporter promu build -v ~~~ ~~~ go: downloading github.com/containerd/typeurl/v2 v2.2.3 go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb go: downloading github.com/gogo/protobuf v1.3.2 github.com/prometheus-community/windows_exporter/cmd/windows_exporter: go build github.com/prometheus-community/windows_exporter/cmd/windows_exporter: copying /tmp/go-build2685928784/b001/exe/a.out.exe: open windows_exporter.exe: permission denied !! command failed: build -o windows_exporter.exe -ldflags -X github.com/prometheus/common/version.Version= -X github.com/prometheus/common/version.Revision=non-git -X github.com/prometheus/common/version.Branch=non-git -X github.com/prometheus/common/version.BuildUser=management@vlbvmdevadm01 -X github.com/prometheus/common/version.BuildDate=20250403-08:47:02 -extldflags '-static' -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter: exit status 1 ~~~ Solution : remplacer ''build -o windows_exporter.exe'' par ''build -o /tmp/windows_exporter.exe'' ~~~ go build -o /tmp/windows_exporter.exe -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter ~~~ ### Err windows_exporter.exe is not a valid Win32 application Voir https://learn.microsoft.com/en-us/windows/win32/debug/pe-format ~~~bash $ file windows_exporter* windows_exporter.exe: PE32 executable (console) Intel 80386, for MS Windows, 13 sections windows_exporter_CompiledOnOuindoze.exe: PE32 executable (console) Intel 80386, for MS Windows, 13 section ~~~