Hi every:
I need send a beeper message when a Bacula Jobs fails. For this I write this in
JobDefs:
JobDefs {
Name = "DefinicionPorDefectoParaCopias"
Type = Backup
Level = Incremental
Storage = FileSAN
Messages = Standard
Priority = 5 #Es la opcion por defecto, a mayor numero menos prioridad
Reschedule on error = yes
Reschedule interval = 1 hour
Reschedule times = 2
Max Start Delay = 8 hours
RunScript {
RunsWhen = After
RunsOnFailure = yes
Command = /etc/bacula/scripts/paging.pl 23744 Job %n: %e
}
}
Now the paging.pl script is this one:
#!/usr/bin/perl -w
#
# This script send beeper to movitel (v 1.1)
# Usage:
# paging.pl <PIN> <Message>
#
use strict;
#Modulos para hacer un request HTTP
use LWP::UserAgent;
require HTTP::Request::Common;
require HTTP::Headers;
if ((defined($ARGV[0])) and (defined($ARGV[1])))
{
my $pin = $ARGV[0];
my $mess = substr($ARGV[1],0,119);
my $url = 'http://www.movitel.co.cu/cgi-bin/paging-send.pl';
#printf "$pin|$mess\n";
#INPUT Values from the web page of movitel
my $tserv = 1;
my $PIN = $pin;
my $Msg = $mess;
my $ok = 'http://www.movitel.co.cu/index.php?page=envios_ok';
my $error = 'http://www.movitel.co.cu/index.php?page=envios_error';
my $Submit2 = 'Enviar';
my $browser = LWP::UserAgent->new;
#my $header = HTTP::Headers->new(Content_Type => 'text/html;
charset=iso-8859-1');
#my $Request =
HTTP::Request->new(POST=>$url,[Content_Type=>'application/x-www-form-urlencoded',tserv=>'1',PIN=>$pin,Msg=>$mess,ok=>$ok,error=>$error,Submi
#printf $Request->as_string();
#my $Response = $browser->request($Request);
# send it 2 times to ensure it arrives
my $Response =
$browser->post($url,[tserv=>'1',PIN=>$pin,Msg=>$mess,ok=>$ok,error=>$error,Submit2=>'Enviar']);
$Response =
$browser->post($url,[tserv=>'1',PIN=>$pin,Msg=>$mess,ok=>$ok,error=>$error,Submit2=>'Enviar']);
my $Resultado = $Response->content();
my $Resp = "Unknow";
if ($Resultado =~ /page\=envios_ok/i) {
$Resp = "0k";
}
if ($Resultado =~ /page\=envios_error/i) {
$Resp = "Error";
}
#printf $Resultado;
my $time = localtime;
open File,">>/var/log/nagios/paging.log";
print File "$time\|$pin\|$mess\|$Resp(movitel)\n";
close File;
}
But Bacula never send me a message. What's wrong here?
Cheers and thanks in advance
Ing. Reynier Pérez Mira
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
|