#!/bin/bash
# system_status startup script
# chkconfig: 345 70 30
# description: start or stop system_status script 
### BEGIN INIT INFO
# Provides: system_status
# Default-Start: 345
# Default-Stop:  0 1 2 6
# Short-Description: start or stop system_status script 
# Description: start or stop system_status script 
### END INIT INFO


case "$1" in
start)
    mypid=`pgrep -u root -f "log_system_status"`
    if [[ $mypid != "" ]]
    then
        echo "ERR: system_status is already running"
    else
        nohup bash /opt/Avaya/scripts/log_system_status.sh $2 $3 & &> /dev/null
    fi
    ;;
stop)
    pid=`pgrep -u root -f "log_system_status"`
    if [[ $pid != "" ]]
    then
        kill -9 $pid 
    fi
    ;;

status)
    mypid=`pgrep -u root -f "log_system_status"`
    if [[ $mypid != "" ]]
    then 
        echo "The script is RUNNING"
    else
        echo "The script is STOPPED"
    fi
    ;;
*)
    echo "usage: $0 (start|stop|status)"
;;
esac
