This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kpacha/mesos-dns
Mesos dns
- Loading branch information
Showing
28 changed files
with
878 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,5 @@ go: | |
- 1.4 | ||
|
||
install: | ||
- go get ./... | ||
- go fmt | ||
- make | ||
- go vet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
FROM golang:1.5.1-onbuild | ||
FROM golang:1.5.1 | ||
MAINTAINER kpacha | ||
|
||
ENV MESOS_MASTER_HOST=leader.mesos | ||
ENV MESOS_MASTER_PORT=5050 | ||
ENV MESOS_SLAVE_HOST=slave.mesos | ||
ENV MESOS_SLAVE_PORT=5051 | ||
|
||
ENV MARATHON_HOST=marathon.mesos | ||
ENV MARATHON_PORT=8080 | ||
|
||
ENV INFLUXDB_HOST=influxdb | ||
ENV INFLUXDB_PORT=8086 | ||
ENV INFLUXDB_DB=mesos | ||
ENV INFLUXDB_USER=root | ||
ENV INFLUXDB_PWD=root | ||
|
||
ENV COLLECTOR_LAPSE=1 | ||
ENV COLLECTOR_LIFETIME=1800 | ||
RUN mkdir -p /go/src/github.com/kpacha/mesos-influxdb-collector | ||
COPY . /go/src/github.com/kpacha/mesos-influxdb-collector | ||
|
||
WORKDIR /go/src/github.com/kpacha/mesos-influxdb-collector | ||
RUN make install | ||
|
||
ENTRYPOINT ["/go/bin/mesos-influxdb-collector"] | ||
|
||
CMD ["-c", "conf.hcl"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM busybox:1.24.1 | ||
MAINTAINER kpacha | ||
|
||
ENV INFLUXDB_USER=root | ||
ENV INFLUXDB_PWD=root | ||
|
||
COPY ./mesos-influxdb-collector /mesos-influxdb-collector | ||
COPY ./conf.hcl /conf.hcl | ||
|
||
ENTRYPOINT ["/./mesos-influxdb-collector"] | ||
|
||
CMD ["-c", "/conf.hcl"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
all: deps build test | ||
|
||
deps: | ||
go get github.com/hashicorp/hcl | ||
go get github.com/influxdb/influxdb/client | ||
|
||
gen: | ||
go fmt ./... | ||
|
||
build: | ||
sh -c 'CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o mesos-influxdb-collector' | ||
|
||
install: all do_install | ||
|
||
do_install: | ||
go install | ||
|
||
test: | ||
go test -cover ./... | ||
|
||
docker: | ||
docker run --rm -it -e "GOPATH=/go" -v "${PWD}:/go/src/github.com/kpacha/mesos-influxdb-collector" -w /go/src/github.com/kpacha/mesos-influxdb-collector golang:1.5.1 make | ||
docker build -f Dockerfile-min -t kpacha/mesos-influxdb-collector:mesos-dns-min . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package collector | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kpacha/mesos-influxdb-collector/config" | ||
"github.com/kpacha/mesos-influxdb-collector/parser/marathon" | ||
"github.com/kpacha/mesos-influxdb-collector/parser/mesos" | ||
"log" | ||
"net/url" | ||
) | ||
|
||
func NewCollectorFromConfig(configuration *config.Config) Collector { | ||
var collectors []Collector | ||
|
||
for _, master := range configuration.Master { | ||
collectors = append(collectors, NewMesosMasterCollector(master.Host, master.Port, master.Leader)) | ||
} | ||
for _, slave := range configuration.Slave { | ||
collectors = append(collectors, NewMesosSlaveCollector(slave.Host, slave.Port)) | ||
} | ||
for _, marathonInstance := range configuration.Marathon { | ||
collectors = append(collectors, NewMarathonCollector(marathonInstance.Host, marathonInstance.Port)) | ||
} | ||
|
||
log.Println("Total collectors created:", len(collectors)) | ||
|
||
return NewMultiCollector(collectors) | ||
} | ||
|
||
func NewMultiCollector(collectors []Collector) Collector { | ||
return MultiCollector{collectors} | ||
} | ||
|
||
func NewMesosLeaderCollector(host string, port int) Collector { | ||
return NewMesosMasterCollector(host, port, true) | ||
} | ||
|
||
func NewMesosMasterCollector(host string, port int, leader bool) Collector { | ||
u, err := url.Parse(fmt.Sprintf("http://%s:%d/metrics/snapshot", host, port)) | ||
if err != nil { | ||
log.Fatal("Error building the mesos master collector:", err) | ||
} | ||
return UrlCollector{Url: u.String(), Parser: mesos.MasterParser{Node: host, Leader: leader}} | ||
} | ||
|
||
func NewMesosSlaveCollector(host string, port int) Collector { | ||
u, err := url.Parse(fmt.Sprintf("http://%s:%d/metrics/snapshot", host, port)) | ||
if err != nil { | ||
log.Fatal("Error building the mesos slave collector:", err) | ||
} | ||
return UrlCollector{Url: u.String(), Parser: mesos.SlaveParser{Node: host}} | ||
} | ||
|
||
func NewMarathonCollector(host string, port int) Collector { | ||
u, err := url.Parse(fmt.Sprintf("http://%s:%d/metrics", host, port)) | ||
if err != nil { | ||
log.Fatal("Error building the marathon collector:", err) | ||
} | ||
return UrlCollector{Url: u.String(), Parser: marathon.MarathonParser{Node: host}} | ||
} |
Oops, something went wrong.