未验证 提交 695ad274 编写于 作者: Q QinZuoyan 提交者: GitHub

fix: improve shell get_app_stat and ls_nodes & fix scripts (#382)

上级 b0bd9f52
...@@ -11,6 +11,7 @@ if [ $# -lt 2 ]; then ...@@ -11,6 +11,7 @@ if [ $# -lt 2 ]; then
exit 1 exit 1
fi fi
PID=$$
clusters_file=$1 clusters_file=$1
format=$2 format=$2
if [ "$format" != "table" -a "$format" != "csv" ]; then if [ "$format" != "table" -a "$format" != "csv" ]; then
...@@ -49,8 +50,8 @@ while read cluster ...@@ -49,8 +50,8 @@ while read cluster
do do
tmp_file="/tmp/$UID.$PID.pegasus.clusters_status.cluster_info" tmp_file="/tmp/$UID.$PID.pegasus.clusters_status.cluster_info"
echo "cluster_info" | ./run.sh shell -n $cluster &>$tmp_file echo "cluster_info" | ./run.sh shell -n $cluster &>$tmp_file
cluster_info_ok=`grep "succeed" $tmp_file | wc -l` cluster_info_fail=`grep "\<failed\>" $tmp_file | wc -l`
if [ $cluster_info_ok -ne 1 ]; then if [ $cluster_info_fail -eq 1 ]; then
echo "ERROR: get cluster info failed, refer error to $tmp_file" echo "ERROR: get cluster info failed, refer error to $tmp_file"
exit 1 exit 1
fi fi
...@@ -71,8 +72,13 @@ do ...@@ -71,8 +72,13 @@ do
echo "app_stat -o $app_stat_result" | ./run.sh shell -n $cluster &>$tmp_file echo "app_stat -o $app_stat_result" | ./run.sh shell -n $cluster &>$tmp_file
app_stat_fail=`grep "\<failed\>" $tmp_file | wc -l` app_stat_fail=`grep "\<failed\>" $tmp_file | wc -l`
if [ $app_stat_fail -eq 1 ]; then if [ $app_stat_fail -eq 1 ]; then
echo "ERROR: app stat failed, refer error to $tmp_file" sleep 1
exit 1 echo "app_stat -o $app_stat_result" | ./run.sh shell -n $cluster &>$tmp_file
app_stat_fail=`grep "\<failed\>" $tmp_file | wc -l`
if [ $app_stat_fail -eq 1 ]; then
echo "ERROR: app stat failed, refer error to $tmp_file"
exit 1
fi
fi fi
app_count=`cat $app_stat_result | wc -l` app_count=`cat $app_stat_result | wc -l`
app_count=$((app_count-2)) app_count=$((app_count-2))
......
...@@ -58,8 +58,8 @@ function get_env() ...@@ -58,8 +58,8 @@ function get_env()
log_file="/tmp/$UID.$PID.pegasus.get_app_envs.${app_name}" log_file="/tmp/$UID.$PID.pegasus.get_app_envs.${app_name}"
echo -e "use ${app_name}\n get_app_envs" | ./run.sh shell --cluster ${cluster} &>${log_file} echo -e "use ${app_name}\n get_app_envs" | ./run.sh shell --cluster ${cluster} &>${log_file}
get_ok=`grep 'get app envs succeed' ${log_file} | wc -l` get_fail=`grep 'get app env failed' ${log_file} | wc -l`
if [ ${get_ok} -ne 1 ]; then if [ ${get_fail} -eq 1 ]; then
echo "ERROR: get app envs failed, refer to ${log_file}" echo "ERROR: get app envs failed, refer to ${log_file}"
exit 1 exit 1
fi fi
...@@ -77,8 +77,8 @@ function set_env() ...@@ -77,8 +77,8 @@ function set_env()
echo "set_app_envs ${key}=${value}" echo "set_app_envs ${key}=${value}"
log_file="/tmp/$UID.$PID.pegasus.set_app_envs.${app_name}" log_file="/tmp/$UID.$PID.pegasus.set_app_envs.${app_name}"
echo -e "use ${app_name}\n set_app_envs ${key} ${value}" | ./run.sh shell --cluster ${cluster} &>${log_file} echo -e "use ${app_name}\n set_app_envs ${key} ${value}" | ./run.sh shell --cluster ${cluster} &>${log_file}
set_ok=`grep 'set app envs succeed' ${log_file} | wc -l` set_fail=`grep 'set app env failed' ${log_file} | wc -l`
if [ ${set_ok} -ne 1 ]; then if [ ${set_fail} -eq 1 ]; then
echo "ERROR: set app envs failed, refer to ${log_file}" echo "ERROR: set app envs failed, refer to ${log_file}"
exit 1 exit 1
fi fi
......
...@@ -27,8 +27,8 @@ all_start_time=$((`date +%s`)) ...@@ -27,8 +27,8 @@ all_start_time=$((`date +%s`))
echo echo
echo "app $app_name -d" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.app.$app_name echo "app $app_name -d" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.app.$app_name
list_ok=`grep "list app $app_name succeed" /tmp/$UID.$PID.pegasus.app.$app_name | wc -l` list_fail=`grep "\<failed\>" /tmp/$UID.$PID.pegasus.app.$app_name | wc -l`
if [ $list_ok -ne 1 ]; then if [ $list_fail -eq 1 ]; then
grep ERR /tmp/$UID.$PID.pegasus.app.$app_name grep ERR /tmp/$UID.$PID.pegasus.app.$app_name
echo "ERROR: list app failed, refer to /tmp/$UID.$PID.pegasus.app.$app_name" echo "ERROR: list app failed, refer to /tmp/$UID.$PID.pegasus.app.$app_name"
exit 1 exit 1
......
...@@ -33,8 +33,8 @@ all_start_time=$((`date +%s`)) ...@@ -33,8 +33,8 @@ all_start_time=$((`date +%s`))
echo echo
echo -e "use $app_name\nset_app_envs $scenario_key $scenario" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.set_app_envs echo -e "use $app_name\nset_app_envs $scenario_key $scenario" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.set_app_envs
set_ok=`grep 'set app envs succeed' /tmp/$UID.$PID.pegasus.set_app_envs | wc -l` set_fail=`grep 'set app env failed' /tmp/$UID.$PID.pegasus.set_app_envs | wc -l`
if [ $set_ok -ne 1 ]; then if [ $set_fail -eq 1 ]; then
grep ERR /tmp/$UID.$PID.pegasus.set_app_envs grep ERR /tmp/$UID.$PID.pegasus.set_app_envs
echo "ERROR: set app envs failed, refer to /tmp/$UID.$PID.pegasus.set_app_envs" echo "ERROR: set app envs failed, refer to /tmp/$UID.$PID.pegasus.set_app_envs"
exit 1 exit 1
......
...@@ -680,12 +680,13 @@ get_app_stat(shell_context *sc, const std::string &app_name, std::vector<row_dat ...@@ -680,12 +680,13 @@ get_app_stat(shell_context *sc, const std::string &app_name, std::vector<row_dat
} }
::dsn::command command; ::dsn::command command;
command.cmd = "perf-counters-by-substr"; command.cmd = "perf-counters";
char tmp[256]; char tmp[256];
if (app_name.empty()) if (app_name.empty()) {
sprintf(tmp, "@"); sprintf(tmp, ".*@.*");
else } else {
sprintf(tmp, "@%d.", app_info->app_id); sprintf(tmp, ".*@%d\\..*", app_info->app_id);
}
command.arguments.emplace_back(tmp); command.arguments.emplace_back(tmp);
std::vector<std::pair<bool, std::string>> results; std::vector<std::pair<bool, std::string>> results;
call_remote_command(sc, nodes, command, results); call_remote_command(sc, nodes, command, results);
......
...@@ -171,7 +171,7 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args) ...@@ -171,7 +171,7 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args)
if (resource_usage) { if (resource_usage) {
std::vector<node_desc> nodes; std::vector<node_desc> nodes;
if (!fill_nodes(sc, "replica-server", nodes)) { if (!fill_nodes(sc, "replica-server", nodes)) {
derror("get replica server node list failed"); std::cout << "get replica server node list failed" << std::endl;
return true; return true;
} }
...@@ -192,21 +192,20 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args) ...@@ -192,21 +192,20 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args)
if (tmp_it == tmp_map.end()) if (tmp_it == tmp_map.end())
continue; continue;
if (!results[i].first) { if (!results[i].first) {
derror("query perf counter info from node %s failed", node_addr.to_string()); std::cout << "query perf counter info from node " << node_addr.to_string()
<< " failed" << std::endl;
return true; return true;
} }
dsn::perf_counter_info info; dsn::perf_counter_info info;
dsn::blob bb(results[i].second.data(), 0, results[i].second.size()); dsn::blob bb(results[i].second.data(), 0, results[i].second.size());
if (!dsn::json::json_forwarder<dsn::perf_counter_info>::decode(bb, info)) { if (!dsn::json::json_forwarder<dsn::perf_counter_info>::decode(bb, info)) {
derror("decode perf counter info from node %s failed, result = %s", std::cout << "decode perf counter info from node " << node_addr.to_string()
node_addr.to_string(), << " failed, result = " << results[i].second << std::endl;
results[i].second.c_str());
return true; return true;
} }
if (info.result != "OK") { if (info.result != "OK") {
derror("query perf counter info from node %s returns error, error = %s", std::cout << "query perf counter info from node " << node_addr.to_string()
node_addr.to_string(), << " returns error, error = " << info.result << std::endl;
info.result.c_str());
return true; return true;
} }
list_nodes_helper &h = tmp_it->second; list_nodes_helper &h = tmp_it->second;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册