3
our @ISA = qw(DBD::MySQL::Server);
11
$self->{cancelled} = 0;
12
$self->{length} = 100;
13
if ($params{mode} =~ /my::queue::status/) {
14
($self->{running}, $self->{waiting}, $self->{held}, $self->{cancelled}) =
15
$self->{handle}->fetchrow_array(q{
16
SELECT COUNT(*) FROM queues WHERE
17
status IN ('running', 'waiting', 'held', 'cancelled')
20
} elsif ($params{mode} =~ /my::queue::length/) {
21
$self->{length} = $self->{handle}->fetchrow_array(q{
22
SELECT COUNT(*) FROM queues
24
} elsif ($params{mode} =~ /my::queue::througput/) {
25
$self->{processed_items} = $self->{handle}->fetchrow_array(q{
26
SELECT processed FROM queue_status
28
$self->valdiff(\%params, qw(processed_items));
29
# this automatically creates
30
# $self->{delta_timestamp}
31
# the time in seconds since the last run of check_mysql_health
32
# $self->{delta_processed_items}
33
# the difference between processed_items now and
34
# processed_items when check_mysql_health was run last time
35
$self->{throughput} = $self->{delta_processed_items} / $self->{delta_timestamp};
43
if ($params{mode} =~ /my::queue::status/) {
44
if ($self->{held} > 10 || $self->{cancelled} > 10) {
45
$self->add_nagios_critical("more than 10 queues are held or cancelled");
46
} elsif ($self->{waiting} > 20 && $self->{running} < 3) {
47
$self->add_nagios_warning("more than 20 queues are waiting and less than 3 queues are running");
49
$self->add_nagios_ok("queues are running normal");
51
$self->add_perfdata(sprintf "held=%d cancelled=%d waiting=%d running=%d",
52
$self->{running}, $self->{waiting}, $self->{held}, $self->{cancelled});
53
} elsif ($params{mode} =~ /my::queue::length/) {
55
$self->check_thresholds($self->{length}, 100, 500),
56
sprintf "queue length is %d", $self->{length});
57
$self->add_perfdata(sprintf "queuelen=%d;%d;%d",
58
$self->{length}, $self->{warningrange}, $self->{criticalrange});
59
} elsif ($params{mode} =~ /my::queue::througput/) {
61
$self->check_thresholds($self->{throughput}, "50:", "10:"),
62
sprintf "queue throughput is %d", $self->{throughput});
63
$self->add_perfdata(sprintf "throughput=%.2f;%d;%d",
64
$self->{throughput}, $self->{warningrange}, $self->{criticalrange});
66
$self->add_nagios_unknown("unknown mode");