check_mk_extensions icon indicating copy to clipboard operation
check_mk_extensions copied to clipboard

Check interval for dir_size

Open roland-gsell opened this issue 3 years ago • 2 comments

Hi, it would be great to have a check interval available to set in WATO for the dir_size check, since this can take up quite some time in many cases. Manually moving it to a subfolder (e.g. 600) will not solve the issue, since the bakery will put it in the main plugin folder eventually, messing up the monitoring for the whole host. Thanks for reading, Roland.

roland-gsell avatar Dec 30 '21 12:12 roland-gsell

@gurubert Hi Robert. Kannste hier mal schauen? :-)

doctore74 avatar Apr 05 '22 14:04 doctore74

i rebuild the check to this, and make my own interval

#!/bin/bash

CONTENTFILE="/tmp/dir_size_checkmk.out"
TMPCONTENTFILE="/tmp/dir_size_checkmk.out.tmp"
function createoutput() {
        (
                if [ -e "$MK_CONFDIR/dir_size.cfg" ]; then
                        touch $TMPCONTENTFILE
                        echo '<<<dir_size>>>' >$TMPCONTENTFILE
                        grep -v "^#" $MK_CONFDIR/dir_size.cfg |
                                while read -r path; do
                                        if [[ $path == */ ]]; then
                                                if [ -d "$path" ]; then
                                                        find "$path" -mindepth 1 -maxdepth 1 -type d -exec nice ionice -c2 -n7 du -s {} \; >>$TMPCONTENTFILE
                                                fi
                                        else
                                                if [ -d "$path" ]; then
                                                        nice ionice -c2 -n7 du -s "$path" >>$TMPCONTENTFILE
                                                fi
                                        fi
                                done
                        cp $TMPCONTENTFILE $CONTENTFILE
                fi
        ) &
}

if [[ ! -f "$TMPCONTENTFILE" ]]; then
        createoutput
elif [[ $(find "$CONTENTFILE" -mtime +1 -print 2>/dev/null) ]]; then
        createoutput
fi

# Output
if [[ -f "$CONTENTFILE" ]]; then
        CONTENT="$(cat $CONTENTFILE)"
        if [[ $(echo "$CONTENT" | wc -l) -gt 0 ]]; then
                cat "$CONTENTFILE" 
        fi
fi

in dir_size.cfg

if path ends with "/" so this will include subdirs, without only the spec path also recheck only 1 per day

but yes check Interval per service would be nice

Delido avatar Jun 11 '22 15:06 Delido

please test dir_size-5.2.0.mkp

gurubert avatar Mar 30 '23 12:03 gurubert

Hi @gurubert ,

funktioniert gut.

doctore74 avatar Apr 27 '23 12:04 doctore74