2017-08-03 18:54:05 +00:00
|
|
|
PREFIX := /usr/local
|
2017-06-27 20:24:06 +00:00
|
|
|
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
|
|
|
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
COMMIT := $(shell git rev-parse --short HEAD)
|
2015-11-20 22:23:48 +00:00
|
|
|
ifdef GOBIN
|
|
|
|
PATH := $(GOBIN):$(PATH)
|
|
|
|
else
|
|
|
|
PATH := $(subst :,/bin:,$(GOPATH))/bin:$(PATH)
|
2015-09-10 17:01:08 +00:00
|
|
|
endif
|
2015-08-04 20:52:44 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
TELEGRAF := telegraf$(shell go tool dist env | grep -q 'GOOS=.windows.' && echo .exe)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-08-09 18:47:55 +00:00
|
|
|
all:
|
|
|
|
$(MAKE) deps
|
|
|
|
$(MAKE) telegraf
|
2017-08-03 18:54:05 +00:00
|
|
|
|
|
|
|
deps:
|
|
|
|
go get github.com/sparrc/gdm
|
|
|
|
gdm restore
|
|
|
|
|
|
|
|
telegraf:
|
2017-08-21 21:44:53 +00:00
|
|
|
go build -i -o $(TELEGRAF) -ldflags "$(LDFLAGS)" ./cmd/telegraf/telegraf.go
|
2015-12-04 18:44:56 +00:00
|
|
|
|
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
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
install: telegraf
|
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
cp $(TELEGRAF) $(DESTDIR)$(PREFIX)/bin/
|
2015-08-04 20:52:44 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
test:
|
|
|
|
go test -short ./...
|
|
|
|
|
|
|
|
test-windows:
|
|
|
|
go test ./plugins/inputs/ping/...
|
|
|
|
go test ./plugins/inputs/win_perf_counters/...
|
2017-08-07 21:36:15 +00:00
|
|
|
go test ./plugins/inputs/win_services/...
|
2017-08-03 18:54:05 +00:00
|
|
|
|
|
|
|
lint:
|
|
|
|
go vet ./...
|
2016-01-30 18:30:01 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
test-all: lint
|
|
|
|
go test ./...
|
2015-12-21 19:49:56 +00:00
|
|
|
|
2016-02-18 04:57:33 +00:00
|
|
|
package:
|
|
|
|
./scripts/build.py --package --version="$(VERSION)" --platform=linux --arch=all --upload
|
2015-12-21 19:49:56 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
clean:
|
|
|
|
-rm -f telegraf
|
|
|
|
-rm -f telegraf.exe
|
2016-01-29 18:02:54 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
# Run all docker containers necessary for integration tests
|
2015-10-27 17:50:16 +00:00
|
|
|
docker-run:
|
2016-08-24 08:03:17 +00:00
|
|
|
docker run --name aerospike -p "3000:3000" -d aerospike/aerospike-server:3.9.0
|
2017-06-08 01:22:28 +00:00
|
|
|
docker run --name zookeeper -p "2181:2181" -d wurstmeister/zookeeper
|
2015-10-27 17:50:16 +00:00
|
|
|
docker run --name kafka \
|
2017-06-08 01:22:28 +00:00
|
|
|
--link zookeeper:zookeeper \
|
|
|
|
-e KAFKA_ADVERTISED_HOST_NAME=localhost \
|
|
|
|
-e KAFKA_ADVERTISED_PORT=9092 \
|
|
|
|
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
|
|
|
|
-e KAFKA_CREATE_TOPICS="test:1:1" \
|
|
|
|
-p "9092:9092" \
|
|
|
|
-d wurstmeister/kafka
|
2017-03-21 00:47:57 +00:00
|
|
|
docker run --name elasticsearch -p "9200:9200" -p "9300:9300" -d elasticsearch:5
|
2015-10-27 17:50:16 +00:00
|
|
|
docker run --name mysql -p "3306:3306" -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql
|
|
|
|
docker run --name memcached -p "11211:11211" -d memcached
|
|
|
|
docker run --name postgres -p "5432:5432" -d postgres
|
|
|
|
docker run --name rabbitmq -p "15672:15672" -p "5672:5672" -d rabbitmq:3-management
|
|
|
|
docker run --name redis -p "6379:6379" -d redis
|
|
|
|
docker run --name nsq -p "4150:4150" -d nsqio/nsq /nsqd
|
2015-11-13 20:37:24 +00:00
|
|
|
docker run --name mqtt -p "1883:1883" -d ncarlier/mqtt
|
2017-01-27 22:54:59 +00:00
|
|
|
docker run --name riemann -p "5555:5555" -d stealthly/docker-riemann
|
2016-09-01 12:11:42 +00:00
|
|
|
docker run --name nats -p "4222:4222" -d nats
|
2017-04-03 14:30:53 +00:00
|
|
|
docker run --name openldap \
|
|
|
|
-e SLAPD_CONFIG_ROOTDN="cn=manager,cn=config" \
|
|
|
|
-e SLAPD_CONFIG_ROOTPW="secret" \
|
|
|
|
-p "389:389" -p "636:636" \
|
|
|
|
-d cobaugh/openldap-alpine
|
2015-08-18 16:16:59 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
# Run docker containers necessary for integration tests; skipping services provided
|
|
|
|
# by CircleCI
|
2015-10-27 22:22:21 +00:00
|
|
|
docker-run-circle:
|
2016-08-24 08:03:17 +00:00
|
|
|
docker run --name aerospike -p "3000:3000" -d aerospike/aerospike-server:3.9.0
|
2017-06-08 01:22:28 +00:00
|
|
|
docker run --name zookeeper -p "2181:2181" -d wurstmeister/zookeeper
|
2015-10-27 22:22:21 +00:00
|
|
|
docker run --name kafka \
|
2017-06-08 01:22:28 +00:00
|
|
|
--link zookeeper:zookeeper \
|
|
|
|
-e KAFKA_ADVERTISED_HOST_NAME=localhost \
|
|
|
|
-e KAFKA_ADVERTISED_PORT=9092 \
|
|
|
|
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
|
|
|
|
-e KAFKA_CREATE_TOPICS="test:1:1" \
|
|
|
|
-p "9092:9092" \
|
|
|
|
-d wurstmeister/kafka
|
2017-03-21 00:47:57 +00:00
|
|
|
docker run --name elasticsearch -p "9200:9200" -p "9300:9300" -d elasticsearch:5
|
2015-10-27 22:22:21 +00:00
|
|
|
docker run --name nsq -p "4150:4150" -d nsqio/nsq /nsqd
|
2015-11-13 20:37:24 +00:00
|
|
|
docker run --name mqtt -p "1883:1883" -d ncarlier/mqtt
|
2017-01-27 22:54:59 +00:00
|
|
|
docker run --name riemann -p "5555:5555" -d stealthly/docker-riemann
|
2016-09-01 12:11:42 +00:00
|
|
|
docker run --name nats -p "4222:4222" -d nats
|
2017-04-03 14:30:53 +00:00
|
|
|
docker run --name openldap \
|
|
|
|
-e SLAPD_CONFIG_ROOTDN="cn=manager,cn=config" \
|
|
|
|
-e SLAPD_CONFIG_ROOTPW="secret" \
|
|
|
|
-p "389:389" -p "636:636" \
|
|
|
|
-d cobaugh/openldap-alpine
|
2015-10-27 22:22:21 +00:00
|
|
|
|
2015-10-27 17:50:16 +00:00
|
|
|
docker-kill:
|
2017-08-03 18:54:05 +00:00
|
|
|
-docker kill aerospike elasticsearch kafka memcached mqtt mysql nats nsq \
|
|
|
|
openldap postgres rabbitmq redis riemann zookeeper
|
|
|
|
-docker rm aerospike elasticsearch kafka memcached mqtt mysql nats nsq \
|
|
|
|
openldap postgres rabbitmq redis riemann zookeeper
|
2016-02-19 21:46:03 +00:00
|
|
|
|
2017-08-03 18:54:05 +00:00
|
|
|
.PHONY: deps telegraf telegraf.exe install test test-windows lint test-all \
|
|
|
|
package clean docker-run docker-run-circle docker-kill
|