sdmem 863 Bytes
Newer Older
1 2 3 4 5 6 7 8
#!/bin/sh

PREREQ=""

prereqs() {
   echo "${PREREQ}"
}

9 10 11 12 13 14 15 16 17 18 19
tweak_sysctl() {
   echo 3   > /proc/sys/kernel/printk

   echo 3   > /proc/sys/vm/drop_caches
   echo 256 > /proc/sys/vm/min_free_kbytes

   echo 1   > /proc/sys/vm/overcommit_memory
   echo 1   > /proc/sys/vm/oom_kill_allocating_task
   echo 0   > /proc/sys/vm/oom_dump_tasks
}

20 21 22 23 24 25 26
case ${1} in
   prereqs)
      prereqs
      exit 0
      ;;
esac

27
if [ -n "${sdmem}" ] ; then
28
   tweak_sysctl
29 30
   if [ -z "${sdmemopts}" ] ; then
      sdmemopts="v"
31
   fi
32
   for i in $(seq 0 30) ; do /usr/bin/sdmem "-${sdmemopts}" & done
33 34
   # Wait for sdmem jobs to complete.
   wait
35
fi
36

37
if [ "${sdmemdebug}" = 1 ] ; then
38
   clear
39 40 41 42
   echo "Going to sleep 10 minutes. Happy dumping!"
   sleep 600
fi

43 44 45 46 47 48 49 50 51 52
case "${sdmem}" in
   halt)
      /sbin/halt -fndp
      ;;
   reboot)
      /sbin/reboot -fnd
      ;;
   *)
      ;;
esac