Coder Social home page Coder Social logo

netways / check_bareos Goto Github PK

View Code? Open in Web Editor NEW
8.0 14.0 7.0 119 KB

Icinga Plugin to check Bareos Backup Director databases

Home Page: https://www.netways.de/

License: GNU General Public License v3.0

Python 99.48% Makefile 0.52%
plugin monitoring icinga bareos

check_bareos's Introduction

check_bareos

Icinga Monitoring Plugin to check Bareos Backup Director databases

The plugin connects to the Bareos database in order to retrieve data.

Installation

The plugin requires at least Python 3.

Python dependencies:

  • psycopg2-binary

Usage

p check_bareos.py --help
usage: check_bareos.py [-h] -U USER [-p PASSWORD] [-H HOST] [-P PORT] [-d DATABASE] [-v]
                       {job,tape,status} ...

Check Plugin for Bareos Backup Status

positional arguments:
  {job,tape,status}
    job                 Specific checks on a job
    tape                Specific checks on a tapes
    status              Specific status informations

options:
  -h, --help            show this help message and exit

  -U USER, --user USER  user name for the database connections
  -p PASSWORD, --password PASSWORD
                        password for the database connections
  -H HOST, --Host HOST  database host
  -P PORT, --port PORT  database port
  -d DATABASE, --database DATABASE
                        database name
  -v, --version         show program's version number and exit

Job

Check the status of Bareos Jobs.

usage: check_bareos.py job [-h] (-js | -j | -rt) [-n NAME] [-t TIME] [-u {GB,TB,PB}] [-w WARNING]
                           [-c CRITICAL] [-st {A,B,C,D,E,F,I,L,M,R,S,T,W,a,c,d,e,f,i,j,l,m,p,q,s,t}]
                           [-f] [-i] [-d]

options:
  -h, --help            show this help message and exit
  -js, --checkJobs      Check how many jobs are in a specific state [default=queued]
  -j, --checkJob        Check the state of a specific job [default=queued]
  -rt, --runTimeJobs    Check if a backup runs longer then n day
  -n NAME, --name NAME  Name of the job
  -t TIME, --time TIME  Time in days (default=7 days)
  -u {GB,TB,PB}, --unit {GB,TB,PB}
                        display unit
  -w WARNING, --warning WARNING
                        Warning value
  -c CRITICAL, --critical CRITICAL
                        Critical value
  -st {A,B,C,D,E,F,I,L,M,R,S,T,W,a,c,d,e,f,i,j,l,m,p,q,s,t}, --state {A,B,C,D,E,F,I,L,M,R,S,T,W,a,c,d,e,f,i,j,l,m,p,q,s,t}
                        Bareos Job State [default=C]
  -f, --full            Backup kind full
  -i, --inc             Backup kind inc
  -d, --diff            Backup kind diff

Examples

Check if a job is runing longar than 7 days (default value):

check_bareos.py job -rt -t 4 -st R  -w 1 -c 4

Check how much jobs are in the wating status:

check_bareos.py job -js -w 50 -c 100

Tape

Check the status of Bareos Tapes.

usage: check_bareos.py tape [-h] (-e | -ts | -ex | -wex | -r) [-w WARNING] [-c CRITICAL] [-m MOUNTS]
                            [-t TIME]

options:
  -h, --help            show this help message and exit
  -e, --emptyTapes      Count empty tapes in the storage (Status Purged/Expired)
  -ts, --tapesInStorage
                        Count how much tapes are in the storage
  -ex, --expiredTapes   Count how much tapes are expired
  -wex, --willExpire    Count how much tapes are will expire in n day
  -r, --replaceTapes    Count how much tapes should by replaced
  -w WARNING, --warning WARNING
                        Warning value
  -c CRITICAL, --critical CRITICAL
                        Critical value
  -m MOUNTS, --mounts MOUNTS
                        Amout of allowed mounts for a tape [used for replace tapes]
  -t TIME, --time TIME  Time in days (default=7 days)

Examples

Check how much tapes are empty in the storage:

check_bareos.py tape -e -w 15 -c 10

Check how much tapes are expired:

check_bareos.py tape -ex

Check how much tapes will expire in the next 14 days;

check_bareos.py tape -wex -t 14 -w 10 -c 5

Status

Check the status of various Bareos metrics.

usage: check_bareos.py status [-h] (-b | -e | -o | -fb) [-f] [-i] [-d] [-t TIME] [-w WARNING]
                              [-c CRITICAL] [-s SIZE] [-u {MB,GB,TB,PB,EB}]

