Create OpenVZ OS Template

  1. Login to OpenVZ(Hardware Node).
  2. Start the VM for the template creation.(replace 105 with your container ID)
    vzctl start 105
  3. Remove the IP from the VM.
    sudo vzctl set 105 --ipdel all --save
  4. Stop the container.
    vzctl stop 105
  5. Create template
    cd /vz/private/105/
    tar -czf /vz/template/cache/<OS>-<ARCH>.tar.gz ./
  6. Create the configuration file.
    cp /etc/vz/dists/centos.conf /etc/vz/dists/template-name.conf

Swatch : Simple Log Watcher to monitor Asterisk PRI status

This will monitor the asterisk log file and check for some pattern and restart the asterisk & dahdi service. ( can be used as a work around till you find the real problem).

  • Install swatch

# yum install swatch
  • Create file daemon script


# Simple Log Watcher Program

case "$1" in
 /usr/bin/swatch --daemon --config-file=/etc/swatch.conf --tail-file=/var/log/asterisk/full --pid-file=/var/run/
 PID=`cat /var/run/`
 kill $PID
 echo "Usage: $0 { start | stop }"
exit 0

  • Make it executable and enable autostart.

# sudo chmod 755 /etc/init.d/swatch
# sudo ln -s /etc/init.d/swatch /etc/rc2.d/S99swatch
# sudo ln -s /etc/init.d/swatch /etc/rc3.d/S99swatch
# sudo ln -s /etc/init.d/swatch /etc/rc5.d/S99swatch
  • Create swatch config and commands.

vi /etc/swatch.conf

watchfor /Span 1: D-channel is down!|Primary D-Channel on span 1 down/
# echo
 write root
 mail addresses=user1\\, subject=PRI down. Trying to restart.


  • Add commands in  script and make it executable.

vi /usr/bin/

sudo asterisk -rx "logger rotate"
sleep 3
sudo /etc/init.d/asterisk stop
sleep 3
sudo /etc/init.d/dahdi restart
sleep 3
sudo /etc/init.d/asterisk start
sleep 2

# chmod 755 /usr/bin/