mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Update quota2percent_
add POD documentation add env.language add example graph for Munin Plugin Gallery remove German comments
This commit is contained in:
parent
dab96a619f
commit
f21a2fe432
1 changed files with 135 additions and 73 deletions
|
@ -1,45 +1,116 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# -*- sh -*-
|
||||||
|
: <<=cut
|
||||||
|
|
||||||
# Das Plugin zeigt die Festplattenbelegung in Prozent des Quota-Hard-Limits.
|
=head1 NAME
|
||||||
# Munin plugin to show the disk usage in percent of the quota hard limit.
|
|
||||||
# The base frame is copied from the proftp plugin
|
|
||||||
|
|
||||||
##########################################################################################
|
quota2percent - Plugin to show disk usage in percent of quota hard limit.
|
||||||
# Folgende Eintraege in der Datei /etc/munin/plugin-conf.d/munin-node nicht vergessen ! #
|
|
||||||
# Don't forget to add following lines to the file /etc/munin/plugin-conf.d/munin-node #
|
|
||||||
# [quota2percent_*] #
|
|
||||||
# user root #
|
|
||||||
# #
|
|
||||||
# Weiterhin sind folgende Environment-Variablen erlaubt: #
|
|
||||||
# Following environment variables are allowed: #
|
|
||||||
# env.warning [value] #
|
|
||||||
# env.critical [value] #
|
|
||||||
# V17.0124 Jo Hartmann #
|
|
||||||
##########################################################################################
|
|
||||||
|
|
||||||
# Spachauswahl
|
=head1 APPLICABLE SYSTEMS
|
||||||
# Language selection
|
|
||||||
Language="de"
|
|
||||||
|
|
||||||
|
All systems with "bash", "quota", "repquota" and "munin"
|
||||||
|
|
||||||
|
=head1 CONFIGURATION
|
||||||
|
|
||||||
|
The following is the default configuration
|
||||||
|
|
||||||
|
[quota2percent_*]
|
||||||
|
user root
|
||||||
|
|
||||||
|
You could define two alert levels and the graph language
|
||||||
|
|
||||||
|
[quota2percent_*]
|
||||||
|
env.warning [value] (default: 90)
|
||||||
|
env.critical [value] (default: 95)
|
||||||
|
env.language [en|de|es] (default: en)
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
Wild card Plugin for monitoring the utilization of devices with quota rules.
|
||||||
|
A graph is drawn for each user, which shows the usage as a percentage of his hard limit. System accounts (UID <1000) are suppressed.
|
||||||
|
In addition, a graph is displayed which indicates the ratio device size to device coverage.
|
||||||
|
The script repqutoa, usually part of the package quota, is needed.
|
||||||
|
The plugin itself can be stored in any directory. For example, the device sdb1 shell be monitored, a symbolic link must be created
|
||||||
|
in the /etc/munin/plugins/ directory as follows:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
I<<< ln -s /<path to file>/quota2percent_ quota2percent_sdb1 >>>
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 MAGIC MARKERS
|
||||||
|
|
||||||
|
#%# family=auto
|
||||||
|
#%# capabilities=autoconf
|
||||||
|
|
||||||
|
=head1 VERSION
|
||||||
|
|
||||||
|
17.0131
|
||||||
|
|
||||||
|
=head1 HISTORY
|
||||||
|
|
||||||
|
V17.0131
|
||||||
|
|
||||||
|
add POD documentation
|
||||||
|
add env.language
|
||||||
|
add example graph for Munin Plugin Gallery
|
||||||
|
remove German comments
|
||||||
|
|
||||||
|
V17.0124
|
||||||
|
|
||||||
|
first version, not munin rules conform
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Jo Hartmann
|
||||||
|
|
||||||
|
=head1 LICENSE
|
||||||
|
|
||||||
|
GPLv2 (L<http://www.gnu.org/licenses/gpl-2.0.html>)
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Preparation section #
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
# Load munin's shell libary
|
||||||
|
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||||
|
|
||||||
|
# if any fetch from munin-node file
|
||||||
|
Warning=${warning:-90}
|
||||||
|
Critical=${critical:-95}
|
||||||
|
Language=${language:-en}
|
||||||
|
|
||||||
|
# Ensure that the 'root' path is valid
|
||||||
|
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
# Checking if repquota installed and on the path
|
||||||
|
repquota -V &> /dev/null
|
||||||
|
if ! repquota -V &> /dev/null ; then
|
||||||
|
echo "The script 'repquota' is not installed or on the path"
|
||||||
|
# Send the exit code FATAL ERROR happens
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
|
|
||||||
# Wildcard-Text erkennen
|
|
||||||
# get tehe wild card text
|
# get tehe wild card text
|
||||||
Id=$0
|
Id=${0##*_}
|
||||||
Id=${Id##*_}
|
|
||||||
|
###################################################
|
||||||
|
# Data reading sections #
|
||||||
|
###################################################
|
||||||
|
|
||||||
# Einlesen der Quoten für das entsprechende Laufwerk mit repquota
|
|
||||||
# Reading the quotes for the selected device, using repquota
|
# Reading the quotes for the selected device, using repquota
|
||||||
readarray Quotas < <( repquota /dev/$Id | grep " -- " )
|
readarray Quotas < <( repquota "/dev/$Id" | grep " -- " )
|
||||||
readarray Totals < <( df /dev/$Id )
|
readarray Totals < <( df "/dev/$Id" )
|
||||||
|
|
||||||
# Anzahl der Nutzer ermitteln
|
|
||||||
# Get the count of Users
|
# Get the count of Users
|
||||||
Users=${#Quotas[@]}
|
Users=${#Quotas[@]}
|
||||||
|
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Beginn der Standard-Konfigurationsbereiches #
|
# Munin Configuration Section #
|
||||||
# Standard Config Section Begin #
|
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
if [ "$1" = "autoconf" ]; then
|
||||||
|
@ -47,97 +118,88 @@
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
# Anpassung der Texte in der Grafik
|
|
||||||
# Localisation of the graphic texts
|
# Localisation of the graphic texts
|
||||||
case $Language in
|
case $Language in
|
||||||
de)
|
de)
|
||||||
echo graph_title Quota-Hard-Limit von $Id
|
echo graph_title "Quota-Hard-Limit von $Id"
|
||||||
echo graph_vlabel Nutzung in % Hardlimit
|
echo graph_vlabel "Nutzung in % Hardlimit"
|
||||||
echo graph_info "Die Grafik zeigt die Belegung des durch Quota reglementierten Speicherplatzes für alle regulären Nutzer (UID >=1000) in Prozent des Hardlimits."
|
echo graph_info "Die Grafik zeigt die Belegung des durch Quota reglementierten Speicherplatzes für alle regulären Nutzer (UID >=1000) in Prozent des Hardlimits."
|
||||||
Total_txt="Su. aller Nutzer"
|
Total_txt="Su. aller Nutzer"
|
||||||
Total_info="Inklusive Systemnutzer (UID < 1000)"
|
Total_info="Inklusive Systemnutzer (UID < 1000)"
|
||||||
;;
|
;;
|
||||||
es)
|
es)
|
||||||
echo graph_title Cuota de límite absoluto de $ Id
|
echo graph_title "Cuota de límite absoluto de $Id"
|
||||||
echo graph_vlabel el % de uso del límite duro
|
echo graph_vlabel "el % de uso del límite duro"
|
||||||
echo graph_info "El gráfico muestra la disponibilidad de espacio regulado por cuotas para todos los usuarios regulares (UID> = 1000) como porcentaje de límites duros."
|
echo graph_info "El gráfico muestra la disponibilidad de espacio regulado por cuotas para todos los usuarios regulares (UID> = 1000) como porcentaje de límites duros."
|
||||||
Total_txt="Suma de todos los usuarios "
|
Total_txt="Suma de todos los usuarios "
|
||||||
Total_info="La inclusión de usuario del sistema (UID <1000) "
|
Total_info="La inclusión de usuario del sistema (UID <1000) "
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo graph_title quota hard limit of %Id
|
echo graph_title "quota hard limit of $Id"
|
||||||
echo graph_vlabel Usage in %
|
echo graph_vlabel "Usage in %"
|
||||||
Total_txt="all users"
|
|
||||||
echo graph_info "The graphic shows the allocation of the quota-regulated storage space for all regular users (UID> = 1000) as a percentage of the hard limit ."
|
echo graph_info "The graphic shows the allocation of the quota-regulated storage space for all regular users (UID> = 1000) as a percentage of the hard limit ."
|
||||||
|
Total_txt="all users"
|
||||||
Total_info="system users (UID < 1000) included"
|
Total_info="system users (UID < 1000) included"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Standard Konfiguration
|
|
||||||
# Defaults configuration
|
# Defaults configuration
|
||||||
echo graph_category disk
|
echo graph_category disk
|
||||||
echo graph_args --lower-limit 0 --upper-limit 100
|
echo graph_args --lower-limit 0 --upper-limit 100
|
||||||
echo graph_printf %5.2lf %%
|
echo graph_printf %5.2lf %%
|
||||||
echo graph_scale no
|
echo graph_scale no
|
||||||
|
|
||||||
# Ggf. Werte aus der Datei munin-node uebernehmen
|
|
||||||
# if any fetch from munin-node file
|
|
||||||
Warning=${warning:-90}
|
|
||||||
Critical=${critical:-95}
|
|
||||||
|
|
||||||
# Die Quota-Nutzer und deren Real-Namen ermitteln, das Root-Problem beheben, die Kondfigurationsdaten ausgeben
|
|
||||||
# For each quota user fetch his real name, solve the root problem, Output the configuration data
|
# For each quota user fetch his real name, solve the root problem, Output the configuration data
|
||||||
for((i=0; i<$Users; i++));do
|
for((i=0; i<"$Users"; i++));do
|
||||||
Quota=( ${Quotas[$i]} )
|
Quota=( ${Quotas[$i]} )
|
||||||
User=${Quota[0]}
|
UserName=${Quota[0]}
|
||||||
Passwd=$(cat /etc/passwd | grep $User)
|
#Passwd=$(cat /etc/passwd | grep $UserName)
|
||||||
|
Passwd=$(grep "$UserName" /etc/passwd)
|
||||||
OLDIFS=$IFS
|
OLDIFS=$IFS
|
||||||
IFS=':' Infos=($Passwd)
|
IFS=':' Infos=($Passwd)
|
||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
Name=${Infos[4]}
|
UserInfo=${Infos[4]}
|
||||||
Name=${Name%%,*}
|
UserInfo=${UserInfo%%,*}
|
||||||
|
|
||||||
[ $User == "root" ] && { User="__root"; Name="__root";}
|
UserName="$(clean_fieldname "$UserName")"
|
||||||
[ ! -n "$Name" ] && Name=$User
|
UserInfo="$(clean_fieldname "$UserInfo")"
|
||||||
[ $(id -u ${Quota[0]}) -lt 1000 ] && echo $User.graph no
|
|
||||||
echo $User.label $Name
|
[ ! -n "$UserInfo" ] && UserInfo="$UserName"
|
||||||
echo $User.warning $warning
|
[ "$(id -u "${Quota[0]}")" -lt 1000 ] && echo "$UserName.graph no"
|
||||||
echo $User.critical $critical
|
echo "$UserName.label $UserInfo"
|
||||||
|
echo "$UserName.warning $Warning"
|
||||||
|
echo "$UserName.critical $Critical"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Die Summenzeile konfigurieren
|
# configure the total line and send exit code NO ERROR happens
|
||||||
# configure the total line
|
echo total.label "$Total_txt"
|
||||||
echo total.label $Total_txt
|
echo total.warning "$Warning"
|
||||||
echo total.warning $Warning
|
echo total.critical "$Critical"
|
||||||
echo total.critical $Critical
|
echo total.info "$Total_info"
|
||||||
echo total.info $Total_info
|
exit 0
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Ende der Standard-Konfigurationsbereiches #
|
# Munin value section #
|
||||||
# Standard Config Section End #
|
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
# Die Werte (Belegung und Hardlimit) je Nutzer ermitteln, das Root-Problem umgehen, die Prozente berechnen
|
|
||||||
# fetch the needed values (used and hard limit) for each user, work around the root problem, calculate the percent value
|
# fetch the needed values (used and hard limit) for each user, work around the root problem, calculate the percent value
|
||||||
for((i=0; i<$Users; i++));do
|
for((i=0; i<"$Users"; i++));do
|
||||||
Quota=( ${Quotas[$i]} )
|
Quota=( ${Quotas[$i]} )
|
||||||
User=${Quota[0]}
|
UserName="$(clean_fieldname "${Quota[0]}")"
|
||||||
[ $User == "root" ] && User="__root"
|
echo "${Quota[2]} ${Quota[4]} $UserName.value" | awk '{printf "%s %.2f\n", $3 ,$1*100/$2}'
|
||||||
Prozent=`echo "scale=2 ; ${Quota[2]}*100/${Quota[4]}" | bc`
|
|
||||||
|
|
||||||
echo $User.value $Prozent
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Die Summenwerte
|
|
||||||
# the value for the total line
|
# the value for the total line
|
||||||
Total=( ${Totals[1]} )
|
Total=( ${Totals[1]} )
|
||||||
Summe=`echo "scale=2;${Total[2]}*100/${Total[1]}" | bc`
|
echo "${Total[2]} ${Total[1]} total.value" | awk '{printf "%s %.2f\n", $3, $1*100/$2}'
|
||||||
echo total.value $Summe
|
|
||||||
|
|
||||||
|
# send the exit code NO ERROR happens
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Script end #
|
||||||
|
###################################################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue