root / plugins / disk / du @ 8589c6df
Historique | Voir | Annoter | Télécharger (2,36 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
################################################################# |
| 4 |
# |
| 5 |
# Plugin to monitor the size of the specified directory |
| 6 |
# |
| 7 |
################################################################# |
| 8 |
# |
| 9 |
# Parameters understood: |
| 10 |
# |
| 11 |
# config (required) |
| 12 |
# autoconf (optional - checks if the path exists etc, not so advanced feature) |
| 13 |
# |
| 14 |
################################################################# |
| 15 |
# |
| 16 |
# Requirements |
| 17 |
# - bash (or change first line to sh instead of bash or any other shell) |
| 18 |
# - existing and readable directory to scan |
| 19 |
# - du command, it exists on most of the *nix operating systems |
| 20 |
# |
| 21 |
################################################################# |
| 22 |
# |
| 23 |
# Configuration |
| 24 |
# |
| 25 |
# directory to check |
| 26 |
DIR="/var/cache/apache2/" |
| 27 |
|
| 28 |
# unique id, just in case you got multiple such scripts, change id as needed (i guess it should be obsolete, not tested) |
| 29 |
ID=1; |
| 30 |
|
| 31 |
# - make sure that user/group that executes this script has access to the directory you have configured |
| 32 |
# otherwise run it as another user, edit plugins-conf.d/munin-node and stuff it with example below code (not suggested) |
| 33 |
# remember to remove hashes from the beginning of the lines |
| 34 |
# |
| 35 |
# [du] |
| 36 |
# user root |
| 37 |
# |
| 38 |
# - 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) |
| 39 |
# du -sm $DIR in MB |
| 40 |
# du -sk $DIR in KB |
| 41 |
# |
| 42 |
################################################################# |
| 43 |
# |
| 44 |
# Changelog |
| 45 |
# |
| 46 |
# Revision 0.1 Tue 03 Feb 2009 02:16:02 PM CET _KaszpiR_ |
| 47 |
# - initial release, |
| 48 |
# |
| 49 |
################################################################# |
| 50 |
# Magick markers (optional - used by munin-config and som installation |
| 51 |
# scripts): |
| 52 |
#%# family=auto |
| 53 |
#%# capabilities=autoconf |
| 54 |
|
| 55 |
################################################################# |
| 56 |
################################################################# |
| 57 |
|
| 58 |
if [ "$1" = "autoconf" ]; then |
| 59 |
if [ -d $DIR ]; then |
| 60 |
echo "yes" |
| 61 |
exit 0 |
| 62 |
else |
| 63 |
echo "no (check your path)" |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
fi |
| 67 |
|
| 68 |
if [ "$1" = "config" ]; then |
| 69 |
|
| 70 |
echo "graph_title Directory size: $DIR" |
| 71 |
echo "graph_vlabel size MB" |
| 72 |
echo "graph_category disk" |
| 73 |
echo "graph_info Size of $DIR" |
| 74 |
echo "dir$ID.label size" |
| 75 |
echo "dir$ID.min 0" |
| 76 |
echo "dir$ID.info Shows du -sm for specified directory" |
| 77 |
|
| 78 |
exit 0 |
| 79 |
fi |
| 80 |
|
| 81 |
echo -n "dir$ID.value " |
| 82 |
if [ -d $DIR ]; then |
| 83 |
SIZE=`du -sm $DIR | cut -f1` |
| 84 |
echo $SIZE |
| 85 |
exit 0 |
| 86 |
else |
| 87 |
echo "U" |
| 88 |
exit 1 |
| 89 |
fi |
