-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Vcpu Wait metric * Bump libvirt-go to libvirt-go 7 * gitignore: add libvirt-exporter * Get vcpu.Wait only if instance is active * Update docker builder and build_static to use new libvirt * Fix buildindocker to build dynamically linked with current libvirt * Fix Dockerfile to build dynamically linked with alpine's libvirt * Remove static builds and old building scripts * Add new build scripts * Remove libvirt-patches as we don't need them anymore * Make readme more informative * Add Dockerfile for ubuntu1604
Showing
124 changed files
with
16,309 additions
and
3,726 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
/libvirt_exporter | ||
libvirt-exporter |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,18 @@ | ||
# Stage 1: Build libvirt exporter | ||
FROM golang:alpine | ||
|
||
# Install dependencies | ||
RUN apk add --update git gcc g++ make libc-dev portablexdr-dev linux-headers libnl-dev perl libtirpc-dev pkgconfig wget libtirpc libtirpc-static patch | ||
RUN wget ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz -P /tmp && \ | ||
tar -xf /tmp/libxml2-2.9.4.tar.gz -C /tmp | ||
WORKDIR /tmp/libxml2-2.9.4 | ||
RUN ./configure --disable-shared --enable-static && \ | ||
make -j2 && \ | ||
make install | ||
RUN wget https://libvirt.org/sources/libvirt-3.2.0.tar.xz -P /tmp && \ | ||
tar -xf /tmp/libvirt-3.2.0.tar.xz -C /tmp | ||
WORKDIR /tmp/libvirt-3.2.0 | ||
COPY libvirt-patches libvirt-patches | ||
ENV LIBVIRT_EXPORTER_PATH=/libvirt-exporter | ||
|
||
RUN patch -i libvirt-patches/0001-musl.patch -p1 && \ | ||
./configure --disable-shared --enable-static --localstatedir=/var --without-storage-mpath && \ | ||
make -j2 && \ | ||
RUN apk add ca-certificates g++ git go libnl-dev linux-headers make libvirt-dev libvirt && \ | ||
wget ftp://xmlsoft.org/libxml2/libxml2-2.9.8.tar.gz -P /tmp && \ | ||
tar -xf /tmp/libxml2-2.9.8.tar.gz -C /tmp/ && \ | ||
cd /tmp/libxml2-2.9.8 && \ | ||
./configure && \ | ||
make -j$(nproc) && \ | ||
make install && \ | ||
sed -i 's/^Libs:.*/& -lnl -ltirpc -lxml2/' /usr/local/lib/pkgconfig/libvirt.pc | ||
|
||
# Prepare working directory | ||
ENV LIBVIRT_EXPORTER_PATH=/go/src/github.com/rumanzo/libvirt_exporter_improved | ||
RUN mkdir -p $LIBVIRT_EXPORTER_PATH | ||
mkdir -p $LIBVIRT_EXPORTER_PATH | ||
WORKDIR $LIBVIRT_EXPORTER_PATH | ||
COPY . . | ||
|
||
# Build and strip exporter | ||
RUN go get -d ./... && \ | ||
go build --ldflags '-extldflags "-static"' && \ | ||
strip libvirt-exporter | ||
|
||
# Stage 2: Prepare final image | ||
FROM scratch | ||
|
||
# Copy binary from Stage 1 | ||
COPY --from=0 /go/src/github.com/rumanzo/libvirt_exporter_improved/libvirt-exporter . | ||
RUN go build | ||
|
||
# Entrypoint for starting exporter | ||
ENTRYPOINT [ "./libvirt-exporter" ] |
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,27 @@ | ||
#!/bin/bash | ||
|
||
if [[ "$#" -ne 1 ]]; then | ||
printf "Need one arg. One of:\n" | ||
ls -d ./build_containers/* | ||
exit 1 | ||
fi | ||
|
||
if [ -f "${1}" ]; then | ||
DOCKERFILE=$1 | ||
else | ||
echo "Wrong argument, must be one of:" | ||
ls -d ./build_containers/* | ||
exit 1 | ||
fi | ||
|
||
set -xeu | ||
|
||
DOCKERFILE=$1 | ||
BINARY_NAME=libvirt-exporter | ||
|
||
docker build -t libvirtexporterbuild -f ${DOCKERFILE} . | ||
docker run --rm \ | ||
-v "$PWD":/libvirt-exporter -w /libvirt-exporter \ | ||
-e GOOS=linux \ | ||
-e GOARCH=amd64 \ | ||
libvirtexporterbuild:latest go build -o ${BINARY_NAME} |
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,10 @@ | ||
FROM ubuntu:xenial | ||
|
||
ENV PATH=$PATH:/usr/local/go/bin | ||
|
||
RUN set -ex && \ | ||
apt update && \ | ||
DEBIAN_FRONTEND=noninteractive apt install -yq g++ libvirt0 libvirt-dev wget && \ | ||
wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz && \ | ||
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.2.linux-amd64.tar.gz && \ | ||
export PATH=$PATH:/usr/local/go/bin |
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,10 @@ | ||
FROM ubuntu:bionic | ||
|
||
ENV PATH=$PATH:/usr/local/go/bin | ||
|
||
RUN set -ex && \ | ||
apt update && \ | ||
DEBIAN_FRONTEND=noninteractive apt install -yq g++ libvirt0 libvirt-dev wget && \ | ||
wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz && \ | ||
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.2.linux-amd64.tar.gz && \ | ||
export PATH=$PATH:/usr/local/go/bin |
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,10 @@ | ||
FROM ubuntu:focal | ||
|
||
ENV PATH=$PATH:/usr/local/go/bin | ||
|
||
RUN set -ex && \ | ||
apt update && \ | ||
DEBIAN_FRONTEND=noninteractive apt install -yq g++ libvirt0 libvirt-dev wget && \ | ||
wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz && \ | ||
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.2.linux-amd64.tar.gz && \ | ||
export PATH=$PATH:/usr/local/go/bin |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.