Node_exporter: freebsd build failed

Created on 21 Jul 2016  路  8Comments  路  Source: prometheus/node_exporter

OS: FreeBSD 10.3
GO: go version go1.6.2 freebsd/amd64

daemon node_exporter-0.12.0 # make       
>> formatting code
>> building binaries
 >   .
# runtime/cgo
cc: warning: argument unused during compilation: '-pthread'
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
>> running tests
# _/tmp/node_exporter-0.12.0
./node_exporter.go:86: cannot use ch (type chan<- "github.com/prometheus/client_golang/prometheus".Metric) as type chan<- "github.com/prometheus/node_exporter/vendor/github.com/prometheus/client_golang/prometheus".Metric in argument to c.Update
*** Error code 2

Stop.
make: stopped in /tmp/node_exporter-0.12.0
question

All 8 comments

@laamalif Have you been able to fix your problem? What's the golang version you were using? Have you setup the repository at $GOPATH/src/github.com/prometheus/node_exporter?

Yes GOPATH is /root/go

OS: FreeBSD 10.3
GO: go version go1.6.2 freebsd/amd64

daemon node_exporter (master*) # make
>> formatting code
>> building binaries
 >   node_exporter
can't load package: package github.com/prometheus/node_exporter: cannot find package "github.com/prometheus/node_exporter" in any of:
    /usr/local/go/src/github.com/prometheus/node_exporter (from $GOROOT)
    /root/go/src/github.com/prometheus/node_exporter (from $GOPATH)
[1]     /root/go/src/github.com/prometheus/node_exporter (from $GOPATH)

*** Error code 1

Stop.
make: stopped in /root/node_exporter
daemon node_exporter (master*) # go get github.com/prometheus/node_exporter
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
daemon node_exporter (master*) # make                                      
>> formatting code
>> building binaries
 >   node_exporter
# runtime/cgo
cc: warning: argument unused during compilation: '-pthread'
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
>> running tests
node_exporter.go:27:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
    /usr/local/go/src/github.com/prometheus/client_golang/prometheus (from $GOROOT)
    /root/go/src/github.com/prometheus/client_golang/prometheus (from $GOPATH)
node_exporter.go:28:2: cannot find package "github.com/prometheus/common/log" in any of:
    /usr/local/go/src/github.com/prometheus/common/log (from $GOROOT)
    /root/go/src/github.com/prometheus/common/log (from $GOPATH)
node_exporter.go:29:2: cannot find package "github.com/prometheus/common/version" in any of:
    /usr/local/go/src/github.com/prometheus/common/version (from $GOROOT)
    /root/go/src/github.com/prometheus/common/version (from $GOPATH)
*** Error code 1

Stop.
make: stopped in /root/node_exporter
daemon node_exporter (master*) # go github.com/prometheus/common/version
go: unknown subcommand "github.com/prometheus/common/version"
Run 'go help' for usage.
daemon node_exporter (master*) # go get github.com/prometheus/common/version
daemon node_exporter (master*) # go get github.com/prometheus/common/github.com/prometheus/client_golang/prometheus
package github.com/prometheus/common/github.com/prometheus/client_golang/prometheus: cannot find package "github.com/prometheus/common/github.com/prometheus/client_golang/prometheus" in any of:
    /usr/local/go/src/github.com/prometheus/common/github.com/prometheus/client_golang/prometheus (from $GOROOT)
    /root/go/src/github.com/prometheus/common/github.com/prometheus/client_golang/prometheus (from $GOPATH)
daemon node_exporter (master*) # go get github.com/prometheus/client_golang/prometheus                             
daemon node_exporter (master*) # make                                                 
>> formatting code
>> building binaries
 >   node_exporter
# runtime/cgo
cc: warning: argument unused during compilation: '-pthread'
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
>> running tests
# _/root/node_exporter
./node_exporter.go:86: cannot use ch (type chan<- "github.com/prometheus/client_golang/prometheus".Metric) as type chan<- "github.com/prometheus/node_exporter/vendor/github.com/prometheus/client_golang/prometheus".Metric in argument to c.Update
*** Error code 2

Stop.
make: stopped in /root/node_exporter

Also I to remove --prefix from Makefile to make command work.

daemon node_exporter (master) # make
>> formatting code
>> building binaries
Error: flag needs an argument: --prefix
Usage:
  promu build [flags]

Flags:
      --prefix string   Specific dir to store binaries (default is .)

Global Flags:
      --config string   Config file (default is ./.promu.yml)
  -v, --verbose         Verbose output
      --viper           Use Viper for configuration (default true)

flag needs an argument: --prefix
*** Error code 255

Stop.
make: stopped in /root/node_exporter

I tested this on 10.3-RELEASE-p3 today. There are some warnings, but the build completes successfully, and node_exporter runs.

I do have failing builds on FreeBSD 11-rc1, but that is a different matter.

127# echo $GOPATH
/tmp/gopath
127# pwd
/tmp/gopath/src/github.com/prometheus/node_exporter
127# PREFIX=. make
>> formatting code
>> building binaries
 >   node_exporter
