Skip to content

Commit

Permalink
add script to check cnf file, make wheredaq simpler, restartdaq&stopd…
Browse files Browse the repository at this point in the history
…aq now tmo-compatible
  • Loading branch information
silkenelson committed May 6, 2021
1 parent 7b037b3 commit 13ff8ef
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 59 deletions.
32 changes: 32 additions & 0 deletions scripts/checkcnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
usage()
{
cat << EOF
usage: $0
Discover what host is running the daq in the current hutch, if any.
EOF
}

if [[ ($1 == "--help") || ($1 == "-h") ]]; then
usage
exit 0
fi

HUTCH=`get_info --gethutch`
NOTRUNNING='Not running'

if [[ ($HUTCH == 'tmo') || ($HUTCH == 'rix') ]]; then
source /reg/g/pcds/dist/pds/$HUTCH/scripts/setup_env.sh
PROCMGR='procmgr'
else
PROCMGR='/reg/g/pcds/dist/pds/current/tools/procmgr/procmgr'
fi

STATUS=`$PROCMGR status /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH.cnf control_gui`
ISOK=`echo $STATUS | grep platform | wc -l`
if [[ $ISOK == 0 ]]; then
echo The cnf file for $HUTCH can be parsed
else
echo WARNING: the cnf file for $HUTCH cannot parsed!
fi
52 changes: 23 additions & 29 deletions scripts/restartdaq
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ if [[ `whoami` != *'opr'* ]]; then
exit
fi

#clean the enviroment before sourcing any conda env.
unset PYTHONPATH
unset LD_LIBRARY_PATH

CNFEXT=.cnf
if [[ $AIMHOST == 'cxi-daq' ]]; then
CNFEXT=_0.cnf
Expand All @@ -59,27 +63,23 @@ elif [[ $AIMHOST == 'cxi-monitor' ]]; then
fi

HUTCH=`get_hutch_name`
if [[ $HUTCH == 'xpp' ]]; then
FEZ='172.21.22'
elif [[ $HUTCH == 'xcs' ]]; then
FEZ='172.21.25'
elif [[ $HUTCH == 'sxr' ]]; then
FEZ='172.21.21'
elif [[ $HUTCH == 'mec' ]]; then
FEZ='172.21.27'
elif [[ $HUTCH == 'mfx' ]]; then
FEZ='172.21.24'
elif [[ $HUTCH == 'cxi' ]]; then
FEZ='172.21.26'
elif [[ $HUTCH == 'amo' ]]; then
FEZ='172.21.20'
elif [[ $HUTCH == 'det' ]]; then
FEZ='172.21.59'
HNAME=`cat /etc/hostname`

#go to hutches DAQ scripts directory (puts pid file in consistent location)
cd /reg/g/pcds/dist/pds/$HUTCH/scripts/

DAQNETWORK='fez'
if [[ ($HUTCH == 'tmo') || ($HUTCH == 'rix') ]]; then
source /reg/g/pcds/dist/pds/$HUTCH/scripts/setup_env.sh
PROCMGR='procmgr'
DAQNETWORK='drp'
else
PROCMGR='/reg/g/pcds/dist/pds/tools/procmgr/procmgr'
fi
IS_DAQ_HOST=`/sbin/ifconfig | grep inet | grep $FEZ | wc -l`

IS_DAQ_HOST=`netconfig search $HNAME-$DAQNETWORK --brief | grep $DAQNETWORK | wc -l`
if [ $IS_DAQ_HOST == 0 ]; then
HOSTS=`netconfig search $HUTCH-*-fez --brief | sed s/-fez//g`
HOSTS=`netconfig search $HUTCH-*-$DAQNETWORK --brief | sed s/-$DAQNETWORK//g`
WORKINGHOSTS=''
#make sure at least cds is up.
for HOST in $HOSTS; do
Expand All @@ -88,20 +88,16 @@ if [ $IS_DAQ_HOST == 0 ]; then
WORKINGHOSTS=$WORKINGHOSTS' '$HOST
fi
done
echo $AIMHOST does not have FEZ, please choose one of the following machines to run the DAQ: $WORKINGHOSTS
echo '"restartdaq <machine_with_FEZ>"'
echo $AIMHOST does not have $DADQNETWORK, please choose one of the following machines to run the DAQ: $WORKINGHOSTS
echo '"restartdaq <machine_with_$DAQNETWORK>"'
exit
fi

#go to hutches DAQ scripts directory (puts pid file in consistent location)
cd /reg/g/pcds/dist/pds/$HUTCH/scripts/

#/reg/g/xpp/scripts/stopdaq
DAQHOST=`wheredaq`
if [[ $DAQHOST != *$NOTRUNNING* ]]; then
echo stop the DAQ on $DAQHOST from $HOSTNAME
T="$(date +%s%N)"
/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr stop \
$PROCMGR stop \
/reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT

