[Bps-public-commit] app-aws-cloudwatch-monitor-check-mailqueue branch add-check-module created. 4eeaa2c06f7c78b8d7eba042db52b097a9a514ce

BPS Git Server git at git.bestpractical.com
Wed Dec 1 00:52:19 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "app-aws-cloudwatch-monitor-check-mailqueue".

The branch, add-check-module has been created
        at  4eeaa2c06f7c78b8d7eba042db52b097a9a514ce (commit)

- Log -----------------------------------------------------------------
commit 4eeaa2c06f7c78b8d7eba042db52b097a9a514ce
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Nov 24 18:28:10 2021 -0600

    Add initial check module

diff --git a/README b/README
index acb3b00..f2b67e6 100644
--- a/README
+++ b/README
@@ -1,3 +1,29 @@
 NAME
     App::AWS::CloudWatch::Monitor::Check::MailQueue - gather mail queue
     count
+
+SYNOPSIS
+     my $plugin  = App::AWS::CloudWatch::Monitor::Check::MailQueue->new();
+     my $metrics = $plugin->check();
+
+     perl bin/aws-cloudwatch-monitor --check MailQueue
+
+DESCRIPTION
+    "App::AWS::CloudWatch::Monitor::Check::MailQueue" is a
+    "App::AWS::CloudWatch::Monitor::Check" module which gathers current mail
+    queue count.
+
+METRICS
+    The following metrics are gathered and returned.
+
+    mail-Queue
+
+METHODS
+    check
+        Gathers the metric data and returns an arrayref of hashrefs with
+        keys "MetricName", "Unit", "RawValue".
+
+DEPENDENCIES
+    <App::AWS::CloudWatch::Monitor::Check::MailQueue> depends on the
+    external program, "mailq".
+
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/MailQueue.pm b/lib/App/AWS/CloudWatch/Monitor/Check/MailQueue.pm
new file mode 100644
index 0000000..d3ac6c3
--- /dev/null
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/MailQueue.pm
@@ -0,0 +1,89 @@
+package App::AWS::CloudWatch::Monitor::Check::MailQueue;
+
+use strict;
+use warnings;
+
+use parent 'App::AWS::CloudWatch::Monitor::Check';
+
+our $VERSION = '0.01';
+
+sub check {
+    my $self = shift;
+    my $arg  = shift;
+
+    my @mailq_command = (qw{ /usr/bin/mailq });
+    my ( $exit, $stdout, $stderr ) = $self->run_command( \@mailq_command );
+
+    if ($exit) {
+        die "$stderr\n";
+    }
+
+    return unless $stdout;
+
+    my $mailq_count;
+    foreach my $line ( @{$stdout} ) {
+        if ( $line =~ /Mail queue is empty/ ) {
+            $mailq_count = 0;
+            last;
+        }
+
+        if ( $line =~ /in (\d+) Request/ ) {
+            $mailq_count = $1;
+            last;
+        }
+    }
+
+    return [
+        {   MetricName => 'mail-Queue',
+            Unit       => 'Count',
+            RawValue   => $mailq_count,
+        },
+    ];
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+App::AWS::CloudWatch::Monitor::Check::MailQueue - gather mail queue count
+
+=head1 SYNOPSIS
+
+ my $plugin  = App::AWS::CloudWatch::Monitor::Check::MailQueue->new();
+ my $metrics = $plugin->check();
+
+ perl bin/aws-cloudwatch-monitor --check MailQueue
+
+=head1 DESCRIPTION
+
+C<App::AWS::CloudWatch::Monitor::Check::MailQueue> is a C<App::AWS::CloudWatch::Monitor::Check> module which gathers current mail queue count.
+
+=head1 METRICS
+
+The following metrics are gathered and returned.
+
+=over
+
+=item mail-Queue
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item check
+
+Gathers the metric data and returns an arrayref of hashrefs with keys C<MetricName>, C<Unit>, C<RawValue>.
+
+=back
+
+=head1 DEPENDENCIES
+
+<App::AWS::CloudWatch::Monitor::Check::MailQueue> depends on the external program, C<mailq>.
+
+=cut
-----------------------------------------------------------------------


hooks/post-receive
-- 
app-aws-cloudwatch-monitor-check-mailqueue


More information about the Bps-public-commit mailing list