# runtime/cgo
cc: warning: argument unused during compilation: '-pthread'
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
>> running tests
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
?       github.com/prometheus/node_exporter     [no test files]
127# ./node_exporter
INFO[0000] Starting node_exporter (version=0.12.0, branch=master, revision=428746c48e13ad61f83004e5a3d2aeabf348b36f)  source=node_exporter.go:135
INFO[0000] Build context (go=go1.6.2, [email protected], date=20160817-19:44:24)  source=node_exporter.go:136
INFO[0000] No directory specified, see --collector.textfile.directory  source=textfile.go:57
INFO[0000] Enabled collectors:                           source=node_exporter.go:155
INFO[0000]  - filesystem                                 source=node_exporter.go:157
INFO[0000]  - loadavg                                    source=node_exporter.go:157
INFO[0000]  - meminfo                                    source=node_exporter.go:157
INFO[0000]  - netdev                                     source=node_exporter.go:157
INFO[0000]  - textfile                                   source=node_exporter.go:157
INFO[0000]  - time                                       source=node_exporter.go:157
INFO[0000]  - cpu                                        source=node_exporter.go:157
INFO[0000] Listening on :9100                            source=node_exporter.go:176

@jevonearth could you give a short how-to get node_exporter binary?
i'm trying to build, but got this:

$echo $GOPATH
/tmp/gopath
$ uname -a
FreeBSD freebsd 10.0-RELEASE-p18 FreeBSD 10.0-RELEASE-p18 #0: Wed Feb 25 01:08:00 UTC 2015     [email protected]:/usr/obj/usr/src/sys/GENERIC  amd64
$ go version
go version go1.7.3 freebsd/amd64

$ PREFIX=. make
>> formatting code
>> building binaries
 >   node_exporter
# github.com/prometheus/node_exporter/collector
collector/netdev_bsd.go:66: data.ifi_oqdrops undefined (type *C.struct_if_data has no field or method ifi_oqdrops)
!! command failed: build -o node_exporter -ldflags -X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.Version=0.13.0 -X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.Revision=006d1c7922b765f458fe9b92ce646641bded0f52 -X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.Branch=master -X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.BuildUser=root@freebsd-home-nas -X github.com/prometheus/node_exporter/vendor/github.com/prometheus/common/version.BuildDate=20161207-07:16:59  -extldflags '-static' -a -tags 'netgo static_build' github.com/prometheus/node_exporter: exit status 2
*** Error code 1

Stop.
make: stopped in /tmp/gopath/src/github.com/prometheus/node_exporter

@Savemech I made a freebsd port for node_exporter. So you can install it from packages using pkg install sysutils/node_exporter or use the FreeBSD port by doing; (cd /usr/ports/sysutils/node_exporter; make install clean

I believe that this Issue can be closed, as the FreeBSD port exists. :)

@jevonearth yeah, thats awesome and works like a charm, but idk what to place in rc.conf to start at boot, any ideas? in rc.d there is no node_exporter definition, i'm could help to write some to improve that package.

$ pkg info node_exporter-0.13.0
node_exporter-0.13.0
Name           : node_exporter
Version        : 0.13.0
Installed on   : Tue Dec  6 09:23:57 2016 MSK
Origin         : sysutils/node_exporter
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : sysutils
Licenses       : APACHE20
Maintainer     : [email protected]
WWW            : https://github.com/prometheus/node_exporter
Comment        : Prometheus exporter for machine metrics
Annotations    :
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 10.8MiB
Description    :
node_exporter is a prometheus exporter for machine metrics, written in Go
with pluggable metric collectors.

WWW: https://github.com/prometheus/node_exporter

i hope zfs metrics will appear any soon;
But for basic knowledge i would like to knew this building process, to eliminate all possibly errors was I did trying to build node_exporter.

Hi @Savemech

To enable node_exporter on FreeBSD, put the line node_exporter_enable="YES" into /etc/rc.conf. Then reboot, or run the command service node_exporter start.

Have a look at the rc file /usr/local/etc/rc.d/node_exporter comments, and you will see some more options you can set in rc.conf

If you want to build it yourself, the following steps should get you going;

$ echo $GOPATH
 /home/jev/go
$ mkdir -p go/src/github.com/prometheus
$ cd go/src/github.com/prometheus
$ git clone https://github.com/prometheus/node_exporter.git
Cloning into 'node_exporter'...
remote: Counting objects: 2619, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 2619 (delta 3), reused 0 (delta 0), pack-reused 2606
Receiving objects: 100% (2619/2619), 1.30 MiB | 0 bytes/s, done.
Resolving deltas: 100% (1430/1430), done.
$ cd node_exporter
$ go install
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-gno-record-gcc-switches'
# github.com/prometheus/node_exporter/collector
cc: warning: argument unused during compilation: '-pthread'
cc: warning: argument unused during compilation: '-gno-record-gcc-switches'

You will then have a fresh node_exporter binary in $GOPATH/bin/node_exporter

@jevonearth Many thanks!

Was this page helpful?
0 / 5 - 0 ratings