[Bps-public-commit] app-aws-cloudwatch-monitor branch add-uuid-to-metrics-dimensions created. b68f665d18789b034bb1dbe0153ad5e054203113

BPS Git Server git at git.bestpractical.com
Fri Jul 22 23:16:02 UTC 2022


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, add-uuid-to-metrics-dimensions has been created
        at  b68f665d18789b034bb1dbe0153ad5e054203113 (commit)

- Log -----------------------------------------------------------------
commit b68f665d18789b034bb1dbe0153ad5e054203113
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Fri May 13 18:47:09 2022 -0500

    Add UUID to DiskSpace metrics dimensions

diff --git a/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm b/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
index 3fac519..d57c9b2 100644
--- a/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/Check/DiskSpace.pm
@@ -43,9 +43,25 @@ sub check {
     return unless $stdout;
 
     shift @{$stdout};
+    my @df_out = @{$stdout};
+
+    my @lsblk_command = ( qw{ lsblk -o }, 'NAME,UUID', qw{ -lnp } );
+    ( $exit, $stdout, $stderr ) = $self->run_command( \@lsblk_command );
+
+    if ($exit) {
+        die "$stderr\n";
+    }
+
+    my %uuids = ();
+    foreach my $lsblk_line ( @{$stdout} ) {
+        my @fields = split /\s+/, $lsblk_line;
+        if ( defined $fields[0] && defined $fields[1] ) {
+            $uuids{ $fields[0] } = $fields[1];
+        }
+    }
 
     my $metrics;
-    foreach my $line ( @{$stdout} ) {
+    foreach my $line (@df_out) {
         my @fields = split /\s+/, $line;
 
         my $disk_total = $fields[1] * $self->constants->{KILO};
@@ -53,6 +69,7 @@ sub check {
         my $disk_avail = $fields[3] * $self->constants->{KILO};
         my $filesystem = $fields[0];
         my $mount_path = $fields[5];
+        my $uuid       = $uuids{$filesystem};
 
         push @{$metrics},
             {
@@ -66,6 +83,9 @@ sub check {
                 {   Name  => 'MountPath',
                     Value => $mount_path,
                 },
+                {   Name  => 'UUID',
+                    Value => $uuid,
+                },
             ],
             },
             {
@@ -79,6 +99,9 @@ sub check {
                 {   Name  => 'MountPath',
                     Value => $mount_path,
                 },
+                {   Name  => 'UUID',
+                    Value => $uuid,
+                },
             ],
             },
             {
@@ -92,6 +115,9 @@ sub check {
                 {   Name  => 'MountPath',
                     Value => $mount_path,
                 },
+                {   Name  => 'UUID',
+                    Value => $uuid,
+                },
             ],
             };
     }
-----------------------------------------------------------------------


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


More information about the Bps-public-commit mailing list