[Bps-public-commit] app-aws-cloudwatch-monitor branch master updated. 225f206fc58a7d64369543193d40d007987858fe

BPS Git Server git at git.bestpractical.com
Wed Apr 10 16:13:50 UTC 2024


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".

The branch, master has been updated
       via  225f206fc58a7d64369543193d40d007987858fe (commit)
       via  07030af16e23366e36d50956d3563fb1c4dac45b (commit)
       via  25966fe0e9591ffb4a58785744bba20519aaff00 (commit)
      from  a683d8799ef2e6a3c21a98c98fcc15dec7ae3801 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 225f206fc58a7d64369543193d40d007987858fe
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Wed Apr 10 13:04:10 2024 -0300

    Prepare version 0.05

diff --git a/Changes b/Changes
index c062db1..1f8d726 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for perl module App::AWS::CloudWatch::Monitor
 
+0.05 2024-04-10
+ - Add arguments to set the number of retries and delay between them
+ - Removed some unsed code (max-backoff-sec)
+
 0.04 2024-03-12
  - Add PostfixLog Check
 
diff --git a/bin/aws-cloudwatch-monitor b/bin/aws-cloudwatch-monitor
index 15b2799..c9cc055 100755
--- a/bin/aws-cloudwatch-monitor
+++ b/bin/aws-cloudwatch-monitor
@@ -21,7 +21,7 @@ use Getopt::Long qw(:config pass_through);
 use Pod::Usage ();
 use App::AWS::CloudWatch::Monitor;
 
