|
|
@ -6,11 +6,13 @@ use JSON; |
|
|
|
my $json; |
|
|
|
my $json; |
|
|
|
@{$json->{data}} = (); |
|
|
|
@{$json->{data}} = (); |
|
|
|
|
|
|
|
|
|
|
|
open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!"; |
|
|
|
if (-x '/bin/systemd-detect-virt' && system('/bin/systemd-detect-virt', '-qc') != 0){ |
|
|
|
foreach my $line (<FILE>) { |
|
|
|
open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!"; |
|
|
|
next unless ($line =~ m/^(md\d+)+\s*:/); |
|
|
|
foreach my $line (<FILE>) { |
|
|
|
my ($md,undef,$status,$level) = split(/\ /, $line); |
|
|
|
next unless ($line =~ m/^(md\d+)+\s*:/); |
|
|
|
push @{$json->{data}}, {"{#DEVICE}" => $md, "{#STATUS}" => $status, "{#LEVEL}" => $level}; |
|
|
|
my ($md,undef,$status,$level) = split(/\ /, $line); |
|
|
|
|
|
|
|
push @{$json->{data}}, {"{#DEVICE}" => $md, "{#STATUS}" => $status, "{#LEVEL}" => $level}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
print to_json($json); |
|
|
|
print to_json($json); |
|
|
|
exit(0); |
|
|
|
exit(0); |
|
|
|