For system where there is no datediff, use the alternate name
This commit is contained in:
parent
2ea4238a84
commit
e5f2ee0e30
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,11 @@
|
||||||
source /etc/borg_exporter.rc
|
source /etc/borg_exporter.rc
|
||||||
|
|
||||||
TMP_FILE=$(mktemp /tmp/prometheus-borg-XXXXX)
|
TMP_FILE=$(mktemp /tmp/prometheus-borg-XXXXX)
|
||||||
|
DATEDIFF=`which datediff`
|
||||||
|
if [ -z "$DATEDIFF" ]; then
|
||||||
|
#ubuntu packages have a different executable name
|
||||||
|
DATEDIFF=`which dateutils.ddiff`
|
||||||
|
fi
|
||||||
|
|
||||||
[ -e $TMP_FILE ] && rm -f $TMP_FILE
|
[ -e $TMP_FILE ] && rm -f $TMP_FILE
|
||||||
|
|
||||||
|
@ -57,7 +62,7 @@ function getBorgDataForRepository {
|
||||||
LAST_ARCHIVE_DATE=$(echo $LAST_ARCHIVE | awk '{print $3" "$4}')
|
LAST_ARCHIVE_DATE=$(echo $LAST_ARCHIVE | awk '{print $3" "$4}')
|
||||||
LAST_ARCHIVE_TIMESTAMP=$(date -d "$LAST_ARCHIVE_DATE" +"%s")
|
LAST_ARCHIVE_TIMESTAMP=$(date -d "$LAST_ARCHIVE_DATE" +"%s")
|
||||||
CURRENT_DATE="$(date '+%Y-%m-%d %H:%M:%S')"
|
CURRENT_DATE="$(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
NB_HOUR_FROM_LAST_BCK=$(datediff "$LAST_ARCHIVE_DATE" "$CURRENT_DATE" -f '%H')
|
NB_HOUR_FROM_LAST_BCK=$($DATEDIFF "$LAST_ARCHIVE_DATE" "$CURRENT_DATE" -f '%H')
|
||||||
|
|
||||||
# in case the date parsing from BORG didn't work (e.g. archive with space in it), datediff will output
|
# in case the date parsing from BORG didn't work (e.g. archive with space in it), datediff will output
|
||||||
# a usage message on stdout and will break prometheus formatting. We need to
|
# a usage message on stdout and will break prometheus formatting. We need to
|
||||||
|
|
Loading…
Reference in a new issue