/usr/share/munin/plugins/quota_usage_ is in munin-plugins-core 2.0.19-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #!/usr/bin/perl
#
# Plugin to monitor quota on a specified device. Needs repquota and root privs
#
# Usage: place in /etc/munin/node.d/quota-usage_<dev> (or link it there using
# ln -s), for example quota-usage_hda3. Use underscores instead of slashes, for
# example to monitor /dev/mapper/vol-foo, name this quota-usage_mapper_vol-foo
#
# Parameters understood:
#
# config (required)
#
#%# family=manual
use strict;
use warnings;
use Munin::Plugin;
# We do some magic to allow device strings with underscore to mean a /
# So to monitor /dev/mapper/vol-foo use quota-usage_mapper_vol-foo
my @tmp = split(/_/, $0);
shift @tmp;
my $dev = join("/", @tmp);
my %users;
open (REP, "/usr/sbin/repquota /dev/$dev |") or exit 22;
while (<REP>) {
chomp;
if (/^-+$/../^$/) {
my @data = split(/ +/);
$users{$data[0]} = $data[2] if (@data > 2 && $data[2] > 0);
}
}
close REP;
my @users_by_usage = sort { $users{$b} <=> $users{$a} } keys(%users);
if ($ARGV[0] and $ARGV[0] eq "config") {
print "graph_title Filesystem usage by user on $dev\n";
print "graph_args --base 1024 --lower-limit 0\n";
print "graph_vlabel bytes\n";
print "graph_category disk\n";
for my $user (@users_by_usage) {
my ($uid, $name) = (getpwnam($user))[2,6];
$name = $user if (length($name) < length($user));
$user = clean_fieldname($user);
$name = (split(/,/, $name))[0];
printf "%s.label %s\n", $user, $name;
printf "%s.cdef %s,1024,*\n", $user, $user;
printf "%s.graph no\n", $user if ($uid < 1000);
}
} else {
for my $user (@users_by_usage) {
my $esc = $user;
$esc = clean_fieldname($esc);
printf "%s.value %s\n", $esc, $users{$user};
}
}
# vim: set ts=4 sw=4:
|