Révision cfa5206e
[backup/fresh-backups] move from system/
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
| plugins/backup/fresh-backups | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
|
|
| 3 |
: << =cut |
|
| 4 |
|
|
| 5 |
=head1 NAME |
|
| 6 |
|
|
| 7 |
fresh-backups - Plugin to monitor the freshness of backup files |
|
| 8 |
|
|
| 9 |
=head1 APPLICABLE SYSTEMS |
|
| 10 |
|
|
| 11 |
Any system with some automated backup creating or updating archive files. |
|
| 12 |
|
|
| 13 |
This works well with backup-manager. |
|
| 14 |
|
|
| 15 |
=head1 CONFIGURATION |
|
| 16 |
|
|
| 17 |
The following example checks all tar.bz2 files in /path/to/your/backups/, and |
|
| 18 |
counts all those that are less than 2 days old, and there should be 4 separate |
|
| 19 |
daily archives. |
|
| 20 |
|
|
| 21 |
[fresh-backups] |
|
| 22 |
user root |
|
| 23 |
env.backup_dir /path/to/your/backups/ |
|
| 24 |
env.lifetime 2 |
|
| 25 |
env.archive_pattern *.tar.bz2 |
|
| 26 |
env.backup_number 4 |
|
| 27 |
|
|
| 28 |
This will also set the warning and critical values for this plugin to 2*4 and |
|
| 29 |
4, respectively, meaning that if the number of fresh files goes below those |
|
| 30 |
limits, the relevant notifications will be triggerred. |
|
| 31 |
|
|
| 32 |
An example configuration snippet for backup-manager [0] follows. |
|
| 33 |
|
|
| 34 |
export BM_REPOSITORY_ROOT="/path/to/your/backups" |
|
| 35 |
export BM_TARBALL_FILETYPE="tar.bz2" |
|
| 36 |
export BM_TARBALL_DIRECTORIES="/etc /home /srv /data" |
|
| 37 |
|
|
| 38 |
[0] https://github.com/sukria/Backup-Manager |
|
| 39 |
|
|
| 40 |
=head1 AUTHOR |
|
| 41 |
|
|
| 42 |
Olivier Mehani <shtrom+munin@ssji.net> |
|
| 43 |
|
|
| 44 |
=head1 LICENSE |
|
| 45 |
|
|
| 46 |
GPLv2 |
|
| 47 |
|
|
| 48 |
=head1 MAGIC MARKERS |
|
| 49 |
|
|
| 50 |
#%# family=manual |
|
| 51 |
|
|
| 52 |
=cut |
|
| 53 |
|
|
| 54 |
# Configuration directives, edit before first use. |
|
| 55 |
BACKUP_DIR=${backup_dir:-/data/backup}
|
|
| 56 |
ARCHIVE_PATTERN="${archive_pattern:-*.tar.bz2}"
|
|
| 57 |
# How old backups should be considered as non-yound anymore in [days]. |
|
| 58 |
LIFETIME=${lifetime:-2}
|
|
| 59 |
# Critical states will be issued when the number of fresh backups archives is below `backup_number`, |
|
| 60 |
# and warnings below `backup_number*lifetime` |
|
| 61 |
CRIT=${backup_number:-1}
|
|
| 62 |
WARN=$((CRIT*LIFETIME)) |
|
| 63 |
|
|
| 64 |
# The situation is critical if there are no young files, the backup is down. |
|
| 65 |
case $1 in |
|
| 66 |
config) |
|
| 67 |
cat << EOF |
|
| 68 |
graph_title Fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR}
|
|
| 69 |
graph_vlabel number |
|
| 70 |
graph_args -l 0 |
|
| 71 |
graph_category backup |
|
| 72 |
freshcount.label number |
|
| 73 |
freshcount.critical ${CRIT}:
|
|
| 74 |
freshcount.warning ${WARN}:
|
|
| 75 |
EOF |
|
| 76 |
exit 0;; |
|
| 77 |
esac |
|
| 78 |
|
|
| 79 |
printf "freshcount.value " |
|
| 80 |
find "${BACKUP_DIR}" -name "${ARCHIVE_PATTERN}" -a -mtime "-${LIFETIME}" | wc -l
|
|
| 81 |
printf "freshcount.extinfo " |
|
| 82 |
du -sh "${BACKUP_DIR}"
|
|
| plugins/system/fresh-backups | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
|
|
| 3 |
: << =cut |
|
| 4 |
|
|
| 5 |
=head1 NAME |
|
| 6 |
|
|
| 7 |
fresh-backups - Plugin to monitor the freshness of backup files |
|
| 8 |
|
|
| 9 |
=head1 APPLICABLE SYSTEMS |
|
| 10 |
|
|
| 11 |
Any system with some automated backup creating or updating archive files. |
|
| 12 |
|
|
| 13 |
This works well with backup-manager. |
|
| 14 |
|
|
| 15 |
=head1 CONFIGURATION |
|
| 16 |
|
|
| 17 |
The following example checks all tar.bz2 files in /path/to/your/backups/, and |
|
| 18 |
counts all those that are less than 2 days old, and there should be 4 separate |
|
| 19 |
daily archives. |
|
| 20 |
|
|
| 21 |
[fresh-backups] |
|
| 22 |
user root |
|
| 23 |
env.backup_dir /path/to/your/backups/ |
|
| 24 |
env.lifetime 2 |
|
| 25 |
env.archive_pattern *.tar.bz2 |
|
| 26 |
env.backup_number 4 |
|
| 27 |
|
|
| 28 |
This will also set the warning and critical values for this plugin to 2*4 and |
|
| 29 |
4, respectively, meaning that if the number of fresh files goes below those |
|
| 30 |
limits, the relevant notifications will be triggerred. |
|
| 31 |
|
|
| 32 |
An example configuration snippet for backup-manager [0] follows. |
|
| 33 |
|
|
| 34 |
export BM_REPOSITORY_ROOT="/path/to/your/backups" |
|
| 35 |
export BM_TARBALL_FILETYPE="tar.bz2" |
|
| 36 |
export BM_TARBALL_DIRECTORIES="/etc /home /srv /data" |
|
| 37 |
|
|
| 38 |
[0] https://github.com/sukria/Backup-Manager |
|
| 39 |
|
|
| 40 |
=head1 AUTHOR |
|
| 41 |
|
|
| 42 |
Olivier Mehani <shtrom+munin@ssji.net> |
|
| 43 |
|
|
| 44 |
=head1 LICENSE |
|
| 45 |
|
|
| 46 |
GPLv2 |
|
| 47 |
|
|
| 48 |
=head1 MAGIC MARKERS |
|
| 49 |
|
|
| 50 |
#%# family=manual |
|
| 51 |
|
|
| 52 |
=cut |
|
| 53 |
|
|
| 54 |
# Configuration directives, edit before first use. |
|
| 55 |
BACKUP_DIR=${backup_dir:-/data/backup}
|
|
| 56 |
ARCHIVE_PATTERN="${archive_pattern:-*.tar.bz2}"
|
|
| 57 |
# How old backups should be considered as non-yound anymore in [days]. |
|
| 58 |
LIFETIME=${lifetime:-2}
|
|
| 59 |
# Critical states will be issued when the number of fresh backups archives is below `backup_number`, |
|
| 60 |
# and warnings below `backup_number*lifetime` |
|
| 61 |
CRIT=${backup_number:-1}
|
|
| 62 |
WARN=$((CRIT*LIFETIME)) |
|
| 63 |
|
|
| 64 |
# The situation is critical if there are no young files, the backup is down. |
|
| 65 |
case $1 in |
|
| 66 |
config) |
|
| 67 |
cat << EOF |
|
| 68 |
graph_title Fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR}
|
|
| 69 |
graph_vlabel number |
|
| 70 |
graph_args -l 0 |
|
| 71 |
graph_category backup |
|
| 72 |
freshcount.label number |
|
| 73 |
freshcount.critical ${CRIT}:
|
|
| 74 |
freshcount.warning ${WARN}:
|
|
| 75 |
EOF |
|
| 76 |
exit 0;; |
|
| 77 |
esac |
|
| 78 |
|
|
| 79 |
printf "freshcount.value " |
|
| 80 |
find "${BACKUP_DIR}" -name "${ARCHIVE_PATTERN}" -a -mtime "-${LIFETIME}" | wc -l
|
|
| 81 |
printf "freshcount.extinfo " |
|
| 82 |
du -sh "${BACKUP_DIR}"
|
|
| plugins/system/fresh-backups | ||
|---|---|---|
| 1 |
../backup/fresh-backups |
|
Formats disponibles : Unified diff