options:
  -h, --help            show this help message and exit
  -b, --totalBackupsSize
                        the size of all backups in the database [use time and kind for mor
                        restrictions]
  -e, --emptyBackups    Check if a successful backup have 0 bytes [only wise for full backups]
  -o, --oversizedBackup
                        Check if a backup have more than n TB
  -fb, --failedBackups  Check if a backup failed in the last n day
  -f, --full            Backup kind full
  -i, --inc             Backup kind inc
  -d, --diff            Backup kind diff
  -t TIME, --time TIME  Time in days
  -w WARNING, --warning WARNING
                        Warning value [default=5]
  -c CRITICAL, --critical CRITICAL
                        Critical value [default=10]
  -s SIZE, --size SIZE  Border value for oversized backups [default=2]
  -u {MB,GB,TB,PB,EB}, --unit {MB,GB,TB,PB,EB}
                        display unit [default=TB]

Examples

Check total size of all backups:

check_bareos.py status -b -w 400 -c 500

Check total size of all full backups:

check_bareos.py status -b -f -w 400 -c 500

Check total size of all diff backups:

check_bareos.py status -b -d -w 400 -c 500

Check total size of all inc backups:

check_bareos.py status -b -i -w 400 -c 500

Check if a full backup has 0 Bytes(is Empty) and trigger warning it is at least 1 and trigger ciritcal if more than 5 are empty:

check_bareos.py status -e -f -w 1 -c 5

Check if a diff/inc backup is larger than 2 TB (default value) and trigger warning it is at least 1 and trigger ciritcal if more than 5 are empty:

check_bareos.py status -o -d -i -w 1 -c 5

check_bareos's People

Contributors

adrienr avatar dependabot[bot] avatar jacksgt avatar martialblog avatar mwaldmueller avatar rincewindshat avatar thegidy avatar widhalmt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

check_bareos's Issues

Missing PSQL connection

In version 1.0.2 there was still possible to use the script with PosgreSQL.
parser.add_argument('-d', '--database', dest='database', choices=['mysql', 'm', 'postgresql', 'p', 'psql'], default='mysql', help='the database kind for the database connection (m=mysql, p=psql) (Default=Mysql)')

After version 20 Bareos doesn't support MySQL anymore.
It will be greate if you add PostgreSQL support
Thanks
Regards
Sascha

Does not take jobs waiting for tapes into account

A test environment showd lots of jobs waiting for new labeld tapes so they could not run. This resulted in a month without backup and lots of unfinished jobs. check_bareos showed only one failed job.

After Upgrade from Buster to Bullseye doesn't work - /usr/bin/python: bad interpreter: No such file or directory

Hi, My system accidentally upgraded stable repo from Buster to Bullesye tonight and the command no longer works.
First I get this error:

/usr/bin/python: bad interpreter: No such file or directory

Then I changed the script to :

#!/usr/bin/python3

and I get the following error:

root@backup02:/etc/bareos# /usr/lib/nagios/plugins/check_bareos.py
File "/usr/lib/nagios/plugins/check_bareos.py", line 480
except psycopg2.DatabaseError, e:
^
SyntaxError: invalid syntax

Any update please?

ident authentication failed for user "bareos"

Hey Thomas,

I tried your plugin for bareos. But I always get ident authentication failed for user "bareos".
The user is okay I think. No password is set.

I think it has something to do with postgres. But my knowledge of authentication with postgres is quite limited.

Do you have an idea?

best regards,
Marcel

Failed backup not detected if full caused by consolidate job

Hi,

I just saw failed job with new 16.x consolidate feature (AlwaysIncremental)

# check_bareos.py -u xxx -p xxx -H localhost -d mysql status --failedBackups OK - Only 0 Backups failed in the last 7 days|Failed=0;5;10;;

While there is a failed consolidate job, i.e. the consolidate jobs creates new "full" jobs which consolidate the jobs. One of these jobs failed but not detected by the plugin :(

Icinga2 check command conf

Hi,

You said it's for icinga, do you have a working CheckCommand object already you could provide ? :|

Thanks a lot!

Refactor Plugin to use Bareos API

A lot has changed in the recent Bareos releases. Starting with Bareos 21 (released on December 22, 2021), it no longer supports MySQL.

Even more interesting Bareos 20 introduced REST API. So no longer do we need to query the DB, but can talk JSON with the API. I think this would simplify the Plugin and be way easier to test.

We should try to write a POC in the near future.

Script not working latest bareos with MariaDB 5.5.52

Traceback (most recent call last):
  File "./check_bareos.py", line 634, in <module>
    args.func(args)
  File "./check_bareos.py", line 581, in checkTape
    checkResult = checkEmptyTapes(cursor, args.warning, args.critical)
  File "./check_bareos.py", line 448, in checkEmptyTapes
    courser.execute(query)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '::INTERVAL)<now() and VolStatus not like 'Error')' at line 6")

Restore old Query Syntax for psql

The old queries should work on psql. Since one of them got replaced, restore it and add a conditional to check wether Postgre or MySQL is used. Keep this in mind for further changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.