pika_control.sh 1.53 KB
Newer Older
fwinkler's avatar
fwinkler committed
1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash

source /sw/taurus/tools/pika/pika-current.conf
DEBUG_PATH=/tmp/pika_control.out


function pika_clean() {
  rm -rf /tmp/pika_*
  rm -rf /opt/pika/*
}

12 13 14 15 16 17 18 19 20 21 22
function pika_status() {
  COLLECTD_PID=`ps -eo pid,cmd | grep -v grep | grep "pika_collectd" | awk '{print $1}'`

  # check if COLLECTD_PID is empty
  if [ -z "$COLLECTD_PID" ]; then
    echo "PIKA collectd is not running."
  else
    echo "PIKA collectd is running. PID=$COLLECTD_PID"
  fi       
}

fwinkler's avatar
fwinkler committed
23 24 25 26 27 28 29
function pika_install() {
  mkdir -p ${PIKA_INSTALL_PATH}
  echo -e "tar xzf ${PIKA_PACKAGE_PATH} -C ${PIKA_INSTALL_PATH}/.."
  tar xzf ${PIKA_PACKAGE_PATH} -C ${PIKA_INSTALL_PATH}/..
}

function pika_start() {
30
  DAEMON="${PIKA_INSTALL_PATH}/collectd/${COLLECTD_VERSION}/sbin/collectd -C ${PIKA_COLLECTD_CONF} -P ${PIKA_COLLECTD_PID_FILE}"
fwinkler's avatar
fwinkler committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

  touch $DEBUG_PATH

  source ${PIKA_ROOT}/job_control/slurm/taurus/pika_start_collectd.sh
  
  cat $DEBUG_PATH
  rm -f $DEBUG_PATH
}

function pika_stop() {
  source ${PIKA_ROOT}/job_control/slurm/taurus/pika_stop_collectd.sh
}

if [ ! $# -eq 1 ]; then
  echo "One argument required!"
46
  echo "./pika_control [status|purge|install|start|stop]"
fwinkler's avatar
fwinkler committed
47 48
else
  case "$1" in
49 50 51
    status)
       pika_status
       ;;
fwinkler's avatar
fwinkler committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    purge)
      pika_stop
      pika_clean
      ;;
    install)
      pika_stop
      pika_clean
      pika_install
      ;;
    start)
      pika_stop
      if [ ! -d "${PIKA_INSTALL_PATH}" ]; then
        pika_install
      fi
      pika_start
      ;;
    stop)
      pika_stop
      ;;
    *)
      echo "$1 is not supported."
      ;;
  esac
75
fi