Additional scripts for Zabbix agent on Linux to discover and monitor several services
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.
 
 

22 lines
558 B

#!/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;
@{$json->{data}} = ();
foreach my $block (@blocks){
my $size = 1;
if ( -e "/sys/block/$block/size"){
open SIZE, "/sys/block/$block/size";
$size = join "", <SIZE>;
close SIZE;
chomp($size);
next if ($size eq '0');
}
push @{$json->{data}}, { "{#BLOCKDEVICE}" => $block, "{#BLOCKSIZE}" => $size };
}
print to_json($json);
exit(0);