2009-02-10 17:36:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Plugin to monitor the size of the specified directory
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Parameters understood:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional - checks if the path exists etc, not so advanced feature)
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Requirements
|
|
|
|
# - bash (or change first line to sh instead of bash or any other shell)
|
|
|
|
# - existing and readable directory to scan
|
2018-08-02 02:03:42 +02:00
|
|
|
# - du command, it exists on most of the *nix operating systems
|
2009-02-10 17:36:13 +01:00
|
|
|
#
|
|
|
|
#################################################################
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2009-02-10 17:36:13 +01:00
|
|
|
# Configuration
|
|
|
|
#
|
|
|
|
# directory to check
|
|
|
|
DIR="/var/cache/apache2/"
|
|
|
|
|
2014-12-05 00:37:42 +01:00
|
|
|
# unique id, just in case you got multiple such scripts, change id as needed (i guess it should be obsolete, not tested)
|
2009-02-10 17:36:13 +01:00
|
|
|
ID=1;
|
|
|
|
|
2014-12-05 00:37:42 +01:00
|
|
|
# - make sure that user/group that executes this script has access to the directory you have configured
|
2009-02-10 17:36:13 +01:00
|
|
|
# otherwise run it as another user, edit plugins-conf.d/munin-node and stuff it with example below code (not suggested)
|
2014-12-05 00:37:42 +01:00
|
|
|
# remember to remove hashes from the beginning of the lines
|
2009-02-10 17:36:13 +01:00
|
|
|
#
|
|
|
|
# [du]
|
|
|
|
# user root
|
|
|
|
#
|
2017-04-17 22:43:38 +02:00
|
|
|
# - by default the value is in MegaBytes, to change it you should edit below line in the script to something else, recognizable by du (see man du)
|
2009-02-10 17:36:13 +01:00
|
|
|
# du -sm $DIR in MB
|
|
|
|
# du -sk $DIR in KB
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Changelog
|
|
|
|
#
|
|
|
|
# Revision 0.1 Tue 03 Feb 2009 02:16:02 PM CET _KaszpiR_
|
2018-08-02 02:03:42 +02:00
|
|
|
# - initial release,
|
|
|
|
#
|
2009-02-10 17:36:13 +01:00
|
|
|
#################################################################
|
|
|
|
# Magick markers (optional - used by munin-config and som installation
|
|
|
|
# scripts):
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
#################################################################
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
if [ -d $DIR ]; then
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no (check your path)"
|
|
|
|
fi
|
2018-09-16 04:01:57 +02:00
|
|
|
exit 0
|
2009-02-10 17:36:13 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
|
|
|
echo "graph_title Directory size: $DIR"
|
|
|
|
echo "graph_vlabel size MB"
|
|
|
|
echo "graph_category disk"
|
|
|
|
echo "graph_info Size of $DIR"
|
|
|
|
echo "dir$ID.label size"
|
|
|
|
echo "dir$ID.min 0"
|
|
|
|
echo "dir$ID.info Shows du -sm for specified directory"
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "dir$ID.value "
|
|
|
|
if [ -d $DIR ]; then
|
|
|
|
SIZE=`du -sm $DIR | cut -f1`
|
|
|
|
echo $SIZE
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "U"
|
|
|
|
exit 1
|
|
|
|
fi
|