diff --git a/.editorconfig b/.editorconfig index 7fef3e3..03c358e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,3 +4,4 @@ charset = utf-8 indent_size = 3 indent_style = space insert_final_newline = true +end_of_line = lf diff --git a/build/build.sh b/build/build.sh index bfc29bf..e8a43ad 100644 --- a/build/build.sh +++ b/build/build.sh @@ -23,6 +23,7 @@ go build --ldflags '-extldflags "-static"' cp dovecot_exporter $SCRIPTPATH/../exporter/dovecot_exporter/ +cd .. # ------------------------ # Postfix Exporter # ------------------------ @@ -35,7 +36,41 @@ go get -d ./... go build cp postfix_exporter $SCRIPTPATH/../exporter/postfix_exporter/ +cd .. +# ------------------------ +# FritzBox Exporter +# ------------------------ + +# echo "Building fritzbox_exporter" + +# git clone https://github.com/ndecker/fritzbox_exporter.git fritzbox_exporter +# cd fritzbox_exporter + +# rm -r vendor + +# go get -d ./... +# go build + +# cp fritzbox_exporter $SCRIPTPATH/../exporter/fritzbox_exporter/ + +# cd .. + + +# ------------------------ +# FritzBox Exporter +# ------------------------ +echo "Building connectivity_exporter" + +git clone https://git.stamm.me/Ops/ConnectivityExporter.git connectivity_exporter +cd connectivity_exporter + +npm install +npm run build + +cp connectivity-exporter $SCRIPTPATH/../exporter/connectivity_exporter/connectivity_exporter + +cd .. #go get gopkg.in/yaml.v2 diff --git a/exporter/connectivity_exporter/connectivity_exporter b/exporter/connectivity_exporter/connectivity_exporter new file mode 100644 index 0000000..c5a584c Binary files /dev/null and b/exporter/connectivity_exporter/connectivity_exporter differ diff --git a/exporter/connectivity_exporter/connectivity_exporter.service b/exporter/connectivity_exporter/connectivity_exporter.service new file mode 100644 index 0000000..85bee6e --- /dev/null +++ b/exporter/connectivity_exporter/connectivity_exporter.service @@ -0,0 +1,10 @@ +[Unit] +Description=Node Exporter + +[Service] +User=connectivity_exporter +EnvironmentFile=/etc/sysconfig/connectivity_exporter +ExecStart=/usr/prometheus/connectivity_exporter --config $CONFIG $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/exporter/connectivity_exporter/connectivity_exporter.sysconfig b/exporter/connectivity_exporter/connectivity_exporter.sysconfig new file mode 100644 index 0000000..da951d0 --- /dev/null +++ b/exporter/connectivity_exporter/connectivity_exporter.sysconfig @@ -0,0 +1,2 @@ +OPTIONS="" +CONFIG="/etc/sysconfig/connectivity_exporter.yaml" diff --git a/exporter/connectivity_exporter/connectivity_exporter.yaml b/exporter/connectivity_exporter/connectivity_exporter.yaml new file mode 100644 index 0000000..1f7b6db --- /dev/null +++ b/exporter/connectivity_exporter/connectivity_exporter.yaml @@ -0,0 +1 @@ +targets: [] diff --git a/exporter/connectivity_exporter/install.sh b/exporter/connectivity_exporter/install.sh new file mode 100644 index 0000000..635ce58 --- /dev/null +++ b/exporter/connectivity_exporter/install.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +if getent passwd connectivity_exporter > /dev/null 2>&1; then + echo "User already exists!" +else + adduser --system --no-create-home --group --shell=/bin/false connectivity_exporter +fi + +if service --status-all | grep -Fq 'connectivity_exporter'; then + service connectivity_exporter stop +fi + +echo "Copying exporter" + +mkdir -p /usr/prometheus + +echo "Checking/Creating systemd configuration" + +cp $SCRIPTPATH/connectivity_exporter /usr/prometheus/connectivity_exporter +chmod +x /usr/prometheus/connectivity_exporter + +cp $SCRIPTPATH/connectivity_exporter.service /etc/systemd/system/ + +[ ! -d /etc/sysconfig ] && mkdir /etc/sysconfig + +if [ -f "/etc/sysconfig/connectivity_exporter" ]; then + echo "/etc/sysconfig/connectivity_exporter already there. Skipping." +else + cp $SCRIPTPATH/connectivity_exporter.sysconfig /etc/sysconfig/connectivity_exporter +fi + +if [ -f "/etc/sysconfig/connectivity_exporter.yaml" ]; then + echo "/etc/sysconfig/connectivity_exporter.yaml already there. Skipping." +else + cp $SCRIPTPATH/connectivity_exporter.yaml /etc/sysconfig/connectivity_exporter.yaml +fi + +echo "Starting exporter" + +systemctl enable connectivity_exporter.service +service connectivity_exporter start + +echo "Exporter available at :9285"