-my $VERSION = '0.03';
+my $VERSION = '0.05';
 
 Getopt::Long::GetOptions(
     \my %opt,
diff --git a/lib/App/AWS/CloudWatch/Monitor.pm b/lib/App/AWS/CloudWatch/Monitor.pm
index d5b4e5f..6f074bc 100644
--- a/lib/App/AWS/CloudWatch/Monitor.pm
+++ b/lib/App/AWS/CloudWatch/Monitor.pm
@@ -23,7 +23,7 @@ use List::Util;
 use Try::Tiny;
 use Module::Loader;
 
-our $VERSION = '0.04';
+our $VERSION = '0.05';
 
 my $config;
 
diff --git a/lib/App/AWS/CloudWatch/Monitor/AwsSignatureV4.pm b/lib/App/AWS/CloudWatch/Monitor/AwsSignatureV4.pm
index d229d53..6185294 100644
--- a/lib/App/AWS/CloudWatch/Monitor/AwsSignatureV4.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/AwsSignatureV4.pm
@@ -41,7 +41,7 @@ use Digest::SHA qw(sha256_hex hmac_sha256 hmac_sha256_hex);
 # For using PurePerl implementation of SHA functions
 # use Digest::SHA::PurePerl qw(sha256_hex hmac_sha256 hmac_sha256_hex);
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 # RFC3986 safe/unsafe characters
 our $SAFE_CHARACTERS   = 'A-Za-z0-9\-\._~';
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check.pm b/lib/App/AWS/CloudWatch/Monitor/Check.pm
index 744aee7..429f949 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check.pm
@@ -19,7 +19,7 @@ use warnings;
 
 use Capture::Tiny;
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub new {
     my $class = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm b/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
index 3fac519..3c1e5af 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
@@ -21,7 +21,7 @@ use parent 'App::AWS::CloudWatch::Monitor::Check';
 
 use Getopt::Long qw(:config pass_through);
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/Inode.pm b/lib/App/AWS/CloudWatch/Monitor/Check/Inode.pm
index 7633476..09573b4 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/Inode.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/Inode.pm
@@ -21,7 +21,7 @@ use parent 'App::AWS::CloudWatch::Monitor::Check';
 
 use Getopt::Long qw(:config pass_through);
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/LoadAvg.pm b/lib/App/AWS/CloudWatch/Monitor/Check/LoadAvg.pm
index b396db6..8088270 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/LoadAvg.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/LoadAvg.pm
@@ -19,7 +19,7 @@ use warnings;
 
 use parent 'App::AWS::CloudWatch::Monitor::Check';
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/Memory.pm b/lib/App/AWS/CloudWatch/Monitor/Check/Memory.pm
index 4174ce2..0e6842d 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/Memory.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/Memory.pm
@@ -19,7 +19,7 @@ use warnings;
 
 use parent 'App::AWS::CloudWatch::Monitor::Check';
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/PostfixLog.pm b/lib/App/AWS/CloudWatch/Monitor/Check/PostfixLog.pm
index ba2d22c..a7e3536 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/PostfixLog.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/PostfixLog.pm
@@ -21,7 +21,7 @@ use parent 'App::AWS::CloudWatch::Monitor::Check';
 
 use Getopt::Long qw(:config pass_through);
 
-our $VERSION = '0.01';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/Process.pm b/lib/App/AWS/CloudWatch/Monitor/Check/Process.pm
index 8afae3f..33b3dc1 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/Process.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/Process.pm
@@ -21,7 +21,7 @@ use parent 'App::AWS::CloudWatch::Monitor::Check';
 
 use Getopt::Long qw(:config pass_through);
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
index 3bf0ab7..e3c75cc 100644
--- a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
@@ -45,7 +45,7 @@ use LWP 6;
 use LWP::Simple qw($ua get);
 $ua->timeout(2);    # timeout for meta-data calls
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 our %version_prefix_map = ( '2010-08-01' => [ 'GraniteServiceVersion20100801', 'com.amazonaws.cloudwatch.v2010_08_01#' ] );
 
diff --git a/lib/App/AWS/CloudWatch/Monitor/Config.pm b/lib/App/AWS/CloudWatch/Monitor/Config.pm
index ad67546..9284756 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Config.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Config.pm
@@ -19,7 +19,7 @@ use warnings;
 
 use Config::Tiny;
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub load {
     my $config = _load_and_verify();
diff --git a/t/lib/App/AWS/CloudWatch/Monitor/Check/TestArgs.pm b/t/lib/App/AWS/CloudWatch/Monitor/Check/TestArgs.pm
index 830ec84..4a5c5e1 100644
--- a/t/lib/App/AWS/CloudWatch/Monitor/Check/TestArgs.pm
+++ b/t/lib/App/AWS/CloudWatch/Monitor/Check/TestArgs.pm
@@ -7,7 +7,7 @@ use parent 'App::AWS::CloudWatch::Monitor::Check';
 
 use Getopt::Long qw(:config pass_through);
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/t/lib/App/AWS/CloudWatch/Monitor/Check/TestSuccess.pm b/t/lib/App/AWS/CloudWatch/Monitor/Check/TestSuccess.pm
index 01c8b97..816b72f 100644
--- a/t/lib/App/AWS/CloudWatch/Monitor/Check/TestSuccess.pm
+++ b/t/lib/App/AWS/CloudWatch/Monitor/Check/TestSuccess.pm
@@ -5,7 +5,7 @@ use warnings;
 
 use parent 'App::AWS::CloudWatch::Monitor::Check';
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub check {
     my $self = shift;
diff --git a/t/lib/App/AWS/CloudWatch/Monitor/Test.pm b/t/lib/App/AWS/CloudWatch/Monitor/Test.pm
index b96fe8f..8fa3bc5 100644
--- a/t/lib/App/AWS/CloudWatch/Monitor/Test.pm
+++ b/t/lib/App/AWS/CloudWatch/Monitor/Test.pm
@@ -5,7 +5,7 @@ use warnings;
 
 use parent 'Test::More';
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 sub import {
     my $class = shift;
commit 07030af16e23366e36d50956d3563fb1c4dac45b
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Wed Apr 10 11:45:30 2024 -0300

    Remove some unsed code inherited from the original codebase
    
    The original project used as a base for this project is archived and
    some of the code is not used in this project.
    
    This commit removes the a block of code that would never be executed
    by this project because we don't implement the max-backoff-sec argument.

diff --git a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
index 426b212..3bf0ab7 100644
--- a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
@@ -814,9 +814,6 @@ sub call {
     if ( defined( $opts->{'retries'} ) ) {
         $call_attempts += $opts->{'retries'};
     }
-    if ( defined( $opts->{'max-backoff-sec'} ) ) {
-        $max_delay = $opts->{'max-backoff-sec'};
-    }
 
     my $response_code = 0;
 
commit 25966fe0e9591ffb4a58785744bba20519aaff00
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Wed Apr 10 11:45:10 2024 -0300

    Add arguments to specify retries and retry delay
    
    The script already had a retry mechanism, but the number of retries and
    the delay between them were hardcoded. This commit adds command line
    arguments to specify the number of retries, initial delay and maximum
    delay between retries.

diff --git a/bin/aws-cloudwatch-monitor b/bin/aws-cloudwatch-monitor
index 0768834..15b2799 100755
--- a/bin/aws-cloudwatch-monitor
+++ b/bin/aws-cloudwatch-monitor
@@ -28,6 +28,9 @@ Getopt::Long::GetOptions(
     'check=s@',
     'from-cron',
     'verify',
+    'retries=s',
+    'initial-delay=s',
+    'max-delay=s',
     'verbose',
     'version' => sub { print "aws-cloudwatch-monitor version $VERSION\n"; exit 0 },
     'help',
@@ -60,6 +63,7 @@ aws-cloudwatch-monitor - collect and send metrics to AWS CloudWatch
 
  aws-cloudwatch-monitor [--check <module>]
                         [--from-cron] [--verify] [--verbose]
+                        [--retries <count>] [--initial-delay <seconds>] [--max-delay <seconds>]
                         [--version] [--help]
 
 =head1 DESCRIPTION
@@ -76,6 +80,28 @@ Defines the checks to run.
 
 Multiple C<--check> options may be defined and are run in the order they're passed.
 
+=item --retries <count>
+
+Specifies the number of times to retry sending metrics to CloudWatch if the initial attempt fails.
+It will retry if getting a 5xx response or a 400 with a message containing "Throttling".
+If not specified, the default is 2 (so it will attempt to send metrics 3 times)
+
+=item --initial-delay <seconds>
+
+Specifies the initial delay in seconds before retrying to send metrics to CloudWatch.
+If not specified, the default is 4.
+Each subsequent retry will double the delay up to the maximum delay.
+
+=item --max-delay <seconds>
+
+Specifies the maximum delay in seconds before retrying to send metrics to CloudWatch.
+If not specified, the default is 16.
+
+Note: if you want to have a constant delay between retries, set --initial-delay and --max-delay
+to the same value.
+
+    aws-cloudwatch-monitor --retries 5 --initial-delay 30 --max-delay 30
+
 =item --from-cron
 
 Specifies that this script is running from cron.
diff --git a/lib/App/AWS/CloudWatch/Monitor.pm b/lib/App/AWS/CloudWatch/Monitor.pm
index 2411d9e..d5b4e5f 100644
--- a/lib/App/AWS/CloudWatch/Monitor.pm
+++ b/lib/App/AWS/CloudWatch/Monitor.pm
@@ -106,7 +106,7 @@ sub run {
 
     $opt->{'aws-access-key-id'} = $self->config->{aws}{aws_access_key_id};
     $opt->{'aws-secret-key'}    = $self->config->{aws}{aws_secret_access_key};
-    $opt->{retries}             = 2;
+    $opt->{retries}             //= 2;
     $opt->{'user-agent'}        = CLIENT_NAME . "/$VERSION";
 
     my $response = App::AWS::CloudWatch::Monitor::CloudWatchClient::call_json( 'PutMetricData', $param, $opt );
diff --git a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
index e078f3d..426b212 100644
--- a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
@@ -808,8 +808,8 @@ sub call {
     print_out( "Payload: $payload",   $outfile ) if $verbose;
 
     # initial and max delay in seconds between retries
-    my $delay     = 4;
-    my $max_delay = 16;
+    my $delay     = $opts->{'initial-delay'} || 4;
+    my $max_delay = $opts->{'max-delay'} || 16;
 
     if ( defined( $opts->{'retries'} ) ) {
         $call_attempts += $opts->{'retries'};
-----------------------------------------------------------------------

Summary of changes:
 Changes                                            |  4 ++++
 bin/aws-cloudwatch-monitor                         | 28 +++++++++++++++++++++-
 lib/App/AWS/CloudWatch/Monitor.pm                  |  4 ++--
 lib/App/AWS/CloudWatch/Monitor/AwsSignatureV4.pm   |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check.pm            |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm  |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/Inode.pm      |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/LoadAvg.pm    |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/Memory.pm     |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/PostfixLog.pm |  2 +-
 lib/App/AWS/CloudWatch/Monitor/Check/Process.pm    |  2 +-
 lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm |  9 +++----
 lib/App/AWS/CloudWatch/Monitor/Config.pm           |  2 +-
 t/lib/App/AWS/CloudWatch/Monitor/Check/TestArgs.pm |  2 +-
 .../AWS/CloudWatch/Monitor/Check/TestSuccess.pm    |  2 +-
 t/lib/App/AWS/CloudWatch/Monitor/Test.pm           |  2 +-
 16 files changed, 48 insertions(+), 21 deletions(-)


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


More information about the Bps-public-commit mailing list