On 01/26/10 05:31, Personal Técnico wrote:
> Hi,
>
> I have modified my check-client script as following:
>
> #! /bin/bash
> jobClient=$1
> if ( echo "sta client=${jobClient}" | bconsole | grep -v -q "Failed to
> connect to Client" ); then
> exit 0
> else
> exit 1
> fi
>
>
> With this script, if client is on, backup runs with no problem, but if
> client is off, bacula-dir is trying to connect during 15 minutes... What
> I want to avoid is this: waiting 15 minutes. If job has a "Run Before
> Job" parameter and it returns "1" (client is off), I thought job was
> cancelled inmediatly it started:
>
> 1. first it was scheduled at time X:Y
> 2. after scheduling, it was started at X:(Y+any minutes) (depending
> previous scheduled jobs)
> 3. but if client is not accessible, job is cancelled at X:(Y+any
> minutes + some seconds).
You might try the attached checkhost script instead. It first checks
whether the host is actually alive and on the network, then whether it's
listening on port 9102, instead of going straight to trying to connect
to it from the console. Trying to use the console for this purpose is,
as you've discovered, very slow.
--
Phil Stracchino, CDK#2 DoD#299792458 ICBM: 43.5607, -71.355
ala...@caerllewys.net ala...@metrocast.net p...@co.ordinate.org
Renaissance Man, Unix ronin, Perl hacker, Free Stater
It's not the years, it's the mileage.
#!/usr/bin/perl
use strict;
use Getopt::Long;
use Socket;
use Net::Ping;
use Net::Telnet ();
# Return values:
# -1 Program error or no host specified
# 0 Success, FD found and responding
# 1 Client alive but FD not listening
# 2 Client not found on network
my $ret = -1;
my ($host, $p, %opts);
GetOptions(\%opts,
'verbose',
'retry');
$host = shift || die "No host specified!\n";
if ($opts{verbose})
{
if ($host =~ /^\d+\.\d+\.\d+\.\d+$/)
{
my $ip = inet_aton($host);
printf("Host $host has name %s\n",
gethostbyaddr($ip, AF_INET));
}
else
{
printf("Client $host has address %d.%d.%d.%d\n",
unpack('C4',
(my @addrs = (gethostbyname($host))[4])[0]));
}
}
$p = Net::Ping->new();
my $retrycount = ($opts{retry} ? 3 : 1);
while ($retrycount && ($ret != 0))
{
if ($p->ping($host))
{
print "Host $host is alive\n" if ($opts{verbose});
my $t = new Net::Telnet (Timeout => 10,
Port => 9102,
Prompt => '/bash\$ $/');
if ($t->open($host))
{
print "Bacula-FD listening on port 9102\n" if ($opts{verbose});
$ret = 0;
}
else
{
print "Bacula-FD not running on host $host\n";
$ret = 1;
}
$t->close;
}
else
{
print "Client $host not found on network\n";
$ret = 2;
}
$retrycount--;
sleep(30) if ($retrycount && ($ret != 0));
}
$p->close();
print "Returning value $ret\n" if ($opts{verbose});
exit ($ret);
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users