Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf433ec9
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cf433ec9
编写于
4月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: check server status
上级
07ae7839
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
17 deletion
+49
-17
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+9
-1
source/dnode/mgmt/interface/src/dmInt.c
source/dnode/mgmt/interface/src/dmInt.c
+2
-2
tools/shell/inc/shell.h
tools/shell/inc/shell.h
+2
-1
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+36
-13
未找到文件。
source/client/src/clientImpl.c
浏览文件 @
cf433ec9
...
...
@@ -844,6 +844,14 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
goto
_OVER
;
}
if
(
fqdn
==
NULL
)
{
fqdn
=
tsLocalFqdn
;
}
if
(
port
==
0
)
{
port
=
tsServerPort
;
}
tstrncpy
(
epSet
.
eps
[
0
].
fqdn
,
fqdn
,
TSDB_FQDN_LEN
);
epSet
.
eps
[
0
].
port
=
(
uint16_t
)
port
;
rpcSendRecv
(
clientRpc
,
&
epSet
,
&
rpcMsg
,
&
rpcRsp
);
...
...
@@ -859,7 +867,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
}
code
=
statusRsp
.
statusCode
;
if
(
details
!=
NULL
)
{
if
(
details
!=
NULL
&&
statusRsp
.
details
!=
NULL
)
{
tstrncpy
(
details
,
statusRsp
.
details
,
maxlen
);
}
...
...
source/dnode/mgmt/interface/src/dmInt.c
浏览文件 @
cf433ec9
...
...
@@ -145,7 +145,7 @@ void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
static
void
dmGetServerStatus
(
SDnode
*
pDnode
,
SServerStatusRsp
*
pStatus
)
{
if
(
pDnode
->
status
==
DND_STAT_INIT
)
{
pStatus
->
statusCode
=
TSDB_SRV_STATUS_NETWORK_OK
;
}
else
if
(
pDnode
->
status
!
=
DND_STAT_STOPPED
)
{
}
else
if
(
pDnode
->
status
=
=
DND_STAT_STOPPED
)
{
pStatus
->
statusCode
=
TSDB_SRV_STATUS_EXTING
;
}
else
{
pStatus
->
statusCode
=
TSDB_SRV_STATUS_SERVICE_OK
;
...
...
@@ -172,7 +172,7 @@ void dmProcessServerStatusReq(SDnode *pDnode, SRpcMsg *pReq) {
SServerStatusRsp
statusRsp
=
{
0
};
dmGetServerStatus
(
pDnode
,
&
statusRsp
);
SRpcMsg
rspMsg
=
{.
handle
=
pReq
->
handle
,
.
handle
=
pReq
->
ahandle
};
SRpcMsg
rspMsg
=
{.
handle
=
pReq
->
handle
,
.
a
handle
=
pReq
->
ahandle
};
int32_t
rspLen
=
tSerializeSServerStatusRsp
(
NULL
,
0
,
&
statusRsp
);
if
(
rspLen
<
0
)
{
rspMsg
.
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
tools/shell/inc/shell.h
浏览文件 @
cf433ec9
...
...
@@ -50,6 +50,8 @@ typedef struct SShellArguments {
char
dir
[
TSDB_FILENAME_LEN
];
int
threadNum
;
int
check
;
bool
status
;
bool
verbose
;
char
*
commands
;
int
abort
;
int
port
;
...
...
@@ -72,7 +74,6 @@ void read_history();
void
write_history
();
void
source_file
(
TAOS
*
con
,
char
*
fptr
);
void
source_dir
(
TAOS
*
con
,
SShellArguments
*
args
);
void
shellCheck
(
TAOS
*
con
,
SShellArguments
*
args
);
void
get_history_path
(
char
*
history
);
void
shellCheck
(
TAOS
*
con
,
SShellArguments
*
args
);
void
cleanup_handler
(
void
*
arg
);
...
...
tools/shell/src/shellMain.c
浏览文件 @
cf433ec9
...
...
@@ -35,6 +35,7 @@ static char args_doc[] = "";
TdThread
pid
;
static
tsem_t
cancelSem
;
extern
void
taos_init
();
static
struct
argp_option
options
[]
=
{
{
"host"
,
'h'
,
"HOST"
,
0
,
"TDengine server FQDN to connect. The default host is localhost."
},
...
...
@@ -52,6 +53,8 @@ static struct argp_option options[] = {
{
"check"
,
'k'
,
"CHECK"
,
0
,
"Check tables."
},
{
"database"
,
'd'
,
"DATABASE"
,
0
,
"Database to use when connecting to the server."
},
{
"timezone"
,
'z'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"status"
,
't'
,
NULL
,
0
,
"Check the service status."
},
{
"verbose"
,
'v'
,
NULL
,
0
,
"Check the details of the service status."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|speed|fqdn."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
...
...
@@ -138,6 +141,12 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'k'
:
arguments
->
check
=
atoi
(
arg
);
break
;
case
't'
:
arguments
->
status
=
true
;
break
;
case
'v'
:
arguments
->
verbose
=
true
;
break
;
case
'd'
:
arguments
->
database
=
arg
;
break
;
...
...
@@ -608,10 +617,9 @@ int main(int argc, char *argv[]) {
}
shellParseArgument
(
argc
,
argv
,
&
args
);
taos_init
();
if
(
args
.
dump_config
)
{
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
);
SConfig
*
pCfg
=
taosGetCfg
();
if
(
NULL
==
pCfg
)
{
printf
(
"TDengine read global config failed!
\n
"
);
...
...
@@ -621,21 +629,36 @@ int main(int argc, char *argv[]) {
exit
(
0
);
}
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
TAOS
*
con
=
NULL
;
if
(
args
.
auth
==
NULL
)
{
con
=
taos_connect
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
database
,
args
.
port
);
}
else
{
con
=
taos_connect_auth
(
args
.
host
,
args
.
user
,
args
.
auth
,
args
.
database
,
args
.
port
);
if
(
args
.
status
||
args
.
verbose
)
{
char
details
[
1024
]
=
{
0
};
TSDB_SERVER_STATUS
code
=
taos_check_server_status
(
args
.
host
,
args
.
port
,
details
,
args
.
verbose
?
1024
:
0
);
switch
(
code
)
{
case
TSDB_SRV_STATUS_UNAVAILABLE
:
printf
(
"0: unavailable
\n
"
);
break
;
case
TSDB_SRV_STATUS_NETWORK_OK
:
printf
(
"1: network ok
\n
"
);
break
;
case
TSDB_SRV_STATUS_SERVICE_OK
:
printf
(
"2: service ok
\n
"
);
break
;
case
TSDB_SRV_STATUS_SERVICE_DEGRADED
:
printf
(
"3: service degradedk
\n
"
);
break
;
case
TSDB_SRV_STATUS_EXTING
:
printf
(
"4: exiting
\n
"
);
break
;
}
// if (taos_init()) {
// printf("Failed to init taos");
// exit(EXIT_FAILURE);
// }
if
(
strlen
(
details
)
!=
0
)
{
printf
(
"detail info:
\n
%s
\n
"
,
details
);
}
exit
(
0
);
}
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktNum
,
args
.
pktType
);
taos_close
(
con
);
exit
(
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录