From 13ff8ef1ccd6546b947c3d2cdeeeb15f6e74237a Mon Sep 17 00:00:00 2001 From: Silke Nelson Date: Wed, 5 May 2021 23:31:27 -0700 Subject: [PATCH] add script to check cnf file, make wheredaq simpler, restartdaq&stopdaq now tmo-compatible --- scripts/checkcnf | 32 ++++++++++++++++++++++++++++ scripts/restartdaq | 52 ++++++++++++++++++++-------------------------- scripts/stopdaq | 21 +++++++++++++++---- scripts/wheredaq | 40 +++++++++++++---------------------- 4 files changed, 86 insertions(+), 59 deletions(-) create mode 100755 scripts/checkcnf diff --git a/scripts/checkcnf b/scripts/checkcnf new file mode 100755 index 00000000..8cdd378f --- /dev/null +++ b/scripts/checkcnf @@ -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 diff --git a/scripts/restartdaq b/scripts/restartdaq index 0a4f21ee..761ef06a 100755 --- a/scripts/restartdaq +++ b/scripts/restartdaq @@ -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 @@ -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 @@ -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 "' + echo $AIMHOST does not have $DADQNETWORK, please choose one of the following machines to run the DAQ: $WORKINGHOSTS + echo '"restartdaq "' 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` @@ -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 @@ -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 diff --git a/scripts/stopdaq b/scripts/stopdaq index eea3067f..0c4afdcf 100755 --- a/scripts/stopdaq +++ b/scripts/stopdaq @@ -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))" diff --git a/scripts/wheredaq b/scripts/wheredaq index ca7a186a..a337141f 100755 --- a/scripts/wheredaq +++ b/scripts/wheredaq @@ -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 -