From 99cc0ebd230e805760cbed8e798d41bab9381fda Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 9 Mar 2004 10:24:18 +0000 Subject: [PATCH] Fix broken Jmsg in find_one.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1119 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/configure | 3 - bacula/examples/nagios.txt | 267 ++++++++++++++++++++++++++++++++++ bacula/kernstodo | 9 +- bacula/src/findlib/find_one.c | 3 +- bacula/src/version.h | 4 +- 5 files changed, 274 insertions(+), 12 deletions(-) create mode 100644 bacula/examples/nagios.txt diff --git a/bacula/configure b/bacula/configure index 9ead700267..d1513edbf2 100755 --- a/bacula/configure +++ b/bacula/configure @@ -897,17 +897,14 @@ Optional Packages: --with-postgresql=DIR Include PostgreSQL support. DIR is the PostgreSQL base install directory, defaults to /usr/local/pgsql -Which DBMS do you want to use (please select only one): --with-mysql=DIR Include MySQL support. DIR is the MySQL base install directory, default is to search through a number of common places for the MySQL files. -Which DBMS do you want to use (please select only one): --with-embedded-mysql=DIR Include MySQL support. DIR is the MySQL base install directory, default is to search through a number of common places for the MySQL files. -Which DBMS do you want to use (please select only one): --with-sqlite=DIR Include SQLite support. DIR is the SQLite base install directory, default is to search through a number of common places for the SQLite files. diff --git a/bacula/examples/nagios.txt b/bacula/examples/nagios.txt new file mode 100644 index 0000000000..f26fec33f2 --- /dev/null +++ b/bacula/examples/nagios.txt @@ -0,0 +1,267 @@ +From bacula-users-admin@lists.sourceforge.net Wed Mar 3 22:08:24 2004 +Return-Path: +Received: from sc8-sf-list2.sourceforge.net (lists.sourceforge.net + [66.35.250.206]) by matou.sibbald.com (8.12.10/8.12.10) with ESMTP id + i23L8Nb7003158 for ; Wed, 3 Mar 2004 22:08:24 +0100 +Received: from localhost ([127.0.0.1] helo=projects.sourceforge.net) by + sc8-sf-list2.sourceforge.net with esmtp (Exim 4.30) id 1Ayddz-0005F7-EZ; + Wed, 03 Mar 2004 13:11:07 -0800 +Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.11] + helo=sc8-sf-mx1.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp + (Exim 4.30) id 1AyddU-00058Y-25 for bacula-users@lists.sourceforge.net; + Wed, 03 Mar 2004 13:10:36 -0800 +Received: from zola.netways.de ([213.95.25.82] + helo=net-sql2.int.netways.de) by sc8-sf-mx1.sourceforge.net with esmtp + (Exim 4.30) id 1AydXy-0008Im-KW for bacula-users@lists.sourceforge.net; + Wed, 03 Mar 2004 13:04:54 -0800 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +Subject: RE: [Bacula-users] monitoring bacula with Nagios +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Message-ID: <2F6750F2110CAD41BE0BC33BB428B568FB9F@net-sql2.int.netways.de> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [Bacula-users] monitoring bacula with Nagios +Thread-Index: AcPflloclgso3C9CREycI4VSOMnJBghyXnSwAACsf0A= +From: "Julian Hein" +To: +X-Spam-Score: 0.0 (/) +X-Spam-Report: Spam Filtering performed by sourceforge.net. See + http://spamassassin.org/tag/ for more details. Report problems to + http://sf.net/tracker/?func=add&group_id=1&atid=200001 +Sender: bacula-users-admin@lists.sourceforge.net +Errors-To: bacula-users-admin@lists.sourceforge.net +X-BeenThere: bacula-users@lists.sourceforge.net +X-Mailman-Version: 2.0.9-sf.net +Precedence: bulk +List-Unsubscribe: + , + +List-Id: Bacula user's email list for support and discussions + +List-Post: +List-Help: +List-Subscribe: + , + +List-Archive: + +Date: Wed, 3 Mar 2004 22:04:49 +0100 +X-MIME-Autoconverted: from quoted-printable to 8bit by matou.sibbald.com id + i23L8Nb7003158 +Content-Transfer-Encoding: 8bit + +Hi, + +> Anyway: I would really like to write such a check_bacula +> plugin. I just +> don't know what I need to implement to achive a successful +> authentication. And maybe to get some infos out. Like current +> number of +> jobs, runtime or so. + +We are checking bacula with Nagios in two ways: First we check all servers if the neccessary services are running, like the fd on all bacula clients (windows & linux), directors, sd, etc. And the second check is to look in baculas mysql database if there is a successful job for every host within the last 24 hours: + + +1. Check if the fd is running +============================= + +Services: +--------- + +# bacula-fd linux +check_command check_spezial_procs_by_ssh!2:!1:!bacula-fd + +# bacula-sd +check_command check_spezial_procs_by_ssh!2:!1:!bacula-sd + +# bacula-dir +check_command check_spezial_procs_by_ssh!2:!1:!bacula-dir + +# bacula-fd windows +check_command check_nt_service!bacula + +Commands: +--------- + +# check for services by name with ssh +define command { + command_name check_spezial_procs_by_ssh + command_line $USER1$/check_by_ssh -t 60 -H $HOSTADDRESS$ -C "/opt/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -C $ARG3$" +} + +# check for the bacula-fd on windows with nsclient +define command { + command_name check_nt_service + command_line $USER1$/check_nt -H $HOSTADDRESS$ -p portno. -s password -v SERVICESTATE -l $ARG1$ +} + +2. Is there a successful job in the database +============================================ + +Services: +--------- + +# bacula jobs +check_command check_bacula_by_ssh!27!1!1 + +Commands: +--------- +The name of our backup jobs have to match the hostname in Nagios. So we can check on the backup server, for a job called $HOSTNAME$: + +define command { + command_name check_bacula_by_ssh + command_line $USER1$/check_by_ssh -t 60 -H my.backup.server -C "/opt/nagios/libexec/check_bacula.pl -H $ARG1$ -w $ +ARG2$ -c $ARG3$ -j $HOSTNAME$" +} + +check_bacula.pl: +---------------- + +#!/usr/bin/perl -w +use strict; +use POSIX; +use File::Basename; +use DBI; +use Getopt::Long; +use vars qw( + $opt_help + $opt_job + $opt_critical + $opt_warning + $opt_hours + $opt_usage + $opt_version + $out + $sql + $date_start + $date_stop + $state + $count + ); + +sub print_help(); +sub print_usage(); +sub get_now(); +sub get_date; + +my $progname = basename($0); + +my %ERRORS = ( 'UNKNOWN' => '-1', + 'OK' => '0', + 'WARNING' => '1', + 'CRITICAL' => '2'); + +Getopt::Long::Configure('bundling'); +GetOptions + ( + "c=s" => \$opt_critical, "critical=s" => \$opt_critical, + "w=s" => \$opt_warning, "warning=s" => \$opt_warning, + "H=s" => \$opt_hours, "hours=s" => \$opt_hours, + "j=s" => \$opt_job, "job=s" => \$opt_job, + "h" => \$opt_help, "help" => \$opt_help, + "usage" => \$opt_usage, + "V" => \$opt_version, "version" => \$opt_version + ) || die "Try '$progname --help' for more information.\n"; + +sub print_help() { +print "\n"; +print "PRINT HELP...\n"; +print "\n"; +} + +sub print_usage() { + print "PRINT USAGE...\n"; + print "\n"; +} + +sub get_now() { + my $now = defined $_[0] ? $_[0] : time; + my $out = strftime("%Y-%m-%d %X", localtime($now)); + return($out); +} + +sub get_date { + my $day = shift; + my $now = defined $_[0] ? $_[0] : time; + my $new = $now - ((60*60*1) * $day); + my $out = strftime("%Y-%m-%d %X", localtime($new)); + return ($out); +} + +if ($opt_help) { + print_help(); + exit $ERRORS{'UNKNOWN'}; +} + +if ($opt_usage) { + print_usage(); + exit $ERRORS{'UNKNOWN'}; +} + +if ($opt_version) { + print "$progname 0.0.1\n"; + exit $ERRORS{'UNKNOWN'}; +} + + +if ($opt_job && $opt_warning && $opt_critical) { + my $dsn = "DBI:mysql:database=bacula;host=localhost"; + my $dbh = DBI->connect( $dsn,'root','' ) or die "Error connecting to: '$dsn': $DBI::errstr\n"; + + if ($opt_hours) + { + $date_stop = get_date($opt_hours); + } + else + { + $date_stop = '1970-01-01 01:00:00'; + } + + $date_start = get_now(); + + $sql = "SELECT count(*) as 'count' from Job where (Name='$opt_job') and (JobStatus='T') and (EndTime <> '') and ((EndTime <= '$date_start') and (EndTime >= '$date_stop'));"; + + my $sth = $dbh->prepare($sql) or die "Error preparing statemment",$dbh->errstr; + $sth->execute; + + while (my @row = $sth->fetchrow_array()) { + ($count) = @row; + } +$state = 'OK'; +if ($count<$opt_warning) { $state='WARNING' } +if ($count<$opt_critical) { $state='CRITICAL' } + +print "Bacula $state: Found $count successfull jobs\n"; +exit $ERRORS{$state}; + $dbh->disconnect(); +} + else { + print_usage(); + } + +Well, this script is not really finished, but it works for us. Maybe it is helpful for you. If somebody makes enhancements, I would be happy to recieve a copy. + +cu, +Julian + +-- +Julian Hein NETWAYS GmbH +Managing Director Deutschherrnstr. 47a +Fon.0911/92885-0 D-90429 Nürnberg +Fax.0911/92885-31 +jhein@netways.de www.netways.de + + + + +------------------------------------------------------- +This SF.Net email is sponsored by: IBM Linux Tutorials +Free Linux tutorial presented by Daniel Robbins, President and CEO of +GenToo technologies. Learn everything from fundamentals to system +administration.http://ads.osdn.com/?ad_id70&alloc_id638&opÌk +_______________________________________________ +Bacula-users mailing list +Bacula-users@lists.sourceforge.net +https://lists.sourceforge.net/lists/listinfo/bacula-users diff --git a/bacula/kernstodo b/bacula/kernstodo index 29290c4bc8..613c90c10f 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -37,11 +37,7 @@ Testing to do: (painful) - Test cancel at EOM. For 1.33 Testing/Documentation: -- Newly labeled tapes are chosen before ones already in use. -- Document new alias records in Director. SDAddress SDDeviceName, SDPassword. - FDPassword, FDAddress, DBAddress, DBPort, DBPassword. - Document new Include/Exclude ... -- Add test of exclusion, test multiple Include {} statements. - Add counter variable test. - Document ln -sf /usr/lib/libncurses.so /usr/lib/libtermcap.so and install the esound-dev  package for compiling Console on SuSE. @@ -85,7 +81,6 @@ For 1.33 - Allow "delete job jobid=xx jobid=xxx". - Allow "delete job jobid=xxx,yyy,aaa-bbb" i.e. list + ranges. - Implement multiple Volume in "purge jobs volume=". -- Rescue builds incorrect script files on Rufus. - Fix option 2 of restore -- list where file is backed up -- require Client, then list last 20 backups. - Allow browsing the catalog to see all versions of a file (with @@ -95,7 +90,6 @@ For 1.33 - Symbolic link a directory to another one, then backup the symbolic link. - Check and possibly fix problems with hard links. - Fix "llist jobid=xx" where no fileset or client exists. -- Release SQLite 2.8.9 - Add all pools in Dir conf to DB also update them to catch changed LabelFormats and such. - Build console in client-only build. @@ -1413,3 +1407,6 @@ Block Position: 0 - Make column listing for running jobs JobId Level Type Started Name Status - Why does Bacula need the drive open to do "autochanger list" ? - Add data compare on write/read in btape "test". +- Rescue builds incorrect script files on Rufus. +- Release SQLite 2.8.9 + diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 226bc89e44..cbd48f0724 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -135,7 +135,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), if (lp->ino == ff_pkt->statp.st_ino && lp->dev == ff_pkt->statp.st_dev) { /* If we have already backed up the hard linked file don't do it again */ if (strcmp(lp->name, fname) == 0) { - Jmsg0(jcr, M_WARNING, 0, _("Attempt to backup hard linked file %s twice ignored.\n")); + Jmsg1(jcr, M_WARNING, 0, _("Attempt to backup hard linked file %s twice ignored.\n"), + fname); return 1; /* ignore */ } ff_pkt->link = lp->name; diff --git a/bacula/src/version.h b/bacula/src/version.h index 16ccc164b1..0f407c0dd2 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.33.4" #define VSTRING "1" -#define BDATE "08 Mar 2004" -#define LSMDATE "08Mar04" +#define BDATE "09 Mar 2004" +#define LSMDATE "09Mar04" /* Debug flags */ #undef DEBUG -- 2.39.5