While browsing across internet i found this usefull post on zabbix forum
(zabbix is an opensource, really good, monitoring system).
This post explain how to monitor jobs executions by using message{}
resource instead of recive mails.
Cesare Montresor
(attachment is taken from post)
URL: http://www.zabbix.com/forum/showthread.php?t=8145
----------------------------------------------------------------------------------------------
post by: milprog Date: 22-10-2007
----------------------------------------------------------------------------------------------
Hi all
I use bacula to back up and verify lots of servers. After I had found
zabbix to monitor these, I now was tired of checking all those silly
"Backup OK ..." mails every day. Moreover, I needed a simple way to
monitor the size of each server's backup.
So I made bacula work with zabbix using a self-made perl script. I use
bacula 2.0.3, but the procedure should work with other versions as well;
perhaps the text strings in the script need some adjustment. Here is my
cookbook contribution:
1) On your server hosting the bacula director, create a perl script
/etc/zabbix/bin/custom_bacula (see attachment, remove .txt extension),
chmod 0755
(sorry, this is my first perl script: not very elegant, but it works for
me. Improvements are welcome!)
2) in /etc/bacula/bacula-dir.conf, replace the mailcommand line by:
mailcommand = "/etc/zabbix/bin/custom.bacula %r %c"
and modify the mail line as follows (of course, replace
my.zabbixserver.fqdn by your server's dns name):
mail = my.zabbixserver.fqdn = all, !skipped
...this way, the bacula result messages go through the zabbix_sender
process instead of being mailed through bsmtp.
3) create zabbix trapper items with the names given in the custom.bacula
script, e.g.
bacula.backup.result
bacula.fd.fileswritten (Units: Bytes)
bacula.fd.byteswritten (Units: Bytes)
(etc.)
4) ensure that the FD names in the bacula-dir.conf file correspond to
the hostnames used in zabbix.
5) Enjoy! Add triggers for bacula.backup.result >1 or
bacula.verify.result >0 to report errors; add thresholds to monitor
backup size etc. etc.
Regards
--Marcel
----------------------------------------------------------------------------------------------
#!/usr/bin/perl
#
# process bacula termination message and generate zabbix events
#
use strict;
use warnings;
my %term_backup = ("OK", "0" , "OK -- with warnings", "1");
my %term_verify = ("OK", "0" );
my $zabbixserver = $ARGV[0];
my $hostname = $ARGV[1];
my $zabbix_sender = "/usr/sbin/zabbix_sender";
#print "Server=", $zabbixserver, "\n";
#print "Host=", $hostname, "\n";
while (<STDIN>) {
if (/Termination:\s*Backup\s*/) {
my $term = $'; chop($term);
if (exists($term_backup{$term})) {
$term=$term_backup{$term};
} else {
$term="2";
};
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.backup.result -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/Termination:\s*Verify\s*/) {
my $term = $'; chop($term);
if (exists($term_verify{$term})) {
$term=$term_verify{$term};
} else {
$term="2";
};
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.verify.result -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/FD Files Written:\s*/) {
my $term = $'; chop($term);
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.fd.fileswritten -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/SD Files Written:\s*/) {
my $term = $'; chop($term);
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.sd.fileswritten -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/FD Bytes Written:\s*/) {
$_ = $'; /[0-9,]+/; $_ = $&; s/,//g;
my $term = $_;
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.fd.byteswritten -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/SD Bytes Written:\s*/) {
$_ = $'; /[0-9,]+/; $_ = $&; s/,//g;
my $term = $_;
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.sd.byteswritten -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/Last Volume Bytes:\s*/) {
$_ = $'; /[0-9,]+/; $_ = $&; s/,//g;
my $term = $_;
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.lastvolumebytes -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
} elsif (/Files Examined:\s*/) {
$_ = $'; /[0-9,]+/; $_ = $&; s/,//g;
my $term = $_;
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k
bacula.verify.filesexamined -o ".$term;
# print $cmd, "\n";
my $return = `$cmd`;
}
;
}
exit 0;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users