forked from tokuhirom/madeye
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add qudo job count and exception_log agent.
- Loading branch information
Showing
2 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
package App::MadEye::Plugin::Agent::Qudo::ExceptionLog; | |||
use strict; | |||
use warnings; | |||
use App::MadEye::Plugin::Agent::Base; | |||
|
|||
use Qudo; | |||
|
|||
sub is_dead { | |||
my ($self, $dsn) = @_; | |||
|
|||
my $conf = $self->config->{config}; | |||
my $user = $conf->{user} or die "missing user"; | |||
my $password = $conf->{password} or die "missing password"; | |||
|
|||
my $qudo = Qudo->new( | |||
databases => [+{ | |||
dsn => $dsn, | |||
username => $user, | |||
password => $password, | |||
}], | |||
); | |||
|
|||
my $exceptions = $qudo->exception_list; | |||
if (scalar(@{$exceptions->{$dsn}}) >= 1) { | |||
return 'qudo has exceptions...'; | |||
} else { | |||
return; # alive. | |||
} | |||
} | |||
|
|||
1; | |||
__END__ | |||
=head1 NAME | |||
App::MadEye::Plugin::Agent::Qudo::ExceptionLog - monitoring exception count of Qudo | |||
=head1 SYNOPSIS | |||
- module: Agent::Qudo::ExceptionLog | |||
config: | |||
target: | |||
- DBI:mysql:database=foo | |||
user: root | |||
password: ~ | |||
=head1 SCHEMA | |||
type: map | |||
mapping: | |||
target: | |||
type: seq | |||
required: yes | |||
sequence: | |||
- type: str | |||
user: | |||
required: yes | |||
type: str | |||
password: | |||
required: yes | |||
type: str | |||
=head1 AUTHORS | |||
Atsushi Kobayashi | |||
=head1 SEE ALSO | |||
L<Qudo>, L<App::MadEye> | |||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,76 @@ | |||
package App::MadEye::Plugin::Agent::Qudo::Job; | |||
use strict; | |||
use warnings; | |||
use App::MadEye::Plugin::Agent::Base; | |||
|
|||
use Qudo; | |||
|
|||
sub is_dead { | |||
my ($self, $dsn) = @_; | |||
|
|||
my $conf = $self->config->{config}; | |||
my $user = $conf->{user} or die "missing user"; | |||
my $password = $conf->{password} or die "missing password"; | |||
my $threshold = $conf->{threshold} or die "missing threshold"; | |||
|
|||
my $qudo = Qudo->new( | |||
databases => [+{ | |||
dsn => $dsn, | |||
username => $user, | |||
password => $password, | |||
}], | |||
); | |||
|
|||
my $job_count = $qudo->job_count; | |||
if ($job_count->{$dsn} >= $threshold) { | |||
return sprintf(q{qudo has many job '%s': %s count.}, $dsn, $job_count->{$dsn}); | |||
} else { | |||
return; # alive. | |||
} | |||
} | |||
|
|||
1; | |||
__END__ | |||
=head1 NAME | |||
App::MadEye::Plugin::Agent::Qudo::Job - monitoring job count of Qudo | |||
=head1 SYNOPSIS | |||
- module: Agent::Qudo::Job | |||
config: | |||
target: | |||
- DBI:mysql:database=foo | |||
user: root | |||
password: ~ | |||
threshold: 1000 | |||
=head1 SCHEMA | |||
type: map | |||
mapping: | |||
target: | |||
type: seq | |||
required: yes | |||
sequence: | |||
- type: str | |||
user: | |||
required: yes | |||
type: str | |||
password: | |||
required: yes | |||
type: str | |||
threshold: | |||
required: yes | |||
type: int | |||
=head1 AUTHORS | |||
Atsushi Kobayashi | |||
=head1 SEE ALSO | |||
L<Qudo>, L<App::MadEye> | |||