diff --git a/Dockerfile b/Dockerfile index 6252624..7c5941a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ COPY prometheus-borg-exporter/borg_exporter.rc /etc/ # Install packages RUN apk update ; apk upgrade RUN apk add --no-cache sudo bash bash-completion tzdata openssh openrc neofetch \ - borgbackup dateutils prometheus-node-exporter curl + borgbackup dateutils prometheus-node-exporter curl wget RUN rm -rf /var/cache/apk/* # Setup SSH-Server diff --git a/bash-config/.bashrc b/bash-config/.bashrc index cac01c3..c67a2df 100644 --- a/bash-config/.bashrc +++ b/bash-config/.bashrc @@ -15,6 +15,7 @@ export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e # Borg Repo finder ############################################################################################################################## source "/variables.sh" +COLUMNS=$(/usr/bin/tput cols) function find_borg_repo { repo_list=( $(find "$1" -name "index.*" -type f | rev | cut -d '/' -f "2-" | rev) ) diff --git a/entrypoint-script/variables.sh b/entrypoint-script/variables.sh index b9b74bb..3e7a80e 100644 --- a/entrypoint-script/variables.sh +++ b/entrypoint-script/variables.sh @@ -2,9 +2,20 @@ DOCKER_IMAGE_VERSION="2.0.0" BORG_VERSION=$(borg -V) SSH_FOLDERS=( "/sshkeys/clients" "/sshkeys/host" ) NODE_EXPORTER_DIR="/logs" +COLUMNS="86" ############################################################################################################################## # Funktionen ############################################################################################################################## function sepurator { - echo "======================================================================================" + if [ ! -z "$2" ]; then + local end="$2" + else + local end="$COLUMNS" + fi + + local start=1 + local str="${1:-=}" + local range=$(seq $start $end) + for i in $range ; do echo -n "${str}"; done + echo; } diff --git a/prometheus-borg-exporter/borg_exporter.sh b/prometheus-borg-exporter/borg_exporter.sh index 5f330e8..2942df0 100755 --- a/prometheus-borg-exporter/borg_exporter.sh +++ b/prometheus-borg-exporter/borg_exporter.sh @@ -205,6 +205,13 @@ function cleanup() { writeDefinitionsToMetrics if [ -n "${REPOSITORY}" ]; then getBorgDataForRepository "${REPOSITORY}" "${HOSTNAME}" + if [ ! -z "${READ_BASEREPODIR}" ]; then + if [ -d "${BASEREPODIR}" ]; then + findRepositorysAndGetData + else + echo "Error: Set BASEREPODIR in /etc/borg_exporter.rc" + fi + fi else #discover (recursively) borg repositories starting from a path and extract info for each #(e.g. when running on the backup server directly)