-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oskar Jagodzinski
committed
Oct 7, 2019
1 parent
3c28919
commit b608230
Showing
5 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
dist |
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,42 @@ | ||
APPLICATION_NAME := prometheus-libvirt-exporter | ||
APPLICATION_VERSION := $(shell cat VERSION) | ||
|
||
LDFLAGS := -X $(APPLICATION_NAME)/meta.Version=$(APPLICATION_VERSION) | ||
|
||
GO_BUILD := go build -v -ldflags "$(LDFLAGS)" | ||
|
||
PATH := $(PWD)/build/dependencies:$(PATH) | ||
|
||
TEMPDIR := $(shell mktemp -d) | ||
|
||
all: build | ||
|
||
build_linux: | ||
env GOOS=linux GOARCH=amd64 GO111MODULE=on $(GO_BUILD) -o build/prometheus-libvirt-exporter ./prometheus-libvirt-exporter.go | ||
|
||
build: | ||
$(GO_BUILD) -o build/prometheus-libvirt-exporter ./prometheus-libvirt-exporter.go | ||
|
||
clean: | ||
go clean -v . | ||
rm -rf build | ||
|
||
FPM-exists: | ||
@fpm -v || \ | ||
(echo >&2 "FPM must be installed on the system. See https://github.com/jordansissel/fpm"; false) | ||
|
||
deb: FPM-exists build_linux | ||
mkdir -p dist/$(APPLICATION_VERSION)/ | ||
cd dist/$(APPLICATION_VERSION)/ && \ | ||
fpm -s dir \ | ||
-t deb \ | ||
-n prometheus-libvirt-exporter \ | ||
-v $(APPLICATION_VERSION) \ | ||
--url="https://github.com/zhangjianweibj/prometheus-libvirt-exporter" \ | ||
--description "Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors)" \ | ||
--deb-priority optional \ | ||
--workdir $(TEMPDIR) \ | ||
--architecture amd64 \ | ||
../../build/prometheus-libvirt-exporter=/usr/bin/prometheus-libvirt-exporter \ | ||
../../debian/prometheus-libvirt-exporter.service=/etc/systemd/system/prometheus-libvirt-exporter.service \ | ||
../../debian/prometheus-libvirt-exporter.upstart=/etc/init/prometheus-libvirt-exporter.conf |
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 @@ | ||
1.1 |
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,13 @@ | ||
[Unit] | ||
Description=Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors) | ||
Requires=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
ExecStart=/usr/bin/prometheus-libvirt-exporter -web.listen-address ":9180" | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
Restart=on-failure | ||
KillSignal=SIGINT | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,15 @@ | ||
description "Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors)" | ||
|
||
start on runlevel [2345] | ||
stop on runlevel [!2345] | ||
|
||
respawn | ||
|
||
script | ||
echo $$ > /var/run/prometheus-libvirt-exporter.pid | ||
exec prometheus-libvirt-exporter -web.listen-address ":9180" | ||
end script | ||
|
||
post-stop script | ||
rm -f /var/run/prometheus-libvirt-exporter.pid | ||
end script |