diff --git a/plugins/apache/apache_cache_disk_count b/plugins/apache/apache_cache_disk_count new file mode 100755 index 00000000..e3f1c807 --- /dev/null +++ b/plugins/apache/apache_cache_disk_count @@ -0,0 +1,123 @@ +#!/bin/bash + +: << =cut + +=head1 NAME + +Munin plugin to monitor apache mod_cache_disk usage. + +=head1 CONFIGURATION + +[apache_cache_disk_count] + user www-data + env.cache_path /var/cache/apache2/mod_cache_disk + env.strings css js + env.label_cs CSS + env.colour_css FFFF00 + env.label_js JS + env.colour_js FF0000 + +=head1 AUTHOR + +Raphaƫl Droz + +=head1 LICENSE + +GPLv2 + +=head1 MAGICK MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +. $MUNIN_LIBDIR/plugins/plugin.sh + +my_cache_path="${cache_path:-/var/cache/apache2/mod_cache_disk}" +declare -a fieldnames labels colours + +getenvdata() { + let during_autoconf=0 + [[ $1 == -v ]] && during_autoconf=1 + arg=( "${strings:-}" ) + for i in ${arg[*]}; do + if [[ ! $i =~ ^[a-zA-Z0-9]+$ ]]; then + (( $during_autoconf )) && echo "no ($i isn't a valid fixed-string)" + ok=0 + continue + fi + label=label_$i + if [[ -z "${!label}" ]]; then + (( $during_autoconf )) && echo "no ($i isn't given a label)" + ok=0 + continue + fi + colour=colour_$i + if [[ -z "${!colour}" ]]; then + (( $during_autoconf )) && echo "no ($i isn't given a colour)" + ok=0 + continue + fi + + fieldnames+=($i) + labels+=("${!label}") + colours+=("${!colour}") + done +} + +if [[ $1 == autoconf ]]; then + let ok=1 + + [[ -z $strings ]] && echo "no strings to monitor defined" && ok=0 + ! type -P htcacheclean &>/dev/null && echo "can't find htcacheclean" && ok=0 + ! test -d "$my_cache_path" && echo "cache_path \"$cache_path\" is not readable" && ok=0 + + getenvdata -v + + (( ${#fieldnames[*]} == 0 )) && echo "no (no valid strings)" && ok=0 + (( $ok == 1 )) && echo yes + exit 0 +fi + +getenvdata + +if [[ $1 == config ]]; then +cat <