From 0c9fad57bdc45567908e72ee28abe2a9ebfcb21b Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 9 Jan 2018 17:23:35 +0100 Subject: [PATCH] Don't detect mdadm RAID in containers --- zabbix_scripts/disco_raid_mdadm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zabbix_scripts/disco_raid_mdadm b/zabbix_scripts/disco_raid_mdadm index 2a9b47a..d4c6b0f 100644 --- a/zabbix_scripts/disco_raid_mdadm +++ b/zabbix_scripts/disco_raid_mdadm @@ -6,11 +6,13 @@ use JSON; my $json; @{$json->{data}} = (); -open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!"; -foreach my $line () { - next unless ($line =~ m/^(md\d+)+\s*:/); - my ($md,undef,$status,$level) = split(/\ /, $line); - push @{$json->{data}}, {"{#DEVICE}" => $md, "{#STATUS}" => $status, "{#LEVEL}" => $level}; +if (-x '/bin/systemd-detect-virt' && system('/bin/systemd-detect-virt', '-qc') != 0){ + open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!"; + foreach my $line () { + 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);