Hi,
there is a bug in AIX agent runing plugins asychron. The code is wrong in function run_cached at the following line:
function run_cached {
NAME=$1
# Be aware: Maxage was expected to be given in minutes but this was
# confusing because all other agents use seconds here. So this has
# been changed to be compatible.
MAXAGE=$2
shift 2
CMDLINE=$*
if [ ! -e $MK_VARDIR/cache ] ; then mkdir -p $MK_VARDIR/cache ; fi
CACHEFILE=$MK_VARDIR/cache/$NAME.cache
USE_CACHEFILE=""
# Check if file exists and is recent enough
if [ -s $CACHEFILE ]
then
MTIME=$(/usr/bin/perl -e 'if (! -f $ARGV[0]){die "0000000"};$mtime=(stat($ARGV[0]))[9];print ($^T-$mtime);' $CACHEFILE )
if (( $MTIME < $MAXAGE )) ; then
USE_CACHEFILE=1
fi
CACHE_INFO="cached($MTIME,$MAXAGE)"
if [[ $NAME == local_* ]]; then
sed -e "s/^/$CACHE_INFO /" "$CACHEFILE"
else
# insert the cache info in the section header (^= after '!'),
# if none is present (^= before '!')
sed -e '/^<<<.*\(:cached(\).*>>>/!s/^<<<\([^>]*\)>>>$/<<<\1:'$CACHE_INFO'>>>/' "$CACHEFILE"
fi
fi
if [ -z "$USE_CACHEFILE" -a ! -e "$CACHEFILE.new" ]
then
nohup sh -c $CMDLINE > $CACHEFILE.new 2> /dev/null && mv $CACHEFILE.new $CACHEFILE &
fi
}
The code can fixed (see following code lines):
function run_cached {
NAME=$1
# Be aware: Maxage was expected to be given in minutes but this was
# confusing because all other agents use seconds here. So this has
# been changed to be compatible.
MAXAGE=$2
shift 2
CMDLINE=$*
if [ ! -e $MK_VARDIR/cache ] ; then mkdir -p $MK_VARDIR/cache ; fi
CACHEFILE=$MK_VARDIR/cache/$NAME.cache
USE_CACHEFILE=""
# Check if file exists and is recent enough
if [ -s $CACHEFILE ]
then
MTIME=$(/usr/bin/perl -e 'if (! -f $ARGV[0]){die "0000000"};$mtime=(stat($ARGV[0]))[9];print ($^T-$mtime);' $CACHEFILE )
if (( $MTIME < $MAXAGE )) ; then
USE_CACHEFILE=1
fi
FTIME=$(perl -le 'print((stat shift)[9])' $CACHEFILE)
CACHE_INFO="cached($FTIME,$MAXAGE)"
if [[ $NAME == local_* ]]; then
sed -e "s/^/$CACHE_INFO /" "$CACHEFILE"
else
# insert the cache info in the section header (^= after '!'),
# if none is present (^= before '!')
sed -e '/^<<<.*\(:cached(\).*>>>/!s/^<<<\([^>]*\)>>>$/<<<\1:'$CACHE_INFO'>>>/' "$CACHEFILE"
fi
fi
if [ -z "$USE_CACHEFILE" -a ! -e "$CACHEFILE.new" ]
then
nohup sh -c $CMDLINE > $CACHEFILE.new 2> /dev/null && mv $CACHEFILE.new $CACHEFILE &
fi
}
Regards,
Christian