PLATFORM=`grep 'if not platform' /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT | awk '{print $NF}' | sed s/\'//g`
Expand All @@ -118,7 +114,7 @@ else
if [ -f /reg/g/pcds/dist/pds/$HUTCH/scripts/p$PLATFORM$CNFEXT.running ]; then
echo while DAQ reports to not run, will stop the DAQ on $DAQHOST from $HOSTNAME to clear the p$PLATFORM$CNFEXT.running file
T="$(date +%s%N)"
/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr stop \
$PROCMGR stop \
/reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT

if [ -f /reg/g/pcds/dist/pds/$HUTCH/scripts/p$PLATFORM$CNFEXT.running ]; then
Expand All @@ -136,9 +132,7 @@ fi
T="$(date +%s%N)"
echo start DAQ on $AIMHOST
if [ $HOSTNAME == $AIMHOST ]; then
unset PYTHONPATH
unset LD_LIBRARY_PATH
/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr start \
$PROCMGR start \
/reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT -c 2000000000 -o /reg/g/pcds/pds/$HUTCH/logfiles
else
ssh -Y $AIMHOST restartdaq
Expand Down
21 changes: 17 additions & 4 deletions scripts/stopdaq
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,29 @@ elif [ $HOSTNAME == 'cxi-monitor' ]; then
CNFEXT=_1.cnf
fi

#clean the enviroment before sourcing any conda env.
unset PYTHONPATH
unset LD_LIBRARY_PATH

#go to hutches DAQ scripts directory
#(puts pid file in consistent location - necessary for stopping for LCLS-II DAQ)
cd /reg/g/pcds/dist/pds/$HUTCH/scripts/

if [[ ($HUTCH == 'tmo') || ($HUTCH == 'rix') ]]; then
source /reg/g/pcds/dist/pds/$HUTCH/scripts/setup_env.sh
PROCMGR='procmgr'
else
PROCMGR='/reg/g/pcds/dist/pds/tools/procmgr/procmgr'
fi

if [[ $DAQHOST != 'DAQ is not running' ]]; then
T="$(date +%s%N)"
echo stop the DAQ from $HOSTNAME
/reg/g/pcds/dist/pds/tools/procmgr/procmgr stop \
/reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT
#source /reg/g/pcds/dist/pds/$HUTCH\/scripts/stop_$HUTCH\_daq.csh
$PROCMGR stop /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT

PLATFORM=`grep 'if not platform' /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH$CNFEXT | awk '{print $NF}' | sed s/\'//g`
if [ -f /reg/g/pcds/dist/pds/$HUTCH/scripts/p$PLATFORM$CNFEXT.running ]; then
echo 'the DAQ did not stop properly, exit now and try again or call Silke or the DAQ phone'
echo 'the DAQ did not stop properly, exit now and try again or call your POC or the DAQ phone'
exit
fi
T2="$(($(date +%s%N)-T))"
Expand Down
40 changes: 14 additions & 26 deletions scripts/wheredaq
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,23 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then
fi

HUTCH=`get_info --gethutch`
NOTRUNNING='Not running'
CNFEXT=.cnf
PLATFORM=0
if [ $HOSTNAME == 'cxi-monitor' ]; then
PLATFORM=1
elif [ $HUTCH == 'rix' ]; then
PLATFORM=2
fi

if [ $HUTCH == 'cxi' ]; then
if [[ ! -f /reg/g/pcds/dist/pds/$HUTCH/scripts/p$PLATFORM.cnf.running ]]; then
if [ $HOSTNAME == 'cxi-daq' ]; then
STATUS=`/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr status /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH\_0.cnf control_gui | grep started`
if [[ $STATUS == *$NOTRUNNING* ]]; then
echo 'cxi_0 - ' $STATUS
else
echo 'cxi_0 - Main DAQ is running on '$HOSTNAME
fi
echo 'Main DAQ cxi_0 is not running on $HOSTNAME '
elif [ $HOSTNAME == 'cxi-monitor' ]; then
STATUS=`/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr status /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH\_1.cnf | grep started`
if [[ $STATUS == *$NOTRUNNING* ]]; then
echo 'cxi_1 - Secondary DAQ is not running'
else
echo 'cxi_1 - Secondary DAQ is running on '$HOSTNAME
fi
else
echo 'This machine ('$HOSTNAME') is not a cxi DAQ host'
echo 'Secondary DAQ cxi_1 is not running on $HOSTNAME '
else
echo 'DAQ is not running in '$HUTCH
fi
exit
fi

STATUS=`/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr status /reg/g/pcds/dist/pds/$HUTCH/scripts/$HUTCH.cnf control_gui | grep started`
if [[ $STATUS == *$NOTRUNNING* ]]; then
echo 'DAQ in ' ${HUTCH^^}': ' $STATUS
exit
else
HOST=`echo $STATUS | awk {'print $5'}`
echo $HOST
DAQ_HOST=`grep HOST /reg/g/pcds/dist/pds/$HUTCH/scripts/p$PLATFORM.cnf.running | awk {'print $3'} | sed s/\'//g`
echo 'DAQ is running on '$DAQ_HOST
fi

0 comments on commit 13ff8ef

Please sign in to comment.