check_backuppc/check_backuppc_nb_bkp_v3

53 lines
1.2 KiB
Text
Raw Permalink Normal View History

2018-03-01 01:23:27 +01:00
#!/bin/bash
2024-10-07 12:39:38 +02:00
VERSION=dev
if [[ "$1" == "-v" ]] || [[ "$1" == "--version" ]] || [[ "$1" == "version" ]]; then
echo "$( basename "$0" ) - $VERSION"
exit 0
fi
2024-10-07 12:03:29 +02:00
[[ ! -d /var/lib/backuppc/pc ]] && echo "BackupPC directory not found (/var/lib/backuppc/pc)." && exit 1
if ! cd "/var/lib/backuppc/pc"; then
echo "Failed to enter in BackupPC directory (/var/lib/backuppc/pc)."
exit 1
fi
2018-03-01 01:23:27 +01:00
OUT="<table align=center>
<thead>
<tr>
<th rowspan=2 align=left>Host</th>
<th colspan=2>Nb backups</th>
<tr>
<th>Before V4</th>
<th>After V4</th>
</tr>
</thead>
<tbody>"
t_v3=0
t_v4=0
2024-10-07 12:03:29 +02:00
for h in *; do
if [[ ! -d "$h" ]] || [[ ! -e "$h/backups" ]]; then
continue
fi
vers=$( cut -f24 < "$h/backups" )
v3=$( grep -Evc '^4' <<< "$vers" )
((t_v3=t_v3+v3))
[[ "$v3" -ne 0 ]] && v3="<strong>$v3</strong>"
v4=$( grep -Ec '^4' <<< "$vers" )
((t_v4=t_v4+v4))
OUT="$OUT<tr><td align=left>$h</td><td>$v3</td><td>$v4</td></tr>"
2018-03-01 01:23:27 +01:00
done
2024-10-07 12:03:29 +02:00
[[ $t_v3 -gt 0 ]] && t_v3="<strong>$t_v3</strong>"
2018-03-01 01:23:27 +01:00
OUT="$OUT
</tbody>
<tfooter>
<tr>
<th align=right>Total :</th>
<th>$t_v3</th>
<th>$t_v4</th>
</tr>
</tfooter>
</table>"
2024-10-07 12:03:29 +02:00
lynx -stdin <<< "$OUT"
# vim:set sw=4 ts=4 sts=4 ft=bash expandtab: