2019-07-30 03:41:12 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
2018-07-12 05:57:46 +00:00
|
|
|
VERSION := $(shell git describe --exact-match --tags 2>nil)
|
|
|
|
HOME := $(HOMEPATH)
|
2019-07-30 03:41:12 +00:00
|
|
|
CGO_ENABLED ?= 0
|
|
|
|
export CGO_ENABLED
|
2018-07-12 05:57:46 +00:00
|
|
|
else
|
|
|
|
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
|
|
|
|
endif
|
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
PREFIX := /usr/local
|
2017-06-27 20:24:06 +00:00
|
|
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
COMMIT := $(shell git rev-parse --short HEAD)
|
2018-02-02 20:25:59 +00:00
|
|
|
GOFILES ?= $(shell git ls-files '*.go')
|
2018-10-19 20:32:54 +00:00
|
|
|
GOFMT ?= $(shell gofmt -l -s $(filter-out plugins/parsers/influx/machine.go, $(GOFILES)))
|
2018-04-10 22:35:58 +00:00
|
|
|
BUILDFLAGS ?=
|
2018-02-01 23:05:39 +00:00
|
|
|
|
2015-11-20 22:23:48 +00:00
|
|
|
ifdef GOBIN
|
|
|
|
PATH := $(GOBIN):$(PATH)
|
2018-07-12 05:57:46 +00:00
|
|
|
else
|
2018-07-24 21:57:24 +00:00
|
|
|
PATH := $(subst :,/bin:,$(shell go env GOPATH))/bin:$(PATH)
|
2015-09-10 17:01:08 +00:00
|
|
|
endif
|
2015-08-04 20:52:44 +00:00
|
|
|
|
2017-08-10 23:33:31 +00:00
|
|
|
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT) -X main.branch=$(BRANCH)
|
2017-06-27 20:24:06 +00:00
|
|
|
ifdef VERSION
|
|
|
|
LDFLAGS += -X main.version=$(VERSION)
|
|
|
|
endif
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: all
|
2017-08-09 18:47:55 +00:00
|
|
|
all:
|
2018-07-24 21:57:24 +00:00
|
|
|
@$(MAKE) --no-print-directory deps
|
|
|
|
@$(MAKE) --no-print-directory telegraf
|
2017-08-03 18:54:05 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: deps
|
2017-08-03 18:54:05 +00:00
|
|
|
deps:
|
2020-01-16 22:38:06 +00:00
|
|
|
go mod download
|
2017-08-03 18:54:05 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: telegraf
|
2017-08-03 18:54:05 +00:00
|
|
|
telegraf:
|
2018-05-04 21:08:23 +00:00
|
|
|
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
|
2015-12-04 18:44:56 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: go-install
|
2017-08-03 18:54:05 +00:00
|
|
|
go-install:
|
2017-08-07 22:47:20 +00:00
|
|
|
go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf
|
2016-01-29 18:02:54 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: install
|
2017-08-03 18:54:05 +00:00
|
|
|
install: telegraf
|
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin/
|
2018-06-13 01:37:50 +00:00
|
|
|
cp telegraf $(DESTDIR)$(PREFIX)/bin/
|
2015-08-04 20:52:44 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: test
|
2017-08-03 18:54:05 +00:00
|
|
|
test:
|
|
|
|
go test -short ./...
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: fmt
|
2018-02-01 23:05:39 +00:00
|
|
|
fmt:
|
2018-10-19 20:32:54 +00:00
|
|
|
@gofmt -s -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))
|
2018-02-01 23:05:39 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: fmtcheck
|
2018-02-01 23:05:39 +00:00
|
|
|
fmtcheck:
|
2018-04-10 22:35:58 +00:00
|
|
|
@if [ ! -z "$(GOFMT)" ]; then \
|
2018-02-01 23:05:39 +00:00
|
|
|
echo "[ERROR] gofmt has found errors in the following files:" ; \
|
|
|
|
echo "$(GOFMT)" ; \
|
|
|
|
echo "" ;\
|
|
|
|
echo "Run make fmt to fix them." ; \
|
|
|
|
exit 1 ;\
|
|
|
|
fi
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: test-windows
|
2017-08-03 18:54:05 +00:00
|
|
|
test-windows:
|
2018-06-22 00:46:58 +00:00
|
|
|
go test -short ./plugins/inputs/ping/...
|
|
|
|
go test -short ./plugins/inputs/win_perf_counters/...
|
|
|
|
go test -short ./plugins/inputs/win_services/...
|
|
|
|
go test -short ./plugins/inputs/procstat/...
|
|
|
|
go test -short ./plugins/inputs/ntpq/...
|
2017-08-03 18:54:05 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: vet
|
2018-02-01 23:05:39 +00:00
|
|
|
vet:
|
2018-03-28 00:30:51 +00:00
|
|
|
@echo 'go vet $$(go list ./... | grep -v ./plugins/parsers/influx)'
|
2018-04-10 22:35:58 +00:00
|
|
|
@go vet $$(go list ./... | grep -v ./plugins/parsers/influx) ; if [ $$? -ne 0 ]; then \
|
2018-02-01 23:05:39 +00:00
|
|
|
echo ""; \
|
|
|
|
echo "go vet has found suspicious constructs. Please remediate any reported errors"; \
|
|
|
|
echo "to fix them before submitting code for review."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
2020-01-16 22:38:06 +00:00
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
go mod verify
|
|
|
|
go mod tidy
|
|
|
|
@if ! git diff --quiet go.mod go.sum; then \
|
|
|
|
echo "please run go mod tidy and check in changes"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: check
|
|
|
|
check: fmtcheck vet
|
2020-01-16 22:38:06 +00:00
|
|
|
@$(MAKE) --no-print-directory tidy
|
2018-04-02 21:13:15 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: test-all
|
2018-04-02 21:13:15 +00:00
|
|
|
test-all: fmtcheck vet
|
2017-08-03 18:54:05 +00:00
|
|
|
go test ./...
|
2015-12-21 19:49:56 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: package
|
2016-02-18 04:57:33 +00:00
|
|
|
package:
|
2017-09-22 23:49:28 +00:00
|
|
|
./scripts/build.py --package --platform=all --arch=all
|
2017-11-07 21:54:36 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: package-release
|
|
|
|
package-release:
|
|
|
|
./scripts/build.py --release --package --platform=all --arch=all \
|
|
|
|
--upload --bucket=dl.influxdata.com/telegraf/releases
|
|
|
|
|
|
|
|
.PHONY: package-nightly
|
|
|
|
package-nightly:
|
|
|
|
./scripts/build.py --nightly --package --platform=all --arch=all \
|
|
|
|
--upload --bucket=dl.influxdata.com/telegraf/nightlies
|
|
|
|
|
|
|
|
.PHONY: clean
|
2017-08-03 18:54:05 +00:00
|
|
|
clean:
|
2018-02-01 23:05:39 +00:00
|
|
|
rm -f telegraf
|
|
|
|
rm -f telegraf.exe
|
2016-01-29 18:02:54 +00:00
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: docker-image
|
2017-09-22 23:49:28 +00:00
|
|
|
docker-image:
|
2018-10-11 07:05:51 +00:00
|
|
|
docker build -f scripts/stretch.docker -t "telegraf:$(COMMIT)" .
|
2017-09-22 23:49:28 +00:00
|
|
|
|
2018-03-28 00:30:51 +00:00
|
|
|
plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl
|
|
|
|
ragel -Z -G2 $^ -o $@
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: static
|
2018-07-02 23:34:40 +00:00
|
|
|
static:
|
|
|
|
@echo "Building static linux binary..."
|
|
|
|
@CGO_ENABLED=0 \
|
|
|
|
GOOS=linux \
|
|
|
|
GOARCH=amd64 \
|
|
|
|
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
|
|
|
|
|
2018-07-24 21:57:24 +00:00
|
|
|
.PHONY: plugin-%
|
2018-07-02 23:34:40 +00:00
|
|
|
plugin-%:
|
|
|
|
@echo "Starting dev environment for $${$(@)} input plugin..."
|
|
|
|
@docker-compose -f plugins/inputs/$${$(@)}/dev/docker-compose.yml up
|
|
|
|
|
2019-10-08 04:08:28 +00:00
|
|
|
.PHONY: ci-1.13
|
|
|
|
ci-1.13:
|
2020-02-25 20:05:44 +00:00
|
|
|
docker build -t quay.io/influxdb/telegraf-ci:1.13.8 - < scripts/ci-1.13.docker
|
|
|
|
docker push quay.io/influxdb/telegraf-ci:1.13.8
|
2019-10-08 04:08:28 +00:00
|
|
|
|
2019-05-30 01:54:44 +00:00
|
|
|
.PHONY: ci-1.12
|
2019-05-30 22:21:25 +00:00
|
|
|
ci-1.12:
|
2020-02-25 20:05:44 +00:00
|
|
|
docker build -t quay.io/influxdb/telegraf-ci:1.12.17 - < scripts/ci-1.12.docker
|
|
|
|
docker push quay.io/influxdb/telegraf-ci:1.12.17
|