Skip to content

Commit faa96e6

Browse files
authored
Merge pull request #328 from ZLLentz/mnt_sdfconfig
MNT: remove references to netconfig from engineering_tools
2 parents 406dccb + 0f4a27e commit faa96e6

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

scripts/restartdaq

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,21 @@ cd /reg/g/pcds/dist/pds/"$HUTCH"/scripts/ || exit
8888
DAQNETWORK='fez'
8989
PROCMGR="/reg/g/pcds/dist/pds/$HUTCH/current/tools/procmgr/procmgr"
9090

91-
if [ "$IS_DAQ_HOST" == 0 ]; then
92-
HOSTS=$(netconfig search "$HUTCH"-*-$DAQNETWORK --brief | sed s/-$DAQNETWORK//g)
93-
WORKINGHOSTS=''
94-
#make sure at least cds is up.
91+
if [ "${IS_DAQ_HOST}" == 0 ]; then
92+
HOSTS="$(sdfconfig search --brief --type subnet PCDSN-"${DAQNETWORK^^}"-"${HUTCH^^}")"
93+
WORKINGHOSTS=""
9594
for HOST in $HOSTS; do
96-
if [[ $(ping -w 2 "$HOST" >/dev/null 2>&1) == 0 ]]; then
97-
WORKINGHOSTS=$WORKINGHOSTS' '$HOST
98-
fi
95+
# Only consider hosts that start with hutch-, e.g. xpp-control, xcs-daq
96+
if [[ "${HOST}" == "${HUTCH}"-* ]]; then
97+
# Make sure cds intf is up via ping
98+
# Remove trailing .pcdsn to switch from fqdn to hostname
99+
if ping -w 2 "${HOST%.pcdsn}" &> /dev/null; then
100+
WORKINGHOSTS="${WORKINGHOSTS} ${HOST%.pcdsn}"
101+
fi
102+
fi
99103
done
100-
echo "$AIMHOST" does not have "$DAQNETWORK", please choose one of the following machines to run the DAQ: "$WORKINGHOSTS"
101-
echo "restartdaq -m <machine_with_$DAQNETWORK>"
104+
echo "${AIMHOST} does not have ${DAQNETWORK}, please choose one of the following machines to run the DAQ:${WORKINGHOSTS}"
105+
echo "restartdaq -m <machine_with_${DAQNETWORK}>"
102106
exit
103107
fi
104108

scripts/serverStat

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ names_from_name(){
1313
INNAME=${INNAME//-ana/}
1414
fi
1515
CDSNAME=$INNAME
16-
CDSIP=$(netconfig search "$CDSNAME" | grep IP: | awk '{print $2}')
17-
if [[ -z $CDSIP ]]; then
18-
echo "Host ($CDSNAME) not found in netconfig, exiting..." >&2
16+
if ! host "$CDSNAME" &> /dev/null; then
17+
echo "Host ($CDSNAME) not found in DNS, exiting..." >&2
1918
exit 1
2019
fi
21-
if [[ $(netconfig search "$NAME"-ipmi --brief | wc -w) -gt 0 ]]; then
20+
CDSIP=$(host "$CDSNAME" | awk '{print $4}')
21+
if host "$NAME"-ipmi &> /dev/null; then
2222
NAMEIPMI=$INNAME-ipmi
2323
fi
24-
if [[ $(netconfig search "$NAME"-fez --brief | wc -w) -gt 0 ]]; then
24+
if host "$NAME"-fez &> /dev/null; then
2525
FEZNAME=$INNAME-fez
26-
FEZIP=$(netconfig search "$FEZNAME" | grep IP: | awk '{print $2}')
26+
FEZIP=$(host "$FEZNAME" | awk '{print $4}')
2727
fi
2828
}
2929

@@ -77,9 +77,11 @@ for name in "tmo" "rix" "txi" "xpp" "xcs" "mfx" "cxi" "mec" "det"; do
7777
fi
7878
done
7979

80-
81-
HOST_HAS_FEZ=$(netconfig search "$HOSTNAME"-fez --brief | wc -l)
82-
80+
if host "$HOSTNAME"-fez &> /dev/null; then
81+
HOST_HAS_FEZ=1
82+
else
83+
HOST_HAS_FEZ=0
84+
fi
8385

8486
if [[ $# -lt 2 ]]; then
8587
if [[ $# -lt 1 ]]; then
@@ -110,10 +112,10 @@ fi
110112

111113
if [[ $NAME == *'172.21'* ]]; then
112114
ISSRV=1
113-
NAME=$(netconfig search "$NAME" --brief | awk '{print $1}')
115+
NAME=$(host "$NAME" | awk '{print $5}' | cut -d "." -f 1)
114116
echo "$DEV is an IP for $NAME"
115117
else
116-
ISSRV=$(netconfig search "$NAME" | grep 'Found' | awk '{print $2}')
118+
host "$NAME" &> /dev/null && ISSRV=1 || ISSRV=0
117119
fi
118120

119121
if [[ $NAME == *'-ipmi'* ]]; then
@@ -182,17 +184,17 @@ if [[ $ISSRV -lt 1 ]] && [[ $HUTCH != 'unknown_hutch' ]]; then
182184
fi
183185
fi
184186
if [[ $NAME ]]; then
185-
ISSRV=$(netconfig search "$NAME" | grep 'Found' | awk '{print $2}')
187+
host "$NAME" &> /dev/null
188+
ISSRV=$?
186189
fi
187190
if [[ $ISSRV -lt 1 ]]; then
188-
echo "Host ($NAME) not found in netconfig, exiting..." >&2
191+
echo "Host ($NAME) not found in DNS, exiting..." >&2
189192
exit 1
190193
fi
191-
192-
SRVIP=$(netconfig search "$NAME" | grep IP: | awk '{print $2}')
194+
SRVIP="$(host "$NAME" | awk '{print $4}')"
193195
echo "server for $DEV is: $NAME"
194196
else
195-
SRVIP=$(netconfig search "$DEV" | grep IP: | awk '{print $2}')
197+
SRVIP="$(host "$DEV" | awk '{print $4}')"
196198
fi
197199

198200

@@ -210,9 +212,9 @@ elif [[ $CMD == "console" ]]; then
210212
elif [[ $CMD == "reset" ]]; then
211213
psipmi "$NAMEIPMI" power reset
212214
elif [[ $CMD == "expert" ]]; then
213-
echo "Host netconfig entry:"
215+
echo "Host sdfconfig entry:"
214216
echo -e "-------------------------------------------------"
215-
netconfig view "$NAME"
217+
sdfconfig view "$NAME".pcdsn
216218
echo -e ""
217219
echo -e "Checking IPMI power status:"
218220
echo -e "-------------------------------------------------"
@@ -232,7 +234,7 @@ elif [[ $CMD == "expert" ]]; then
232234
else
233235
echo "$NAME-ipmi does not ping."
234236
fi
235-
if [[ $(netconfig search "$NAME"-fez --brief | wc -w) -gt 0 ]]; then
237+
if host "$NAME"-fez &> /dev/null; then
236238
if ping -w 2 "$NAME"-fez >/dev/null 2>&1; then
237239
echo "$NAME-fez pings."
238240
else

0 commit comments

Comments
 (0)