You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
394 B
17 lines
394 B
10 years ago
|
#!/usr/bin/perl -w
|
||
|
|
||
|
use strict;
|
||
|
use JSON;
|
||
|
|
||
|
my $json;
|
||
|
@{$json->{data}} = ();
|
||
|
|
||
|
open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!";
|
||
|
foreach my $line (<FILE>) {
|
||
|
next unless ($line =~ m/^(md\d+)+\s*:/);
|
||
|
my ($md,undef,$status,$level) = split(/\ /, $line);
|
||
|
push @{$json->{data}}, {"{#DEVICE}" => $md, "{#STATUS}" => $status, "{#LEVEL}" => $level};
|
||
|
}
|
||
|
print to_json($json);
|
||
|
exit(0);
|