Compare commits
6 commits
80aa2de86e
...
76a91c37e5
Author | SHA1 | Date | |
---|---|---|---|
|
76a91c37e5 | ||
|
ad909157e9 | ||
|
bb7b6969f7 | ||
|
e0714b51dc | ||
|
969b0ca1e3 | ||
|
a97930fdca |
14 changed files with 30 additions and 196 deletions
|
@ -1,15 +0,0 @@
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
|
|
||||||
[*.{yaml,yml}]
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[Makefile]
|
|
||||||
indent_style = tab
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
*~
|
*~
|
||||||
/dist
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
# Pre-commit hooks to run tests and ensure code is cleaned.
|
|
||||||
# See https://pre-commit.com for more information
|
|
||||||
---
|
|
||||||
repos:
|
|
||||||
- repo: https://github.com/codespell-project/codespell
|
|
||||||
rev: v2.2.2
|
|
||||||
hooks:
|
|
||||||
- id: codespell
|
|
||||||
args:
|
|
||||||
- --ignore-words-list=exten
|
|
||||||
- --skip="./.*,*.csv,*.json,*.ini,*.subject,*.txt,*.html,*.log,*.conf"
|
|
||||||
- --quiet-level=2
|
|
||||||
- --ignore-regex=.*codespell-ignore$
|
|
||||||
# - --write-changes # Uncomment to write changes
|
|
||||||
exclude_types: [csv, json]
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
||||||
rev: v2.7.1
|
|
||||||
hooks:
|
|
||||||
- id: prettier
|
|
||||||
args: ["--print-width", "100"]
|
|
||||||
- repo: https://github.com/adrienverge/yamllint
|
|
||||||
rev: v1.32.0
|
|
||||||
hooks:
|
|
||||||
- id: yamllint
|
|
||||||
ignore: .github/
|
|
||||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
||||||
rev: v0.10.0.1
|
|
||||||
hooks:
|
|
||||||
- id: shellcheck
|
|
18
README.md
18
README.md
|
@ -1,21 +1,25 @@
|
||||||
# Nagios/Icinga check plugins for BackupPC
|
Nagios/Icinga check plugins for BackupPC
|
||||||
|
========================================
|
||||||
|
|
||||||
This repository compile some useful Nagios/Icinga check plugins for BackupPC :
|
This repository compile some usefull Nagios/Icinga check plugins for BackupPC :
|
||||||
|
|
||||||
- _check_backuppc\* :_ Check the age of the last backup
|
* *check_backuppc\* :* Check the age of the last backup
|
||||||
- _check_backuppc_du :_ Check disk space use by backups
|
* *check_backuppc_du :* Check disk space use by backups
|
||||||
|
|
||||||
\* This check plugins was fork from [_check_backuppc_](https://sourceforge.net/projects/n-backuppc/) (version 1.1.0) write by Seneca Cunningham <tetragon@users.sourceforge.net>.
|
\* This check plugins was fork from [_check_backuppc_](https://sourceforge.net/projects/n-backuppc/) (version 1.1.0) write by Seneca Cunningham <tetragon@users.sourceforge.net>.
|
||||||
|
|
||||||
## Compatibility
|
Compatibility
|
||||||
|
-------------
|
||||||
|
|
||||||
This check plugins have been successfully test with BackupPC 3 (3.2.1) and 4 (4.1.5).
|
This check plugins have been successfully test with BackupPC 3 (3.2.1) and 4 (4.1.5).
|
||||||
|
|
||||||
## Copyright
|
Copyright
|
||||||
|
---------
|
||||||
|
|
||||||
Copyright (c) 2018 Easter-eggs
|
Copyright (c) 2018 Easter-eggs
|
||||||
|
|
||||||
## License
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
|
76
build.sh
76
build.sh
|
@ -1,76 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
QUIET_ARG=""
|
|
||||||
[[ "$1" == "--quiet" ]] && QUIET_ARG="--quiet"
|
|
||||||
|
|
||||||
# Enter source directory
|
|
||||||
cd "$( dirname "$0" )" || exit
|
|
||||||
|
|
||||||
mapfile -t FILES < <( awk '{print $1}' < "debian/install" )
|
|
||||||
[[ "${#FILES[@]}" -eq 0 ]] && echo "No file found in debian/install file!" && exit 1
|
|
||||||
PACKAGE_NAME="$( basename "$( head -n1 <<< "$FILES" )" | tr '_' '-' )"
|
|
||||||
|
|
||||||
echo "Clean previous build..."
|
|
||||||
rm -fr dist
|
|
||||||
|
|
||||||
echo "Detect version using git describe..."
|
|
||||||
VERSION="$( git describe --tags|sed 's/^[^0-9]*//' )"
|
|
||||||
|
|
||||||
echo "Create building environemt..."
|
|
||||||
BDIR="dist/$PACKAGE_NAME-$VERSION"
|
|
||||||
mkdir -p "$BDIR"
|
|
||||||
RSYNC_ARG=""
|
|
||||||
[[ -z "$QUIET_ARG" ]] && RSYNC_ARG="-v"
|
|
||||||
rsync -a "$RSYNC_ARG" debian/ "$BDIR/debian/"
|
|
||||||
cp "${FILES[@]}" "$BDIR/"
|
|
||||||
|
|
||||||
echo "Set version $VERSION in files..."
|
|
||||||
for FILE in "${FILES[@]}"; do
|
|
||||||
case "$( mimetype -b "$FILE" )" in
|
|
||||||
application/x-perl)
|
|
||||||
echo " - in $FILE (perl)"
|
|
||||||
sed -i "s/^my \$version *=.*$/my \$version = '$VERSION';/" "$BDIR/$( basename "$FILE" )"
|
|
||||||
;;
|
|
||||||
application/x-shellscript)
|
|
||||||
echo " - in $FILE (shellscript)"
|
|
||||||
sed -i "s/^VERSION *=.*$/VERSION = '$VERSION'/" "$BDIR/$( basename "$FILE" )"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z "$DEBIAN_CODENAME" ]]; then
|
|
||||||
echo "Retrieve debian codename using lsb_release..."
|
|
||||||
DEBIAN_CODENAME=$( lsb_release -c -s )
|
|
||||||
else
|
|
||||||
echo "Use debian codename from environment ($DEBIAN_CODENAME)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Generate debian changelog using gitdch..."
|
|
||||||
GITDCH_ARGS=('--verbose')
|
|
||||||
[[ -n "$QUIET_ARG" ]] && GITDCH_ARGS=('--warning')
|
|
||||||
if [[ -n "$MAINTAINER_NAME" ]]; then
|
|
||||||
echo "Use maintainer name from environment ($MAINTAINER_NAME)"
|
|
||||||
GITDCH_ARGS+=("--maintainer-name" "${MAINTAINER_NAME}")
|
|
||||||
fi
|
|
||||||
if [[ -n "$MAINTAINER_EMAIL" ]]; then
|
|
||||||
echo "Use maintainer email from environment ($MAINTAINER_EMAIL)"
|
|
||||||
GITDCH_ARGS+=("--maintainer-email" "$MAINTAINER_EMAIL")
|
|
||||||
fi
|
|
||||||
gitdch \
|
|
||||||
--package-name "$PACKAGE_NAME" \
|
|
||||||
--version "${VERSION}" \
|
|
||||||
--code-name "$DEBIAN_CODENAME" \
|
|
||||||
--output "$BDIR"/debian/changelog \
|
|
||||||
--release-notes dist/release_notes.md \
|
|
||||||
"${GITDCH_ARGS[@]}"
|
|
||||||
|
|
||||||
if [[ -n "$MAINTAINER_NAME" ]] && [[ -n "$MAINTAINER_EMAIL" ]]; then
|
|
||||||
echo "Set Maintainer field in debian control file ($MAINTAINER_NAME <$MAINTAINER_EMAIL>)..."
|
|
||||||
sed -i "s/^Maintainer: .*$/Maintainer: $MAINTAINER_NAME <$MAINTAINER_EMAIL>/" \
|
|
||||||
"$BDIR"/debian/control
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Build debian package..."
|
|
||||||
cd "$BDIR" || exit
|
|
||||||
dpkg-buildpackage
|
|
||||||
# vim:set sw=4 ts=4 sts=4 ft=bash expandtab:
|
|
|
@ -44,7 +44,7 @@ Getopt::Long::Configure('bundling');
|
||||||
use lib "/usr/share/backuppc/lib";
|
use lib "/usr/share/backuppc/lib";
|
||||||
use BackupPC::Lib;
|
use BackupPC::Lib;
|
||||||
|
|
||||||
my $version = 'dev';
|
my $version = '1.1.3';
|
||||||
my $warnDaysOld = 2;
|
my $warnDaysOld = 2;
|
||||||
my $critDaysOld = 7;
|
my $critDaysOld = 7;
|
||||||
my $warnDaysInProgress = 0.5;
|
my $warnDaysInProgress = 0.5;
|
||||||
|
@ -82,7 +82,7 @@ $goodOpt = GetOptions(
|
||||||
@hostsDesired = () if $#hostsDesired < 0;
|
@hostsDesired = () if $#hostsDesired < 0;
|
||||||
@hostsExcluded = () if $#hostsExcluded < 0;
|
@hostsExcluded = () if $#hostsExcluded < 0;
|
||||||
|
|
||||||
# Always check disabled host if a named host is provided (when backup is triggered by cron)
|
# Always check disabled host if a named host is provided (when backup is trigerred by cron)
|
||||||
$forceCheckOnDisabledHosts = 1 if ( @hostsDesired && scalar(@hostsDesired) );
|
$forceCheckOnDisabledHosts = 1 if ( @hostsDesired && scalar(@hostsDesired) );
|
||||||
|
|
||||||
if ($opt_V)
|
if ($opt_V)
|
||||||
|
|
|
@ -42,7 +42,7 @@ Getopt::Long::Configure('bundling');
|
||||||
use lib "/usr/share/backuppc/lib";
|
use lib "/usr/share/backuppc/lib";
|
||||||
use BackupPC::Lib;
|
use BackupPC::Lib;
|
||||||
|
|
||||||
my $version = 'dev';
|
my $version = '1.0';
|
||||||
# Default quota (GB)
|
# Default quota (GB)
|
||||||
my $quota = 100;
|
my $quota = 100;
|
||||||
my $opt_V = 0;
|
my $opt_V = 0;
|
||||||
|
@ -105,7 +105,7 @@ my $hosts_infos = $server->HostInfoRead();
|
||||||
# undump the output... BackupPC uses Data::Dumper
|
# undump the output... BackupPC uses Data::Dumper
|
||||||
eval $status_raw;
|
eval $status_raw;
|
||||||
|
|
||||||
# Allow hostname separated by comma
|
# Allow hostname separeted by comma
|
||||||
@hostlist = split(/,/,join(',',@hostlist));
|
@hostlist = split(/,/,join(',',@hostlist));
|
||||||
|
|
||||||
my $per_host_detail;
|
my $per_host_detail;
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION=dev
|
cd /var/lib/backuppc/pc
|
||||||
|
|
||||||
[[ ! -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
|
|
||||||
|
|
||||||
OUT="<table align=center>
|
OUT="<table align=center>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -21,19 +15,18 @@ OUT="<table align=center>
|
||||||
<tbody>"
|
<tbody>"
|
||||||
t_v3=0
|
t_v3=0
|
||||||
t_v4=0
|
t_v4=0
|
||||||
for h in *; do
|
for h in *
|
||||||
if [[ ! -d "$h" ]] || [[ ! -e "$h/backups" ]]; then
|
do
|
||||||
continue
|
[ ! -d "$h" -o ! -e "$h/backups" ] && continue
|
||||||
fi
|
vers=$( cat $h/backups|cut -f24 )
|
||||||
vers=$( cut -f24 < "$h/backups" )
|
v3=$( echo -e "$vers"|grep -Ev '^4'|wc -l|cut -f1 )
|
||||||
v3=$( grep -Evc '^4' <<< "$vers" )
|
let t_v3=t_v3+v3
|
||||||
((t_v3=t_v3+v3))
|
[ $v3 -ne 0 ] && v3="<strong>$v3</strong>"
|
||||||
[[ "$v3" -ne 0 ]] && v3="<strong>$v3</strong>"
|
v4=$( echo -e "$vers"|grep -Ec '^4' )
|
||||||
v4=$( grep -Ec '^4' <<< "$vers" )
|
let t_v4=t_v4+v4
|
||||||
((t_v4=t_v4+v4))
|
|
||||||
OUT="$OUT<tr><td align=left>$h</td><td>$v3</td><td>$v4</td></tr>"
|
OUT="$OUT<tr><td align=left>$h</td><td>$v3</td><td>$v4</td></tr>"
|
||||||
done
|
done
|
||||||
[[ $t_v3 -gt 0 ]] && t_v3="<strong>$t_v3</strong>"
|
[ $t_v3 -gt 0 ] && t_v3="<strong>$t_v3</strong>"
|
||||||
OUT="$OUT
|
OUT="$OUT
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfooter>
|
<tfooter>
|
||||||
|
@ -44,5 +37,4 @@ OUT="$OUT
|
||||||
</tr>
|
</tr>
|
||||||
</tfooter>
|
</tfooter>
|
||||||
</table>"
|
</table>"
|
||||||
lynx -stdin <<< "$OUT"
|
echo $OUT|lynx -stdin
|
||||||
# vim:set sw=4 ts=4 sts=4 ft=bash expandtab:
|
|
||||||
|
|
1
debian/compat
vendored
1
debian/compat
vendored
|
@ -1 +0,0 @@
|
||||||
11
|
|
12
debian/control
vendored
12
debian/control
vendored
|
@ -1,12 +0,0 @@
|
||||||
Source: check-backuppc
|
|
||||||
Section: admin
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Easter-eggs <info@easter-eggs.com>
|
|
||||||
Build-Depends: debhelper (>> 11.0.0)
|
|
||||||
Standards-Version: 3.9.6
|
|
||||||
|
|
||||||
Package: check-backuppc
|
|
||||||
Architecture: all
|
|
||||||
Depends: ${misc:Depends}, backuppc, libmonitoring-plugin-perl
|
|
||||||
Description: Monitoring plugin to check BackupPC instance
|
|
||||||
This Icinga/Nagios check plugins permit to check BackupPC instance
|
|
20
debian/copyright
vendored
20
debian/copyright
vendored
|
@ -1,20 +0,0 @@
|
||||||
This package was written by Benjamin Renard <brenard@easter-eggs.com>.
|
|
||||||
|
|
||||||
Copyright (C) 2013-2024 Easter-eggs <info@easter-eggs.com>
|
|
||||||
|
|
||||||
check-backuppc is licensed under the GNU general public license, version 2.
|
|
||||||
|
|
||||||
check-backuppc is free software; you can redistribute it and/or modify it under
|
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; either version 2, or (at your option) any later version.
|
|
||||||
|
|
||||||
check-backuppc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
check-backuppc; see the file COPYING. If not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
On Debian systems, a copy of the GNU General Public License is available in
|
|
||||||
/usr/share/common-licenses/GPL-2 as part of the base-files package.
|
|
3
debian/install
vendored
3
debian/install
vendored
|
@ -1,3 +0,0 @@
|
||||||
check_backuppc usr/lib/nagios/plugins
|
|
||||||
check_backuppc_du usr/lib/nagios/plugins
|
|
||||||
check_backuppc_nb_bkp_v3 usr/bin
|
|
4
debian/rules
vendored
4
debian/rules
vendored
|
@ -1,4 +0,0 @@
|
||||||
#!/usr/bin/make -f
|
|
||||||
#export DH_VERBOSE=1
|
|
||||||
%:
|
|
||||||
dh $@
|
|
1
debian/source/format
vendored
1
debian/source/format
vendored
|
@ -1 +0,0 @@
|
||||||
1.0
|
|
Loading…
Reference in a new issue