| 1 | package App::MadEye::Plugin::Agent::Qudo::Job; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use App::MadEye::Plugin::Agent::Base; | ||
| 5 | |||
| 6 | use Qudo; | ||
| 7 | |||
| 8 | sub is_dead { | ||
| 9 | my ($self, $dsn) = @_; | ||
| 10 | |||
| 11 | my $conf = $self->config->{config}; | ||
| 12 | my $user = $conf->{user} or die "missing user"; | ||
| 13 | my $password = $conf->{password} or die "missing password"; | ||
| 14 | my $threshold = $conf->{threshold} or die "missing threshold"; | ||
| 15 | |||
| 16 | my $qudo = Qudo->new( | ||
| 17 | databases => [+{ | ||
| 18 | dsn => $dsn, | ||
| 19 | username => $user, | ||
| 20 | password => $password, | ||
| 21 | }], | ||
| 22 | ); | ||
| 23 | |||
| 24 | my $job_count = $qudo->job_count; | ||
| 25 | if ($job_count->{$dsn} >= $threshold) { | ||
| 26 | return sprintf(q{qudo has many job '%s': %s count.}, $dsn, $job_count->{$dsn}); | ||
| 27 | } else { | ||
| 28 | return; # alive. | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; | ||
| 33 | __END__ |