DiskUsage probe for getting df output
Robert 'phaylon' Sedlacek [Wed, 9 May 2012 01:34:35 +0000 (01:34 +0000)]
lib/System/Introspector/DiskUsage.pm [new file with mode: 0644]

diff --git a/lib/System/Introspector/DiskUsage.pm b/lib/System/Introspector/DiskUsage.pm
new file mode 100644 (file)
index 0000000..061a6da
--- /dev/null
@@ -0,0 +1,25 @@
+package System::Introspector::DiskUsage;
+use Moo;
+
+sub gather {
+    my ($self) = @_;
+    my @lines = `df -aP`;
+    shift @lines; # header
+    chomp @lines;
+    my @rows;
+    for my $line (@lines) {
+        my %row;
+        @row{qw(
+            filesystem
+            blocks_1024
+            used
+            available
+            capacity
+            mount_point
+        )} = split m{\s+}, $line;
+        push @rows, \%row;
+    }
+    return \@rows;
+}
+
+1;