slab and sreclaimable used up most RAM

One of the server few days ago used up almost all available memory.

free -m shows the following:

             total       used       free     shared    buffers     cached
Mem:         31941      31112        828          1        169       1563
-/+ buffers/cache:      29379       2562
Swap:         1023          0       1023

After did some research, issuing the following commands prompted high memory usage on the slab and sreclaimable for the dentry kernel process:

slabtop
vmstat -m

To free up the memory, i used the following:

sync; echo 3 > /proc/sys/vm/drop_caches

and the result:

             total       used       free     shared    buffers     cached
Mem:         31941        971      30969          1          7        103
-/+ buffers/cache:        861      31080
Swap:         1023          0       1023

Will this permanently resolve the memory issue? i think it will not but will keep monitoring, suspected it was due to recent use of nixstats which caused this memory issue due to frequest SSL request (curl or libcurl).

Bash script to monitor website updates on specific words

#!/bin/bash
CTR=0

while true
do
    HOST="https://target-url-to-monitor.com"
    RESULT1="$(curl -s $HOST | grep 'your-specific-keywords')"
    if [[ ! -z ${RESULT1} ]]; then
        CTR=$[$CTR+1]
        break
    else
        sleep 900
    fi
done

if [[ $CTR -gt '0' ]]; then
    echo -e "$CTR matching results for your-specific-keywords" | mail -s "Your Email Subject" your@emailaddress.com
fi

Bash script to auto-update Dynamic DNS on FreeDNS

This bash script is especially useful when your router default dynamic dns function updates is not consistent and require reboot in order for it to update.

If you have a home machine that runs 24/7 connected to Internet, you can schedule a cronjob to execute this script on every 1 hour so your domain/subdomain always get updated with the latest dynamic IP.

#!/bin/bash

if test -f /root/freedns/freedns-last-ip.conf
then
	CacheIP=$(cat /root/freedns/freedns-last-ip.conf)
fi

CurreIP=$(wget http://freedns.afraid.org/dynamic/check.php -o /dev/null -O /dev/stdout | grep Detected | cut -d : -f 2 | cut -d '<' -f 1 | tr -d " ")

if [ "$CurreIP" = "$CacheIP" ]
then
	echo "Update not required..."
else
	echo "Updating http://free.afraid.org with " $CurreIP
	wget https://freedns.afraid.org/dynamic/update.php?insertyourapicode -o /dev/null -O /dev/stdout
	echo `date` "Updating log with IP " $CurreIP >> /root/freedns/freedns-upd.log
fi

rm -f /root/freedns/freedns-last-ip.conf
echo $CurreIP > /root/freedns/freedns-last-ip.conf