安裝SNMP Notifier
git clone https://github.com/maxwo/snmp_notifier.git cd snmp_notifier make build ./snmp_notifier
make build報錯:dial tcp 142.251.43.17:443: i/o timeout
[root@huangning snmp_notifier]# make build >> building binaries GO111MODULE=on /root/go/bin/promu build --prefix /data/prometheus/snmp_notifier > snmp_notifier go: github.com/StackExchange/wmi@v0.0.0-20190523213315-cbe66965904d: Get "https://proxy.golang.org/github.com/%21stack%21exchange/wmi/@v/v0.0.0-20190523213315-cbe66965904d.mod": dial tcp 142.251.43.17:443: i/o timeout go: downloading github.com/go-kit/log v0.1.0 go: downloading github.com/prometheus/client_golang v1.11.0 go: downloading github.com/k-sone/snmpgo v3.2.0+incompatible go: downloading github.com/shirou/gopsutil v2.20.9+incompatible go: downloading github.com/prometheus/alertmanager v0.22.2 go: downloading github.com/prometheus/common v0.30.0 go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6 go: downloading github.com/gorilla/handlers v1.5.1 go: github.com/StackExchange/wmi@v0.0.0-20190523213315-cbe66965904d: Get "https://proxy.golang.org/github.com/%21stack%21exchange/wmi/@v/v0.0.0-20190523213315-cbe66965904d.mod": dial tcp 142.251.43.17:443: i/o timeout !! command failed: build -o /data/prometheus/snmp_notifier/snmp_notifier -ldflags -s -X github.com/prometheus/common/version.Version=1.2.1 -X github.com/prometheus/common/version.Revision=14ba67401c61cfc2f19ebd9ace8acdcf47b4cd49 -X github.com/prometheus/common/version.Branch=master -X github.com/prometheus/common/version.BuildUser=root@huangning -X github.com/prometheus/common/version.BuildDate=20220209-08:59:13 -extldflags '-static' -a -tags netgo github.com/maxwo/snmp_notifier: exit status 1 make: *** [common-build] 錯誤 1
解決方案:
配置goproxy
export GOPROXY=https://goproxy.io,direct export GO111MODULE=on
重新make build:
[root@huangning snmp_notifier]# make build >> building binaries GO111MODULE=on /root/go/bin/promu build --prefix /data/prometheus/snmp_notifier > snmp_notifier go: downloading github.com/go-kit/log v0.1.0 go: downloading github.com/prometheus/client_golang v1.11.0 go: downloading github.com/prometheus/common v0.30.0 go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6 go: downloading github.com/gorilla/handlers v1.5.1 go: downloading github.com/prometheus/alertmanager v0.22.2 go: downloading github.com/k-sone/snmpgo v3.2.0+incompatible go: downloading github.com/shirou/gopsutil v2.20.9+incompatible go: downloading github.com/go-logfmt/logfmt v0.5.0 go: downloading github.com/felixge/httpsnoop v1.0.1 go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 go: downloading github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 go: downloading github.com/pkg/errors v0.9.1 go: downloading github.com/prometheus/client_model v0.2.0 go: downloading github.com/golang/protobuf v1.4.3 go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1 go: downloading github.com/prometheus/procfs v0.6.0 go: downloading github.com/beorn7/perks v1.0.1 go: downloading github.com/cespare/xxhash/v2 v2.1.1 go: downloading github.com/cespare/xxhash v1.1.0 go: downloading google.golang.org/protobuf v1.26.0-rc.1 go: downloading golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 go: downloading github.com/geoffgarside/ber v1.1.0 go: downloading github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 go: downloading github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749