Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8b1a9911
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
8b1a9911
编写于
3月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
send the basic information of the monitor
上级
4f4100f9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
6 deletion
+61
-6
include/common/ttime.h
include/common/ttime.h
+2
-0
source/common/src/ttime.c
source/common/src/ttime.c
+47
-0
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+7
-1
source/util/src/thttp.c
source/util/src/thttp.c
+5
-5
未找到文件。
include/common/ttime.h
浏览文件 @
8b1a9911
...
...
@@ -52,6 +52,8 @@ void deltaToUtcInitOnce();
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
);
void
taosFormatUtcTime
(
char
*
buf
,
int32_t
bufLen
,
int64_t
time
,
int32_t
precision
);
#ifdef __cplusplus
}
#endif
...
...
source/common/src/ttime.c
浏览文件 @
8b1a9911
...
...
@@ -627,3 +627,50 @@ const char* fmtts(int64_t ts) {
return
buf
;
}
void
taosFormatUtcTime
(
char
*
buf
,
int32_t
bufLen
,
int64_t
t
,
int32_t
precision
)
{
char
ts
[
40
]
=
{
0
};
struct
tm
*
ptm
;
int32_t
fractionLen
;
char
*
format
=
NULL
;
time_t
quot
=
0
;
long
mod
=
0
;
switch
(
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
{
quot
=
t
/
1000
;
fractionLen
=
5
;
format
=
".%03"
PRId64
;
mod
=
t
%
1000
;
break
;
}
case
TSDB_TIME_PRECISION_MICRO
:
{
quot
=
t
/
1000000
;
fractionLen
=
8
;
format
=
".%06"
PRId64
;
mod
=
t
%
1000000
;
break
;
}
case
TSDB_TIME_PRECISION_NANO
:
{
quot
=
t
/
1000000000
;
fractionLen
=
11
;
format
=
".%09"
PRId64
;
mod
=
t
%
1000000000
;
break
;
}
default:
fractionLen
=
0
;
assert
(
false
);
}
ptm
=
localtime
(
&
quot
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
length
+=
snprintf
(
ts
+
length
,
fractionLen
,
format
,
mod
);
length
+=
(
int32_t
)
strftime
(
ts
+
length
,
40
-
length
,
"%z"
,
ptm
);
tstrncpy
(
buf
,
ts
,
bufLen
);
}
\ No newline at end of file
source/libs/monitor/src/monitor.c
浏览文件 @
8b1a9911
...
...
@@ -18,6 +18,7 @@
#include "taoserror.h"
#include "thttp.h"
#include "tlog.h"
#include "ttime.h"
static
SMonitor
tsMonitor
=
{
0
};
...
...
@@ -56,7 +57,7 @@ SMonInfo *monCreateMonitorInfo() {
if
(
pMonitor
==
NULL
)
return
NULL
;
taosWLockLatch
(
&
tsMonitor
.
lock
);
pMonitor
->
logs
=
taosArrayDup
(
pMonitor
->
logs
);
pMonitor
->
logs
=
taosArrayDup
(
tsMonitor
.
logs
);
taosArrayClear
(
tsMonitor
.
logs
);
taosWUnLockLatch
(
&
tsMonitor
.
lock
);
...
...
@@ -88,6 +89,11 @@ void monSetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo) {
SJson
*
pJson
=
pMonitor
->
pJson
;
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
tjsonAddStringToObject
(
pJson
,
"dnode_ep"
,
pInfo
->
dnode_ep
);
int64_t
ms
=
taosGetTimestampMs
();
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
ms
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pJson
,
"ts"
,
buf
);
}
void
monSetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
);
...
...
source/util/src/thttp.c
浏览文件 @
8b1a9911
...
...
@@ -32,7 +32,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, const char* pCont,
fd
=
taosOpenTcpClientSocket
(
ip
,
port
,
0
);
if
(
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to create
http socket since %s"
,
terrstr
());
uError
(
"failed to create
socket to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
...
...
@@ -46,24 +46,24 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, const char* pCont,
if
(
taosWriteSocket
(
fd
,
(
void
*
)
header
,
headLen
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to send http header
since %s"
,
terrstr
());
uError
(
"failed to send http header
to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
if
(
taosWriteSocket
(
fd
,
(
void
*
)
pCont
,
contLen
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to send http content
since %s"
,
terrstr
());
uError
(
"failed to send http content
to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
// read something to avoid nginx error 499
if
(
taosReadSocket
(
fd
,
header
,
10
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to receive response
since %s"
,
terrstr
());
uError
(
"failed to receive response
from %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
uInfo
(
"send http to %s:%
d
, len:%d content: %s"
,
server
,
port
,
contLen
,
pCont
);
uInfo
(
"send http to %s:%
u
, len:%d content: %s"
,
server
,
port
,
contLen
,
pCont
);
code
=
0
;
SEND_OVER:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录