mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-26 02:48:28 +00:00
Merge pull request #299 from claudius23/zfs_usage_
plugins/zfs/zfs_usage_ add environment variables, call zfs binary only once
This commit is contained in:
commit
7bd75f1bfb
1 changed files with 20 additions and 12 deletions
|
@ -11,6 +11,19 @@ zfs_usage_ - Script to monitor zfs pool usage
|
||||||
|
|
||||||
Create one symlink per zpool for exampe zfs_usage_system
|
Create one symlink per zpool for exampe zfs_usage_system
|
||||||
|
|
||||||
|
if you need to override the defaults below:
|
||||||
|
|
||||||
|
[zfs_usage_*]
|
||||||
|
env.zpoolexec - Path to zpool binary
|
||||||
|
env.zfsexec - Path to zfs binary
|
||||||
|
|
||||||
|
=head2 DEFAULT CONFIGURATION
|
||||||
|
|
||||||
|
[zfs_usage_*]
|
||||||
|
env.zpoolexec /sbin/zpool
|
||||||
|
env.zfsexec /sbin/zfs
|
||||||
|
|
||||||
|
|
||||||
=head1 BUGS
|
=head1 BUGS
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -35,8 +48,8 @@ need_multigraph();
|
||||||
|
|
||||||
my $filesystems;
|
my $filesystems;
|
||||||
my $zpool;
|
my $zpool;
|
||||||
my $zpoolexec="/sbin/zpool";
|
my $zpoolexec = (defined($ENV{'zpoolexec'}) ? $ENV{'zpoolexec'} : '/sbin/zpool');
|
||||||
my $zfsexec="/sbin/zfs";
|
my $zfsexec = (defined($ENV{'zfsexec'}) ? $ENV{'zfsexec'} : '/sbin/zfs');
|
||||||
|
|
||||||
my $properties = {
|
my $properties = {
|
||||||
available => "Read-only property that identifies the amount of disk"
|
available => "Read-only property that identifies the amount of disk"
|
||||||
|
@ -142,18 +155,13 @@ my @order = (
|
||||||
);
|
);
|
||||||
|
|
||||||
sub do_collect {
|
sub do_collect {
|
||||||
my $fslist=(`$zfsexec list -H -r -o name $zpool`);
|
|
||||||
|
|
||||||
my @params = join(',',( keys %{$properties} ));
|
my @params = join(',',( keys %{$properties} ));
|
||||||
|
my $fsget="$zfsexec get -H -p -r -t filesystem,volume @params $zpool";
|
||||||
|
|
||||||
my $fsget="$zfsexec get -H -p @params";
|
foreach my $line (split(/\n/, `$fsget` )) {
|
||||||
|
my ($name, $key, $value, undef ) = (split(/\t/,$line));
|
||||||
foreach my $fsname (split(/\n/,$fslist)) {
|
($name =~ s/\//_/g);
|
||||||
foreach my $line (split(/\n/, `$fsget $fsname` )) {
|
$filesystems->{$name}->{$key}=$value;
|
||||||
my ($name, $key, $value, undef ) = (split(/\t/,$line));
|
|
||||||
($name =~ s/\//_/g);
|
|
||||||
$filesystems->{$name}->{$key}=$value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue