User Tools

Site Tools


nagios_active_checks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
nagios_active_checks [2009/04/07 11:07]
atrox created
nagios_active_checks [2017/04/08 17:57] (current)
svarco [What you need]
Line 1: Line 1:
 ===== Monitoring Bacula with Nagios (active checks) ====== ===== Monitoring Bacula with Nagios (active checks) ======
  
-==== 1. Introduction ====+==== Introduction ====
  
 The goal is to see whether all the backups in Bacula have been successfully completed within some period of time (eg. past 24 hours). The goal is to see whether all the backups in Bacula have been successfully completed within some period of time (eg. past 24 hours).
  
-==== 2. What you need ====+==== What you need ====
  
   * Bacula server   * Bacula server
-  * NRPE +  * plugin ​[[https://​exchange.nagios.org/​directory/​Plugins/​Backup-and-Recovery/​Bacula/​check_bacula-2Epy/​details|check_bacula.py]]
-  * NRPE plugin check_bacula.pl+
   * Nagios - may be on a separate host   * Nagios - may be on a separate host
  
-=== 2.1 Assumptions ===+=== Assumptions ===
  
-I use FreeBSD myself, so Nagios plugins are installed in /usr/local/libexec/nagios/ +  ​* Nagios plugins are installed in /usr/local/lib/nagios/plugins
-* you are using NRPE >= 2.0 +  * your backup-server'​s name in Nagios configuration is "​mybackup-srv"​ 
-* your backup-server'​s name in Nagios configuration is "​mybackup-srv"​ +  * backup-job you are monitoring is named "​myserv-conf"​ in Bacula 
-* backup-job you are monitoring is named "​myserv-conf"​ in Bacula +  * you run the backup once a day 
-* you run the backup once a day +  * you are using MySQL as Bacula database
-* you are using MySQL as Bacula database+
  
-==== 3. Configure NRPE ====+==== Configuration ​====
  
-=== 3.1 Get the plugin === +=== Get the plugin === 
-I assume you've got NRPE up and running. You'll just need to add a separate ​command ​for every backup you want to check. The commands will query Bacula database for backups'​ info.+I assume you've got NRPE up and running. You only need one command to check all backups. The commands will query the Bacula database for backups'​ info.
  
-First, download the script check_bacula.pl (into Nagios plugins'​ directory) and restrict its permissions:​+First, download the script check_bacula.py (into Nagios plugins'​ directory) and restrict its permissions:​
 <code bash> <code bash>
-chown root:nagios check_bacula.pl +chown root:nagios check_bacula.py 
-chmod 750 check_bacula.pl+chmod 750 check_bacula.py
 </​code>​ </​code>​
  
-Now set the correct SQL parameters in the script: 
-<code perl> 
-my $sqlDB = "​bacula";​ 
-my $sqlUsername = "​bacula";​ 
-my $sqlPassword = "​bacula-sql-password";​ 
-</​code>​ 
  
-If you don't use MySQL as your database, you'll also have to change the URL for accessing database: +==== Configure Nagios ====
-<code perl> +
- my $dsn "​DBI:​mysql:​database=$sqlDB;host=localhost";​ +
-</​code>​+
  
-=== 3.2 Define NRPE command ===+I assume you've got Nagios up and running and there are already some services in place for the host we're going to monitor for successful backups.
  
-The sample ​command ​to be put into nrpe.cfg:+Define a command ​for the check_bacula plugin:
 <code ini> <code ini>
-command[check_bacula_myserv_conf]=/​usr/​local/​libexec/​nagios/​check_bacula.pl -H 24 -w 2 -c 1 -j myserv-conf+define ​command
 +  command_name ​                        ​check_bacula 
 +  command_line ​                        ​$USER2$/​check_bacula -H $HOSTADDRESS$ $ARG1$ 
 +}
 </​code>​ </​code>​
- 
-The above command means: 
-* the check is made within the last 24 hours 
-* if there is less than 1 successful backup, CRITICAL is returned 
-* if there is less than 2 successful backup, WARNING is returned 
-* backup-job'​s name (in Bacula) is "​myserv-conf"​ 
- 
-If you make 1 job per day, you should set -w to 1 as well. 
- 
-==== 3. Configure Nagios ==== 
- 
-I assume you've got Nagios up and running and there are already some services in place for the host we're going to monitor for successful backups. 
  
 Assuming you're doing one backup per day, it's enough to check the backup once per day. So let's define a template service for that, basing on already defined generic-service:​ Assuming you're doing one backup per day, it's enough to check the backup once per day. So let's define a template service for that, basing on already defined generic-service:​
Line 69: Line 49:
   name                    backup-service   name                    backup-service
   use                     ​generic-service   use                     ​generic-service
 +  check_command ​          ​check_bacula!-H bacula -U $USER14$ -P $USER15$ -D bacula --warning-severity=15 --critical-severity=25 --days=2
   normal_check_interval ​  1440 ; 24 hours   normal_check_interval ​  1440 ; 24 hours
   max_check_attempts ​     2   max_check_attempts ​     2
Line 75: Line 56:
 </​code>​ </​code>​
  
-Now we need to add the services that actually ​check bacula jobs. For each job, add a service definition ​(substituting the correct bacula job name, of course):+Now we need to add the service which actually ​checks the bacula jobs (substituting the correct bacula job name, of course):
 <code ini> <code ini>
 define service { define service {
-  use                     ​backup-service +  use                      backup-service 
-  host_name ​              ​mybackup-srv +  host_name ​               mybackup-srv 
-  service_description ​    ​Bacula-backup: mysrv-conf +  service_description ​     Bacula-backup 
-  ​check_command ​          ​check_nrpe2!check_bacula_myserv_conf+  ​register ​                1
 } }
 </​code>​ </​code>​
Line 91: Line 72:
  
 If everything is OK, restart Nagios to apply the changes. If everything is OK, restart Nagios to apply the changes.
 +
 +===== Links =====
 +
 +  * [[nagios|monitoring Bacula with nagios passive checks]]
 +  * [[howtos|other howtos]]
 +
nagios_active_checks.1239098860.txt.gz · Last modified: 2009/04/07 11:07 by atrox