parent
7ca8e6daa4
commit
ea9c30ac6c
2 changed files with 24 additions and 0 deletions
@ -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…
Reference in new issue