add dockerfile
This commit is contained in:
parent
e5f2ee0e30
commit
b7a705351e
2 changed files with 34 additions and 2 deletions
23
Dockerfile
Normal file
23
Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
FROM debian:12
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y dateutils binutils borgbackup openssh-client && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
|
COPY borg_exporter.rc borg_exporter.sh /
|
||||||
|
|
||||||
|
# Authorize SSH Host
|
||||||
|
RUN mkdir -p /root/.ssh && \
|
||||||
|
chmod 0700 /root/.ssh
|
||||||
|
|
||||||
|
# See: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
|
||||||
|
COPY known_hosts /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
# Add the Keys
|
||||||
|
COPY id_rsa id_rsa.pub /root/.ssh/
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chmod 600 /root/.ssh/id_rsa && \
|
||||||
|
chmod 600 /root/.ssh/id_rsa.pub
|
||||||
|
|
||||||
|
CMD ["/borg_exporter.sh"]
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /etc/borg_exporter.rc
|
source /borg_exporter.rc
|
||||||
|
|
||||||
|
#sleep 30
|
||||||
|
|
||||||
TMP_FILE=$(mktemp /tmp/prometheus-borg-XXXXX)
|
TMP_FILE=$(mktemp /tmp/prometheus-borg-XXXXX)
|
||||||
DATEDIFF=`which datediff`
|
DATEDIFF=`which datediff`
|
||||||
|
@ -125,6 +127,9 @@ function getBorgDataForRepository {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
|
||||||
#print the definition of the metrics
|
#print the definition of the metrics
|
||||||
echo "# HELP borg_hours_from_last_archive How many hours have passed since the last archive was added to the repo (counted by borg_exporter.sh)" >> $TMP_FILE
|
echo "# HELP borg_hours_from_last_archive How many hours have passed since the last archive was added to the repo (counted by borg_exporter.sh)" >> $TMP_FILE
|
||||||
echo "# TYPE borg_hours_from_last_archive gauge" >> $TMP_FILE
|
echo "# TYPE borg_hours_from_last_archive gauge" >> $TMP_FILE
|
||||||
|
@ -173,7 +178,7 @@ else
|
||||||
getBorgDataForRepository $REPO $host
|
getBorgDataForRepository $REPO $host
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Error: Either set REPOSITORY or BASEREPODIR in /etc/borg_exporter.rc"
|
echo "Error: Either set REPOSITORY or BASEREPODIR in /borg_exporter.rc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -193,3 +198,7 @@ else
|
||||||
fi
|
fi
|
||||||
#cleanup
|
#cleanup
|
||||||
rm -f $TMP_FILE
|
rm -f $TMP_FILE
|
||||||
|
|
||||||
|
sleep 60
|
||||||
|
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue