Révision 95ebf419
[fresh-backups] Show backup counts as stacked areas by age
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
| plugins/backup/fresh-backups | ||
|---|---|---|
| 1 |
#!/bin/sh -u |
|
| 1 |
#!/bin/bash -u
|
|
| 2 | 2 |
|
| 3 | 3 |
: << =cut |
| 4 | 4 |
|
| ... | ... | |
| 39 | 39 |
|
| 40 | 40 |
=head1 AUTHOR |
| 41 | 41 |
|
| 42 |
Olivier Mehani <shtrom+munin@ssji.net> |
|
| 42 |
Copyright (C) 2016,2019 Olivier Mehani <shtrom+munin@ssji.net>
|
|
| 43 | 43 |
|
| 44 | 44 |
=head1 LICENSE |
| 45 | 45 |
|
| 46 |
GPLv2
|
|
| 46 |
SPDX-License-Identifier: GPL-3.0-or-later
|
|
| 47 | 47 |
|
| 48 | 48 |
=head1 MAGIC MARKERS |
| 49 | 49 |
|
| ... | ... | |
| 51 | 51 |
|
| 52 | 52 |
=cut |
| 53 | 53 |
|
| 54 |
# Bash is needed for this array to work |
|
| 55 |
COLOUR=(00FF00 24DA00 48B600 6D9100 916D00 B64800 DA2400 FF0000) # green to red |
|
| 56 |
|
|
| 54 | 57 |
if [ "${MUNIN_DEBUG:-0}" = 1 ]; then
|
| 55 | 58 |
set -x |
| 56 | 59 |
fi |
| ... | ... | |
| 73 | 76 |
graph_info Number of fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR}
|
| 74 | 77 |
graph_args -l 0 |
| 75 | 78 |
graph_category backup |
| 76 |
freshcount.label files fresher than ${LIFETIME}d
|
|
| 79 |
age0.label today |
|
| 80 |
age0.draw AREA |
|
| 81 |
age0.colour ${COLOUR[0]}
|
|
| 82 |
age0.critical : |
|
| 83 |
age0.warning : |
|
| 84 |
EOF |
|
| 85 |
for AGE in $(seq 1 "${LIFETIME}"); do
|
|
| 86 |
cat << EOF |
|
| 87 |
age${AGE}.label older than $((AGE*24))h
|
|
| 88 |
age${AGE}.draw STACK
|
|
| 89 |
age${AGE}.colour ${COLOUR[$AGE]}
|
|
| 90 |
age${AGE}.warning :
|
|
| 91 |
age${AGE}.critical :
|
|
| 92 |
EOF |
|
| 93 |
done |
|
| 94 |
cat << EOF |
|
| 95 |
freshcount.label ${ARCHIVE_PATTERN} files fresher than ${LIFETIME}d
|
|
| 77 | 96 |
freshcount.critical ${CRIT}:
|
| 78 | 97 |
freshcount.warning ${WARN}:
|
| 98 |
freshcount.colour 0080FF |
|
| 79 | 99 |
EOF |
| 80 | 100 |
exit 0;; |
| 81 | 101 |
esac |
| 82 | 102 |
|
| 83 |
printf "freshcount.value " |
|
| 84 |
find "${BACKUP_DIR}" -name "${ARCHIVE_PATTERN}" -mmin "-$(((LIFETIME+1)*60*24))" | wc -l
|
|
| 85 |
printf "freshcount.extinfo " |
|
| 86 |
du -sh "${BACKUP_DIR}"
|
|
| 103 |
for AGE in $(seq 0 "${LIFETIME}"); do
|
|
| 104 |
FILES=$(find "${BACKUP_DIR}" \
|
|
| 105 |
-name "${ARCHIVE_PATTERN}" \
|
|
| 106 |
-mmin "-$(((AGE+1)*60*24))" \ |
|
| 107 |
-not -mmin "-$(((AGE)*60*24))" \ |
|
| 108 |
) |
|
| 109 |
COUNT="$(echo "${FILES}" \
|
|
| 110 |
| wc -l)" |
|
| 111 |
echo "age${AGE}.value $((COUNT))"
|
|
| 112 |
# shellcheck disable=SC2086 |
|
| 113 |
echo "age${AGE}.extinfo $(echo ${FILES} | sort | sed "s^${BACKUP_DIR}^^g")"
|
|
| 114 |
done |
|
| 115 |
|
|
| 116 |
COUNT=$(find "${BACKUP_DIR}" \
|
|
| 117 |
-name "${ARCHIVE_PATTERN}" \
|
|
| 118 |
-mmin "-$(((LIFETIME+1)*60*24))" \ |
|
| 119 |
| wc -l) |
|
| 120 |
# The last count is also our total count |
|
| 121 |
echo "freshcount.value ${COUNT}"
|
|
| 122 |
echo "freshcount.extinfo $(du -sh "${BACKUP_DIR}")"
|
|
Formats disponibles : Unified diff