I've noticed the past few days my cache size drops randomly very low, and after restarting server goes back to normal level...
Since i haven't found any decent answer on why is it happening, i've made a simple script to restart server (CSP instance) if cache level drops below desired level...at least until i find out why is this happening...

Here's the scirpt (using PHP code only for color-coding):


PHP Code:
#!/bin/bash

LOG="/usr/local/csp/log"
REQUESTED_CACHE="75"
DATE=`date +%d-%m-%Y`
TIME=`date +"%T"`
USER="username"
PASS="password"
PORT="8082"

curl --user $USER:$PASS --url http://localhost:$PORT/xmlHandler?command=cache-status >> /dev/null 2>&1 > $LOG/tmp1.log

grep -'<cache-param name="pending-ecms"' $LOG/tmp1.log $LOG/tmp2.log

sed 
's|[(<"=>)]| |g' $LOG/tmp2.log $LOG/tmp3.log

value
=$(grep 'value' $LOG/tmp3.log awk -'value=*  ' '{print $2}' awk -" " '{print $1}')

peak=$(grep 'value' $LOG/tmp3.log awk -'value=*  ' '{print $2}' awk -" " '{print $3}')

percent=`awk 'BEGIN{printf("%0.2f", '$value' / '$peak' * 100)}'`

if (( ${
percent%%.*} <= ${REQUESTED_CACHE%%.*} ))

    
then
        
echo "$DATE $TIME - CACHE level LOW ($percent%), restarting server." >> $LOG/cache_monitor.log
        csp stop
        sleep 1
        csp start 
&
    else
        echo 
"CACHE OK, now at $percent%"
fi

rm 
-rf $LOG/tmp1.log
rm 
-rf $LOG/tmp2.log
rm 
-rf $LOG/tmp3.log

exit 
What is the script doing?
It monitors cache status on "pending-ecms" part; i have noticed that when my cache drops very low, pending ecms drop to almost 0, while peak remains the same as it was when cache worked normally...
That's why the script calculates percentage between pending ecms and peak, and if percentage is below the desired level, it restarts the server and notifies your logfile of it's action, so you can keep track on how many times it happened, otherwise only displays the current cache percentage...
My desired cache level (REQUESTED_CACHE) started at 80%, then server got restarted at least 3-4 times a day, now i decreased it to 75% and it seems ok like this, you can change it according to your cache level...

Try it, suggest changes...use it, or don't.