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

BPS Git Server git at git.bestpractical.com
Tue May 24 21:44:25 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  da75b97d8e67d1cc30d9da2b01abb685c74929bd (commit)

- Log -----------------------------------------------------------------
commit da75b97d8e67d1cc30d9da2b01abb685c74929bd
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 44e9e98..3af7410 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