zabbix-agent-addons/zabbix_scripts/disco_raid_mdadm

19 lines
503 B
Plaintext
Raw Normal View History

#!/usr/bin/perl -w
use strict;
use JSON;
my $json;
@{$json->{data}} = ();
2018-02-06 10:53:15 +01:00
if (!-x '/usr/bin/systemd-detect-virt' || system('/usr/bin/systemd-detect-virt', '-qc') != 0){
2018-01-09 17:23:35 +01:00
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);