[PVE-User] KSM not working?

Fred Supinski fred at vmu.ca
Wed Dec 30 09:38:56 CET 2009


I've also un-nested the if statement.  Complete init script:

#!/bin/bash
#
# ksmtuned     Kernel Samepage Merging (KSM) Tuning Daemon
#
# Author:      Dan Kenigsberg <danken at redhat.com>
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# chkconfig: 345 85 15
# description: The KSM tuning daemon controls whether (and with what
vigor) \
#              ksm should ksm search duplicated pages.
# processname: ksmtuned
# config: /etc/ksmtuned.conf
# pidfile: /var/run/ksmtuned.pid
#
### BEGIN INIT INFO
# Provides: ksmtuned
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tune the speed of ksm
# Description: The Kernel Samepage Merging control Daemon is a simple script
#   that controls whether (and with what vigor) should ksm search duplicated
#   memory pages.
#   needs testing and ironing. contact danken at redhat.com if something
breaks.
### END INIT INFO

. /lib/lsb/init-functions

PATH=/sbin:/bin:/usr/sbin:/usr/bin

prog=ksmtuned
ksmtuned=/usr/sbin/ksmtuned
DESC="KSM control daemon"

pidfile=${PIDFILE-/var/run/ksmtune.pid}
RETVAL=0

test -x $ksmtuned || exit 0

#Include defaults if available
if [ -f /etc/defaults/$prog ] ; then
        . /etc/defaults/$prog
fi

if [ "$START" != "yes" ]; then
        exit 0
fi

start() {

    [ -d /sys/kernel/mm/ksm/ ] || exit 0;

    log_daemon_msg "Starting $DESC" $prog
    pid=$( pidofproc -p ${pidfile} $ksmtuned )
    if [ -n "$pid" ] ; then
        log_begin_msg "Already running."
        log_end_msg 0
        exit 0
    fi

    start-stop-daemon --start --quiet --pidfile=${pidfile} --exec $ksmtuned
    RETVAL=$?
    log_end_msg $RETVAL
}

stop() {
    log_daemon_msg "Stopping $DESC" $prog
    start-stop-daemon --stop --quiet --pidfile ${pidfile}
    RETVAL=$?
    log_end_msg $RETVAL
}

restart() {
    stop
    start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        pidofproc -p ${pidfile} $ksmtuned >/dev/null
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
                log_success_msg "$DESC is running."
        else
                log_failure_msg "$DESC is not running."
        fi
        ;;
  restart)
        restart
        ;;
  force-reload)
        restart
        ;;
  reload)
        kill -SIGUSR1 `cat ${pidfile}`
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog
{start|stop|restart|force-restart|status|reload}"
        RETVAL=3
esac

exit $RETVAL



-------- Original Message  --------
Subject: Re: [PVE-User] KSM not working?
From: Fred Supinski <fred at vmu.ca>
To: pve-user at pve.proxmox.com
Date: Wed Dec 30 2009 03:21:16 GMT-0500 (Eastern Standard Time)
> The path is hard coded wrong also.
>
> /etc/default/$prog needs to be changed to /etc/defaults/$prog
>
> I think that pretty much covers off the init script.
>
> -Fred
>
> -------- Original Message  --------
> Subject: Re: [PVE-User] KSM not working?
> From: Dietmar Maurer <dietmar at proxmox.com>
> To: Fred Supinski <fred at vmu.ca>, pve-user at pve.proxmox.com
> <pve-user at pve.proxmox.com>
> Date: Wed Dec 30 2009 02:57:54 GMT-0500 (Eastern Standard Time)
>> The statement should then be nested in the if statement that is loading
>> that file, shouldn't it?
>>
>> #Include defaults if available
>> if [ -f /etc/default/$prog ] ; then
>>         . /etc/default/$prog
>>         if [ "$START" != "yes" ]; then
>>                 exit 0
>>         fi
>> fi
>>
>> -Fred
>>
>>
>> -------- Original Message  --------
>> Subject: Re: [PVE-User] KSM not working?
>> From: Dietmar Maurer <dietmar at proxmox.com>
>> To: Fred Supinski <fred at vmu.ca>, pve-user at pve.proxmox.com
>> <pve-user at pve.proxmox.com>
>> Date: Wed Dec 30 2009 02:57:54 GMT-0500 (Eastern Standard Time)
>>
>>   
>>>> I'm not sure about the if statement though.  Where is this variable being pulled from?
>>>>       
>>> from /etc/defaults/ksmtuned
>>>
>>> - Dietmar
>>>
>>>     
>> _______________________________________________
>> pve-user mailing list
>> pve-user at pve.proxmox.com
>> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user
>>   
>
>
> _______________________________________________
> pve-user mailing list
> pve-user at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-user/attachments/20091230/aa8957b7/attachment.htm>


More information about the pve-user mailing list