Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions core/sqf/sql/scripts/dcscheck
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

dcsznode=/$USER/dcs/master
jpscmd=$JAVA_HOME/bin/jps
JAVA=$JAVA_HOME/bin/java
jstatcmd=$JAVA_HOME/bin/jstat
jstackcmd=$JAVA_HOME/bin/jstack
cfg_mxo_cnt=0
act_mxo_cnt=0
down_mxo_cnt=0
Expand All @@ -30,7 +33,7 @@ cfg_dcsserver_cnt=0
actual_dcsserver_cnt=0
down_dcsserver_cnt=0
activeMaster=localhost

OPT_VALUE=$1
if [ -e $SQ_PDSH ]; then
L_PDSH="$SQ_PDSH $MY_NODES "
else
Expand Down Expand Up @@ -171,17 +174,58 @@ if ( [ $sq_stat == 0 ] || [ $sq_stat == 1 ] ); then
fi
echo
fi
echo -e "Process\t\tConfigured\tActual\t\tDown"
echo -e "---------\t----------\t------\t\t----"
echo -e "DcsMaster\t$cfg_dcsmaster_cnt\t\t$actual_dcsmaster_cnt\t\t$down_dcsmaster_cnt"
echo -e "DcsServer\t$cfg_dcsserver_cnt\t\t$actual_dcsserver_cnt\t\t$down_dcsserver_cnt"
echo -e "mxosrvr\t\t$cfg_mxo_cnt\t\t$act_mxo_cnt\t\t$down_mxo_cnt\n"
else
echo "DCS is not installed. Please install and configure DCS..."
exit 1
fi
else
echo "Trafodion is not started or is not operational..."
echo
exit 1
fi

case $OPT_VALUE in
-m)
if [ -e $SQ_PDSH ]; then
STAT_CMD="$SQ_PDSH -w $activeMaster $jstatcmd -gc "
else
STAT_CMD=" $jstatcmd -gc "
fi
J_STATUS=`$STAT_CMD $activeDcsPid `
EC=`echo $J_STATUS | sed -n 1p | awk '{ print $20 }'`
EU=`echo $J_STATUS | sed -n 1p | awk '{ print $21 }'`
OC=`echo $J_STATUS | sed -n 1p | awk '{ print $22 }'`
OU=`echo $J_STATUS | sed -n 1p | awk '{ print $23 }'`
PERCENT_EU=$(echo "scale=2;$EU/$EC "| bc)
PERCENT_OU=$(echo "scale=2;$OU/$OC "| bc)

echo -e "Active DCSMaster VM status:"
echo -e "EC\tEU\tOC\tOU\tPERCENT_EU\tPERCENT_OU\t"
echo -e "$EC\t|$EU\t|$OC\t|$OU\t|$PERCENT_EU\t\t|$PERCENT_OU\t"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to expand the title headers as indicated before EC , OC and so on... Please delete the debug lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to expand the title headers because jdk command 'jstat' behaves as the same way.

;;

-t)
if [ -e $SQ_PDSH ]; then
STAT_CMD="$SQ_PDSH -w $activeMaster $jstackcmd "
else
STAT_CMD=" $jstackcmd "
fi
echo `$STAT_CMD $activeDcsPid \
| sed -n '/Thread-6/, /ListenerWorker.java/p'`

echo `$STAT_CMD $activeDcsPid \
| sed -n '/Thread-5/, /ListenerService.java/p'`
;;
-s)
"$JAVA" -XX:OnOutOfMemoryError="kill -9 %p" -classpath ${CLASSPATH}:${DCS_INSTALL_DIR}/"dcs-"$TRAFODION_VER".jar" org.trafodion.dcs.zookeeper.ZKShellTool 2>/dev/null
;;
*)
echo -e "Process\t\tConfigured\tActual\t\tDown"
echo -e "---------\t----------\t------\t\t----"
echo -e "DcsMaster\t$cfg_dcsmaster_cnt\t\t$actual_dcsmaster_cnt\t\t$down_dcsmaster_cnt"
echo -e "DcsServer\t$cfg_dcsserver_cnt\t\t$actual_dcsserver_cnt\t\t$down_dcsserver_cnt"
echo -e "mxosrvr\t\t$cfg_mxo_cnt\t\t$act_mxo_cnt\t\t$down_mxo_cnt\n"
exit 0
;;
esac
exit 0
61 changes: 61 additions & 0 deletions dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKShellTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @@@ START COPYRIGHT @@@

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

* @@@ END COPYRIGHT @@@
*/
package org.trafodion.dcs.zookeeper;

import java.util.Properties;
import java.util.Map.Entry;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.trafodion.dcs.util.DcsConfiguration;
import java.sql.Timestamp;
/**
* Tool for reading ZooKeeper servers from dcs XML configuration and producing
* a line-by-line list for use by bash scripts.
*/
public class ZKShellTool {
/**
* Run the tool.
* @param args Command line arguments.
*/
public static void main(String args[]) throws Exception{
String username = System.getProperty("user.name");
System.out.println("User: " + username);
ZkClient zkc = new ZkClient();
zkc.connect();

String registeredPath = new String("/"+username + "/dcs/servers/registered");
List<String> zks = zkc.getChildren(registeredPath, null);

System.out.println("State\t\tNode\tProcessId\tProcessName\tIpAddress\tPort\tClientName\tClientApp\tClientIp\tClientPort");
for (String nodeName: zks){
String nodePath = registeredPath + "/" + nodeName;
String currentData = new String(zkc.getData(nodePath, false, null));
String[] node_status = currentData.split(":");
for(int i = 0; i < node_status.length; i++){
if (i != 1 && i != 2)
System.out.print(node_status[i]+"\t");
}
System.out.println();
}
}
}