parsed.org

Tips by tag: swap

Simple swap monitor by mandric on Sep 25, 2007 06:32 PM

This is a simple swap monitor script:

#!/bin/bash
# Notify me one time if my swap is over MAXSWAP and log the
# swap usage as well in SWAPLOG.
# Usage: ./monitor.sh &

SWAPLOG=~/logs/monitor/swap
MAXSWAP=5
INTERVAL=30

send_sms_msg () {
  if [ "$1" ]; then STRING=$1; fi
  if [ $SMS_SENT ]; then
    return 0
  else
    echo $STRING | mailx -s 'monitor msg' 5101234567@cingularme.com
    SMS_SENT=1
  fi
}

while true; do
    # parse free output, get current swap value
    swaptest=`free -m |grep Swap|perl -pe 's/Swap:\s+\S+\s+(\S+).*/$1/'`
    if [ $swaptest -ge $MAXSWAP ]; then
        echo `date` Swap is: $swaptest >> $SWAPLOG
        send_sms_msg "Swap is: $swaptest"
    fi;
    sleep $INTERVAL
done;
bashmemorymonitorscriptshellswaptools
Vim Uppercase by http://xinu.myopenid.com/ on Jan 22, 2008 09:06 AM

To take a series of lines, say from the cursor to the bottom of the file and make them uppercase, the following would be useful:

%,$s/\(.*\)/\U\1/
regexswapuppercasevivim
RSS