add block discovery

tags/zabbix-agent-addons-0.2.20-1
Daniel Berteaud 12 years ago
parent 7ca8e6daa4
commit ea9c30ac6c
  1. 2
      conf/block_devices.conf
  2. 22
      scripts/disco_block_devices

@ -0,0 +1,2 @@
# Discover block devices
UserParameter=vfs.dev.discovery,/var/lib/zabbix/bin/disco_block_devices

@ -0,0 +1,22 @@
#!/usr/bin/perl -w
use JSON;
opendir(my $dh, "/sys/block") or die "Couldn't open /sys/block: $!";
my @blocks = grep { $_ !~ m/^\./ } readdir($dh);
closedir($dh);
my $json;
foreach my $block (@blocks){
my $remouvable = 0;
if ( -e "/sys/block/$block/remouvable"){
open REMOUVABLE, "/sys/block/$block/remouvable";
$remouvable = join "", <REMOUVABLE>;
close REMOUVABLE;
chomp($remouvable);
next if ($remouvable eq '1');
}
my $dev = '/dev/' . $block;
push @{$json->{data}}, { "{#BLOCKDEVICE}" => $dev };
}
print to_json($json);
exit(0);
Loading…
Cancel
Save