#!/bin/bash

THIS_SCRIPT="${0##*/}"

if [ "${JWM_DIR}"x != ""x ] ; then 
  [ -d "${JWM_DIR}"/collectl ] && cd "${JWM_DIR}"/collectl
elif [ -d $( dirname $0 )/../collectl ] ; then
  cd $( dirname $0 )/../collectl
fi

[ -x ./collectl.pl ] && COLLECTL="./collectl.pl"
[ -x ./collectl ] && COLLECTL="./collectl"

if [ "${COLLECTL}"x != ""x ] ; then

  case ${THIS_SCRIPT} in 
    collectl )
      "${COLLECTL}" $*
      ;;

    collectl_top )
      "${COLLECTL}" --top --export proctree $*
      ;;

    collectl_top_io )
      "${COLLECTL}" --top ioall --procopt ti --export proctree $*
      ;;
    * ) 
      echo "${THIS_SCRIPT} is an unknown script name"
      ;;
      
  esac      
else
  echo "Neither collect nor collectl found in the directory $PWD"
fi

