1 From bacula-users-admin@lists.sourceforge.net Wed Mar 3 22:08:24 2004
2 Return-Path: <bacula-users-admin@lists.sourceforge.net>
3 Received: from sc8-sf-list2.sourceforge.net (lists.sourceforge.net
4 [66.35.250.206]) by matou.sibbald.com (8.12.10/8.12.10) with ESMTP id
5 i23L8Nb7003158 for <kern@sibbald.com>; Wed, 3 Mar 2004 22:08:24 +0100
6 Received: from localhost ([127.0.0.1] helo=projects.sourceforge.net) by
7 sc8-sf-list2.sourceforge.net with esmtp (Exim 4.30) id 1Ayddz-0005F7-EZ;
8 Wed, 03 Mar 2004 13:11:07 -0800
9 Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.11]
10 helo=sc8-sf-mx1.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp
11 (Exim 4.30) id 1AyddU-00058Y-25 for bacula-users@lists.sourceforge.net;
12 Wed, 03 Mar 2004 13:10:36 -0800
13 Received: from zola.netways.de ([213.95.25.82]
14 helo=net-sql2.int.netways.de) by sc8-sf-mx1.sourceforge.net with esmtp
15 (Exim 4.30) id 1AydXy-0008Im-KW for bacula-users@lists.sourceforge.net;
16 Wed, 03 Mar 2004 13:04:54 -0800
17 Content-class: urn:content-classes:message
19 Content-Type: text/plain; charset="iso-8859-1"
20 Subject: RE: [Bacula-users] monitoring bacula with Nagios
21 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0
22 Message-ID: <2F6750F2110CAD41BE0BC33BB428B568FB9F@net-sql2.int.netways.de>
25 Thread-Topic: [Bacula-users] monitoring bacula with Nagios
26 Thread-Index: AcPflloclgso3C9CREycI4VSOMnJBghyXnSwAACsf0A=
27 From: "Julian Hein" <jhein@netways.de>
28 To: <bacula-users@lists.sourceforge.net>
30 X-Spam-Report: Spam Filtering performed by sourceforge.net. See
31 http://spamassassin.org/tag/ for more details. Report problems to
32 http://sf.net/tracker/?func=add&group_id=1&atid=200001
33 Sender: bacula-users-admin@lists.sourceforge.net
34 Errors-To: bacula-users-admin@lists.sourceforge.net
35 X-BeenThere: bacula-users@lists.sourceforge.net
36 X-Mailman-Version: 2.0.9-sf.net
39 <https://lists.sourceforge.net/lists/listinfo/bacula-users>,
40 <mailto:bacula-users-request@lists.sourceforge.net?subject=unsubscribe>
41 List-Id: Bacula user's email list for support and discussions
42 <bacula-users.lists.sourceforge.net>
43 List-Post: <mailto:bacula-users@lists.sourceforge.net>
44 List-Help: <mailto:bacula-users-request@lists.sourceforge.net?subject=help>
46 <https://lists.sourceforge.net/lists/listinfo/bacula-users>,
47 <mailto:bacula-users-request@lists.sourceforge.net?subject=subscribe>
49 <http://sourceforge.net/mailarchive/forum.php?forum=bacula-users>
50 Date: Wed, 3 Mar 2004 22:04:49 +0100
51 X-MIME-Autoconverted: from quoted-printable to 8bit by matou.sibbald.com id
53 Content-Transfer-Encoding: 8bit
57 > Anyway: I would really like to write such a check_bacula
59 > don't know what I need to implement to achive a successful
60 > authentication. And maybe to get some infos out. Like current
62 > jobs, runtime or so.
64 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:
67 1. Check if the fd is running
68 =============================
74 check_command check_spezial_procs_by_ssh!2:!1:!bacula-fd
77 check_command check_spezial_procs_by_ssh!2:!1:!bacula-sd
80 check_command check_spezial_procs_by_ssh!2:!1:!bacula-dir
83 check_command check_nt_service!bacula
88 # check for services by name with ssh
90 command_name check_spezial_procs_by_ssh
91 command_line $USER1$/check_by_ssh -t 60 -H $HOSTADDRESS$ -C "/opt/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -C $ARG3$"
94 # check for the bacula-fd on windows with nsclient
96 command_name check_nt_service
97 command_line $USER1$/check_nt -H $HOSTADDRESS$ -p portno. -s password -v SERVICESTATE -l $ARG1$
100 2. Is there a successful job in the database
101 ============================================
107 check_command check_bacula_by_ssh!27!1!1
111 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$:
114 command_name check_bacula_by_ssh
115 command_line $USER1$/check_by_ssh -t 60 -H my.backup.server -C "/opt/nagios/libexec/check_bacula.pl -H $ARG1$ -w $
116 ARG2$ -c $ARG3$ -j $HOSTNAME$"
149 my $progname = basename($0);
151 my %ERRORS = ( 'UNKNOWN' => '-1',
156 Getopt::Long::Configure('bundling');
159 "c=s" => \$opt_critical, "critical=s" => \$opt_critical,
160 "w=s" => \$opt_warning, "warning=s" => \$opt_warning,
161 "H=s" => \$opt_hours, "hours=s" => \$opt_hours,
162 "j=s" => \$opt_job, "job=s" => \$opt_job,
163 "h" => \$opt_help, "help" => \$opt_help,
164 "usage" => \$opt_usage,
165 "V" => \$opt_version, "version" => \$opt_version
166 ) || die "Try '$progname --help' for more information.\n";
170 print "PRINT HELP...\n";
175 print "PRINT USAGE...\n";
180 my $now = defined $_[0] ? $_[0] : time;
181 my $out = strftime("%Y-%m-%d %X", localtime($now));
187 my $now = defined $_[0] ? $_[0] : time;
188 my $new = $now - ((60*60*1) * $day);
189 my $out = strftime("%Y-%m-%d %X", localtime($new));
195 exit $ERRORS{'UNKNOWN'};
200 exit $ERRORS{'UNKNOWN'};
204 print "$progname 0.0.1\n";
205 exit $ERRORS{'UNKNOWN'};
209 if ($opt_job && $opt_warning && $opt_critical) {
210 my $dsn = "DBI:mysql:database=bacula;host=localhost";
211 my $dbh = DBI->connect( $dsn,'root','' ) or die "Error connecting to: '$dsn': $DBI::errstr\n";
215 $date_stop = get_date($opt_hours);
219 $date_stop = '1970-01-01 01:00:00';
222 $date_start = get_now();
224 $sql = "SELECT count(*) as 'count' from Job where (Name='$opt_job') and (JobStatus='T') and (EndTime <> '') and ((EndTime <= '$date_start') and (EndTime >= '$date_stop'));";
226 my $sth = $dbh->prepare($sql) or die "Error preparing statemment",$dbh->errstr;
229 while (my @row = $sth->fetchrow_array()) {
233 if ($count<$opt_warning) { $state='WARNING' }
234 if ($count<$opt_critical) { $state='CRITICAL' }
236 print "Bacula $state: Found $count successfull jobs\n";
237 exit $ERRORS{$state};
244 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.
250 Julian Hein NETWAYS GmbH
251 Managing Director Deutschherrnstr. 47a
252 Fon.0911/92885-0 D-90429 Nürnberg
254 jhein@netways.de www.netways.de
259 -------------------------------------------------------
260 This SF.Net email is sponsored by: IBM Linux Tutorials
261 Free Linux tutorial presented by Daniel Robbins, President and CEO of
262 GenToo technologies. Learn everything from fundamentals to system
263 administration.http://ads.osdn.com/?ad_id
\1470&alloc_id638&opÌk
264 _______________________________________________
265 Bacula-users mailing list
266 Bacula-users@lists.sourceforge.net
267 https://lists.sourceforge.net/lists/listinfo/bacula-users