Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
418f15e2
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
418f15e2
编写于
12月 03, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
T-2270 change monitordebugflag
上级
26b32bd9
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
110 addition
and
110 deletion
+110
-110
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-1
src/common/src/tglobal.c
src/common/src/tglobal.c
+13
-13
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+4
-4
src/inc/monitor.h
src/inc/monitor.h
+7
-7
src/mnode/inc/mnodeInt.h
src/mnode/inc/mnodeInt.h
+3
-3
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+75
-75
tests/script/general/alter/dnode.sim
tests/script/general/alter/dnode.sim
+4
-4
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-1
未找到文件。
packaging/cfg/taos.cfg
浏览文件 @
418f15e2
...
...
@@ -236,7 +236,7 @@
# httpDebugFlag 131
# debug flag for monitor
# mon
itorDebugFlag
131
# mon
DebugFlag
131
# debug flag for query
# qDebugflag 131
...
...
src/client/src/tscSQLParser.c
浏览文件 @
418f15e2
...
...
@@ -5103,7 +5103,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
const
int
tokenDebugFlagEnd
=
20
;
const
SDNodeDynConfOption
cfgOptions
[]
=
{
{
"resetLog"
,
8
},
{
"resetQueryCache"
,
15
},
{
"balance"
,
7
},
{
"monitor"
,
7
},
{
"debugFlag"
,
9
},
{
"mon
itorDebugFlag"
,
16
},
{
"vDebugFlag"
,
10
},
{
"mDebugFlag"
,
10
},
{
"debugFlag"
,
9
},
{
"mon
DebugFlag"
,
11
},
{
"vDebugFlag"
,
10
},
{
"mDebugFlag"
,
10
},
{
"cDebugFlag"
,
10
},
{
"httpDebugFlag"
,
13
},
{
"qDebugflag"
,
10
},
{
"sdbDebugFlag"
,
12
},
{
"uDebugFlag"
,
10
},
{
"tsdbDebugFlag"
,
13
},
{
"sDebugflag"
,
10
},
{
"rpcDebugFlag"
,
12
},
{
"dDebugFlag"
,
10
},
{
"mqttDebugFlag"
,
13
},
{
"wDebugFlag"
,
10
},
{
"tmrDebugFlag"
,
12
},
...
...
src/common/inc/tglobal.h
浏览文件 @
418f15e2
...
...
@@ -176,7 +176,7 @@ extern int32_t tmrDebugFlag;
extern
int32_t
sdbDebugFlag
;
extern
int32_t
httpDebugFlag
;
extern
int32_t
mqttDebugFlag
;
extern
int32_t
mon
itor
DebugFlag
;
extern
int32_t
monDebugFlag
;
extern
int32_t
uDebugFlag
;
extern
int32_t
rpcDebugFlag
;
extern
int32_t
odbcDebugFlag
;
...
...
src/common/src/tglobal.c
浏览文件 @
418f15e2
...
...
@@ -206,7 +206,7 @@ int32_t jniDebugFlag = 131;
int32_t
odbcDebugFlag
=
131
;
int32_t
httpDebugFlag
=
131
;
int32_t
mqttDebugFlag
=
131
;
int32_t
mon
itor
DebugFlag
=
131
;
int32_t
monDebugFlag
=
131
;
int32_t
qDebugFlag
=
131
;
int32_t
rpcDebugFlag
=
131
;
int32_t
uDebugFlag
=
131
;
...
...
@@ -216,9 +216,9 @@ int32_t wDebugFlag = 135;
int32_t
tsdbDebugFlag
=
131
;
int32_t
cqDebugFlag
=
135
;
int32_t
(
*
mon
itor
StartSystemFp
)()
=
NULL
;
void
(
*
mon
itor
StopSystemFp
)()
=
NULL
;
void
(
*
mon
itor
ExecuteSQLFp
)(
char
*
sql
)
=
NULL
;
int32_t
(
*
monStartSystemFp
)()
=
NULL
;
void
(
*
monStopSystemFp
)()
=
NULL
;
void
(
*
monExecuteSQLFp
)(
char
*
sql
)
=
NULL
;
char
*
qtypeStr
[]
=
{
"rpc"
,
"fwd"
,
"wal"
,
"cq"
,
"query"
};
...
...
@@ -235,7 +235,7 @@ void taosSetAllDebugFlag() {
odbcDebugFlag
=
debugFlag
;
httpDebugFlag
=
debugFlag
;
mqttDebugFlag
=
debugFlag
;
mon
itor
DebugFlag
=
debugFlag
;
monDebugFlag
=
debugFlag
;
qDebugFlag
=
debugFlag
;
rpcDebugFlag
=
debugFlag
;
uDebugFlag
=
debugFlag
;
...
...
@@ -276,15 +276,15 @@ bool taosCfgDynamicOptions(char *msg) {
if
(
strncasecmp
(
cfg
->
option
,
"monitor"
,
olen
)
==
0
)
{
if
(
1
==
vint
)
{
if
(
mon
itor
StartSystemFp
)
{
(
*
mon
itor
StartSystemFp
)();
if
(
monStartSystemFp
)
{
(
*
monStartSystemFp
)();
uInfo
(
"monitor is enabled"
);
}
else
{
uError
(
"monitor can't be updated, for monitor not initialized"
);
}
}
else
{
if
(
mon
itor
StopSystemFp
)
{
(
*
mon
itor
StopSystemFp
)();
if
(
monStopSystemFp
)
{
(
*
monStopSystemFp
)();
uInfo
(
"monitor is disabled"
);
}
else
{
uError
(
"monitor can't be updated, for monitor not initialized"
);
...
...
@@ -307,8 +307,8 @@ bool taosCfgDynamicOptions(char *msg) {
}
if
(
strncasecmp
(
option
,
"resetQueryCache"
,
15
)
==
0
)
{
if
(
mon
itor
ExecuteSQLFp
)
{
(
*
mon
itor
ExecuteSQLFp
)(
"resetQueryCache"
);
if
(
monExecuteSQLFp
)
{
(
*
monExecuteSQLFp
)(
"resetQueryCache"
);
uInfo
(
"resetquerycache is executed"
);
}
else
{
uError
(
"resetquerycache can't be executed, for monitor not started"
);
...
...
@@ -1227,8 +1227,8 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"mon
itor
DebugFlag"
;
cfg
.
ptr
=
&
mon
itor
DebugFlag
;
cfg
.
option
=
"monDebugFlag"
;
cfg
.
ptr
=
&
monDebugFlag
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
;
cfg
.
minValue
=
0
;
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
418f15e2
...
...
@@ -78,10 +78,10 @@ static void dnodeAllocModules() {
tsModule
[
TSDB_MOD_MONITOR
].
enable
=
(
tsEnableMonitorModule
==
1
);
tsModule
[
TSDB_MOD_MONITOR
].
name
=
"monitor"
;
tsModule
[
TSDB_MOD_MONITOR
].
initFp
=
mon
itor
InitSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
cleanUpFp
=
mon
itorCleanU
pSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
startFp
=
mon
itor
StartSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
stopFp
=
mon
itor
StopSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
initFp
=
monInitSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
cleanUpFp
=
mon
Cleanu
pSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
startFp
=
monStartSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
stopFp
=
monStopSystem
;
if
(
tsEnableMonitorModule
)
{
dnodeSetModuleStatus
(
TSDB_MOD_MONITOR
);
}
...
...
src/inc/monitor.h
浏览文件 @
418f15e2
...
...
@@ -47,13 +47,13 @@ typedef struct {
int8_t
accessState
;
}
SAcctMonitorObj
;
int32_t
mon
itor
InitSystem
();
int32_t
mon
itor
StartSystem
();
void
mon
itor
StopSystem
();
void
mon
itorCleanU
pSystem
();
void
mon
itor
SaveAcctLog
(
SAcctMonitorObj
*
pMonObj
);
void
mon
itor
SaveLog
(
int32_t
level
,
const
char
*
const
format
,
...);
void
mon
itor
ExecuteSQL
(
char
*
sql
);
int32_t
monInitSystem
();
int32_t
monStartSystem
();
void
monStopSystem
();
void
mon
Cleanu
pSystem
();
void
monSaveAcctLog
(
SAcctMonitorObj
*
pMonObj
);
void
monSaveLog
(
int32_t
level
,
const
char
*
const
format
,
...);
void
monExecuteSQL
(
char
*
sql
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mnodeInt.h
浏览文件 @
418f15e2
...
...
@@ -41,9 +41,9 @@ extern int32_t sdbDebugFlag;
#define sdbDebug(...) { if (sdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("SDB ", sdbDebugFlag, __VA_ARGS__); }}
#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("SDB ", sdbDebugFlag, __VA_ARGS__); }}
#define mLError(...) { mon
itor
SaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) }
#define mLWarn(...) { mon
itor
SaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
#define mLInfo(...) { mon
itor
SaveLog(0, __VA_ARGS__); mInfo(__VA_ARGS__) }
#define mLError(...) { monSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) }
#define mLWarn(...) { monSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
#define mLInfo(...) { monSaveLog(0, __VA_ARGS__); mInfo(__VA_ARGS__) }
#ifdef __cplusplus
}
...
...
src/plugins/monitor/src/mon
itor
Main.c
→
src/plugins/monitor/src/monMain.c
浏览文件 @
418f15e2
...
...
@@ -27,12 +27,12 @@
#include "monitor.h"
#include "taoserror.h"
#define m
nFatal(...) { if (monitor
DebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
#define m
nError(...) { if (monitor
DebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
#define m
nWarn(...) { if (monitor
DebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
#define m
nInfo(...) { if (monitor
DebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
#define m
nDebug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", monitor
DebugFlag, __VA_ARGS__); }}
#define m
nTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitor
DebugFlag, __VA_ARGS__); }}
#define m
onFatal(...) { if (mon
DebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
#define m
onError(...) { if (mon
DebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
#define m
onWarn(...) { if (mon
DebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
#define m
onInfo(...) { if (mon
DebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
#define m
onDebug(...) { if (monDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", mon
DebugFlag, __VA_ARGS__); }}
#define m
onTrace(...) { if (monDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", mon
DebugFlag, __VA_ARGS__); }}
#define SQL_LENGTH 1030
#define LOG_LEN_STR 100
...
...
@@ -48,12 +48,12 @@ typedef enum {
MON_CMD_CREATE_TB_ACCT_ROOT
,
MON_CMD_CREATE_TB_SLOWQUERY
,
MON_CMD_MAX
}
EMon
itorComman
d
;
}
EMon
Cm
d
;
typedef
enum
{
MON_STATE_NOT_INIT
,
MON_STATE_INITED
}
EMon
itor
State
;
}
EMonState
;
typedef
struct
{
pthread_t
thread
;
...
...
@@ -64,17 +64,17 @@ typedef struct {
int8_t
start
;
// enable/disable by mnode
int8_t
quiting
;
// taosd is quiting
char
sql
[
SQL_LENGTH
+
1
];
}
SMon
itor
Conn
;
}
SMonConn
;
static
SMon
itor
Conn
tsMonitor
=
{
0
};
static
void
mon
itor
SaveSystemInfo
();
static
void
*
mon
itor
ThreadFunc
(
void
*
param
);
static
void
mon
itor
BuildMonitorSql
(
char
*
sql
,
int32_t
cmd
);
extern
int32_t
(
*
mon
itor
StartSystemFp
)();
extern
void
(
*
mon
itor
StopSystemFp
)();
extern
void
(
*
mon
itor
ExecuteSQLFp
)(
char
*
sql
);
static
SMonConn
tsMonitor
=
{
0
};
static
void
monSaveSystemInfo
();
static
void
*
monThreadFunc
(
void
*
param
);
static
void
monBuildMonitorSql
(
char
*
sql
,
int32_t
cmd
);
extern
int32_t
(
*
monStartSystemFp
)();
extern
void
(
*
monStopSystemFp
)();
extern
void
(
*
monExecuteSQLFp
)(
char
*
sql
);
int32_t
mon
itor
InitSystem
()
{
int32_t
monInitSystem
()
{
if
(
tsMonitor
.
ep
[
0
]
==
0
)
{
strcpy
(
tsMonitor
.
ep
,
tsLocalEp
);
}
...
...
@@ -90,29 +90,29 @@ int32_t monitorInitSystem() {
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
tsMonitor
.
thread
,
&
thAttr
,
mon
itor
ThreadFunc
,
NULL
))
{
mnError
(
"failed to create thread to for monitor module, reason:%s"
,
strerror
(
errno
));
if
(
pthread_create
(
&
tsMonitor
.
thread
,
&
thAttr
,
monThreadFunc
,
NULL
))
{
m
o
nError
(
"failed to create thread to for monitor module, reason:%s"
,
strerror
(
errno
));
return
-
1
;
}
pthread_attr_destroy
(
&
thAttr
);
mnDebug
(
"monitor thread is launched"
);
m
o
nDebug
(
"monitor thread is launched"
);
mon
itorStartSystemFp
=
monitor
StartSystem
;
mon
itorStopSystemFp
=
monitor
StopSystem
;
mon
StartSystemFp
=
mon
StartSystem
;
mon
StopSystemFp
=
mon
StopSystem
;
return
0
;
}
int32_t
mon
itor
StartSystem
()
{
int32_t
monStartSystem
()
{
taos_init
();
tsMonitor
.
start
=
1
;
mon
itorExecuteSQLFp
=
monitor
ExecuteSQL
;
mnInfo
(
"monitor module start"
);
mon
ExecuteSQLFp
=
mon
ExecuteSQL
;
m
o
nInfo
(
"monitor module start"
);
return
0
;
}
static
void
*
mon
itor
ThreadFunc
(
void
*
param
)
{
mnDebug
(
"starting to initialize monitor module ..."
);
static
void
*
monThreadFunc
(
void
*
param
)
{
m
o
nDebug
(
"starting to initialize monitor module ..."
);
while
(
1
)
{
static
int32_t
accessTimes
=
0
;
...
...
@@ -121,7 +121,7 @@ static void *monitorThreadFunc(void *param) {
if
(
tsMonitor
.
quiting
)
{
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
mnInfo
(
"monitor thread will quit, for taosd is quiting"
);
m
o
nInfo
(
"monitor thread will quit, for taosd is quiting"
);
break
;
}
else
{
taosGetDisk
();
...
...
@@ -132,7 +132,7 @@ static void *monitorThreadFunc(void *param) {
}
if
(
dnodeGetDnodeId
()
<=
0
)
{
mnDebug
(
"dnode not initialized, waiting for 3000 ms to start monitor module"
);
m
o
nDebug
(
"dnode not initialized, waiting for 3000 ms to start monitor module"
);
continue
;
}
...
...
@@ -140,10 +140,10 @@ static void *monitorThreadFunc(void *param) {
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
tsMonitor
.
conn
=
taos_connect
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
);
if
(
tsMonitor
.
conn
==
NULL
)
{
mnError
(
"failed to connect to database, reason:%s"
,
tstrerror
(
terrno
));
m
o
nError
(
"failed to connect to database, reason:%s"
,
tstrerror
(
terrno
));
continue
;
}
else
{
mnDebug
(
"connect to database success"
);
m
o
nDebug
(
"connect to database success"
);
}
}
...
...
@@ -151,16 +151,16 @@ static void *monitorThreadFunc(void *param) {
int
code
=
0
;
for
(;
tsMonitor
.
cmdIndex
<
MON_CMD_MAX
;
++
tsMonitor
.
cmdIndex
)
{
mon
itor
BuildMonitorSql
(
tsMonitor
.
sql
,
tsMonitor
.
cmdIndex
);
monBuildMonitorSql
(
tsMonitor
.
sql
,
tsMonitor
.
cmdIndex
);
void
*
res
=
taos_query
(
tsMonitor
.
conn
,
tsMonitor
.
sql
);
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
mnError
(
"failed to exec sql:%s, reason:%s"
,
tsMonitor
.
sql
,
tstrerror
(
code
));
m
o
nError
(
"failed to exec sql:%s, reason:%s"
,
tsMonitor
.
sql
,
tstrerror
(
code
));
break
;
}
else
{
mnDebug
(
"successfully to exec sql:%s"
,
tsMonitor
.
sql
);
m
o
nDebug
(
"successfully to exec sql:%s"
,
tsMonitor
.
sql
);
}
}
...
...
@@ -171,16 +171,16 @@ static void *monitorThreadFunc(void *param) {
if
(
tsMonitor
.
state
==
MON_STATE_INITED
)
{
if
(
accessTimes
%
tsMonitorInterval
==
0
)
{
mon
itor
SaveSystemInfo
();
monSaveSystemInfo
();
}
}
}
mnInfo
(
"monitor thread is stopped"
);
m
o
nInfo
(
"monitor thread is stopped"
);
return
NULL
;
}
static
void
mon
itor
BuildMonitorSql
(
char
*
sql
,
int32_t
cmd
)
{
static
void
monBuildMonitorSql
(
char
*
sql
,
int32_t
cmd
)
{
memset
(
sql
,
0
,
SQL_LENGTH
);
if
(
cmd
==
MON_CMD_CREATE_DB
)
{
...
...
@@ -236,47 +236,47 @@ static void monitorBuildMonitorSql(char *sql, int32_t cmd) {
sql
[
SQL_LENGTH
]
=
0
;
}
void
mon
itor
StopSystem
()
{
void
monStopSystem
()
{
tsMonitor
.
start
=
0
;
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
mon
itor
ExecuteSQLFp
=
NULL
;
mnInfo
(
"monitor module stopped"
);
monExecuteSQLFp
=
NULL
;
m
o
nInfo
(
"monitor module stopped"
);
}
void
mon
itorCleanU
pSystem
()
{
void
mon
Cleanu
pSystem
()
{
tsMonitor
.
quiting
=
1
;
mon
itor
StopSystem
();
monStopSystem
();
pthread_join
(
tsMonitor
.
thread
,
NULL
);
if
(
tsMonitor
.
conn
!=
NULL
)
{
taos_close
(
tsMonitor
.
conn
);
tsMonitor
.
conn
=
NULL
;
}
mnInfo
(
"monitor module is cleaned up"
);
m
o
nInfo
(
"monitor module is cleaned up"
);
}
// unit is MB
static
int32_t
mon
itor
BuildMemorySql
(
char
*
sql
)
{
static
int32_t
monBuildMemorySql
(
char
*
sql
)
{
float
sysMemoryUsedMB
=
0
;
bool
suc
=
taosGetSysMemory
(
&
sysMemoryUsedMB
);
if
(
!
suc
)
{
mnDebug
(
"failed to get sys memory info"
);
m
o
nDebug
(
"failed to get sys memory info"
);
}
float
procMemoryUsedMB
=
0
;
suc
=
taosGetProcMemory
(
&
procMemoryUsedMB
);
if
(
!
suc
)
{
mnDebug
(
"failed to get proc memory info"
);
m
o
nDebug
(
"failed to get proc memory info"
);
}
return
sprintf
(
sql
,
", %f, %f, %d"
,
procMemoryUsedMB
,
sysMemoryUsedMB
,
tsTotalMemoryMB
);
}
// unit is %
static
int32_t
mon
itor
BuildCpuSql
(
char
*
sql
)
{
static
int32_t
monBuildCpuSql
(
char
*
sql
)
{
float
sysCpuUsage
=
0
,
procCpuUsage
=
0
;
bool
suc
=
taosGetCpuUsage
(
&
sysCpuUsage
,
&
procCpuUsage
);
if
(
!
suc
)
{
mnDebug
(
"failed to get cpu usage"
);
m
o
nDebug
(
"failed to get cpu usage"
);
}
if
(
sysCpuUsage
<=
procCpuUsage
)
{
...
...
@@ -287,72 +287,72 @@ static int32_t monitorBuildCpuSql(char *sql) {
}
// unit is GB
static
int32_t
mon
itor
BuildDiskSql
(
char
*
sql
)
{
static
int32_t
monBuildDiskSql
(
char
*
sql
)
{
return
sprintf
(
sql
,
", %f, %d"
,
(
tsTotalDataDirGB
-
tsAvailDataDirGB
),
(
int32_t
)
tsTotalDataDirGB
);
}
// unit is Kb
static
int32_t
mon
itor
BuildBandSql
(
char
*
sql
)
{
static
int32_t
monBuildBandSql
(
char
*
sql
)
{
float
bandSpeedKb
=
0
;
bool
suc
=
taosGetBandSpeed
(
&
bandSpeedKb
);
if
(
!
suc
)
{
mnDebug
(
"failed to get bandwidth speed"
);
m
o
nDebug
(
"failed to get bandwidth speed"
);
}
return
sprintf
(
sql
,
", %f"
,
bandSpeedKb
);
}
static
int32_t
mon
itor
BuildReqSql
(
char
*
sql
)
{
static
int32_t
monBuildReqSql
(
char
*
sql
)
{
SStatisInfo
info
=
dnodeGetStatisInfo
();
return
sprintf
(
sql
,
", %d, %d, %d)"
,
info
.
httpReqNum
,
info
.
queryReqNum
,
info
.
submitReqNum
);
}
static
int32_t
mon
itor
BuildIoSql
(
char
*
sql
)
{
static
int32_t
monBuildIoSql
(
char
*
sql
)
{
float
readKB
=
0
,
writeKB
=
0
;
bool
suc
=
taosGetProcIO
(
&
readKB
,
&
writeKB
);
if
(
!
suc
)
{
mnDebug
(
"failed to get io info"
);
m
o
nDebug
(
"failed to get io info"
);
}
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
}
static
void
mon
itor
SaveSystemInfo
()
{
static
void
monSaveSystemInfo
()
{
int64_t
ts
=
taosGetTimestampUs
();
char
*
sql
=
tsMonitor
.
sql
;
int32_t
pos
=
snprintf
(
sql
,
SQL_LENGTH
,
"insert into %s.dn%d values(%"
PRId64
,
tsMonitorDbName
,
dnodeGetDnodeId
(),
ts
);
pos
+=
mon
itor
BuildCpuSql
(
sql
+
pos
);
pos
+=
mon
itor
BuildMemorySql
(
sql
+
pos
);
pos
+=
mon
itor
BuildDiskSql
(
sql
+
pos
);
pos
+=
mon
itor
BuildBandSql
(
sql
+
pos
);
pos
+=
mon
itor
BuildIoSql
(
sql
+
pos
);
pos
+=
mon
itor
BuildReqSql
(
sql
+
pos
);
pos
+=
monBuildCpuSql
(
sql
+
pos
);
pos
+=
monBuildMemorySql
(
sql
+
pos
);
pos
+=
monBuildDiskSql
(
sql
+
pos
);
pos
+=
monBuildBandSql
(
sql
+
pos
);
pos
+=
monBuildIoSql
(
sql
+
pos
);
pos
+=
monBuildReqSql
(
sql
+
pos
);
void
*
res
=
taos_query
(
tsMonitor
.
conn
,
tsMonitor
.
sql
);
int
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
mnError
(
"failed to save system info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
m
o
nError
(
"failed to save system info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
mnDebug
(
"successfully to save system info, sql:%s"
,
tsMonitor
.
sql
);
m
o
nDebug
(
"successfully to save system info, sql:%s"
,
tsMonitor
.
sql
);
}
}
static
void
mon
tior
ExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
static
void
monExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
int32_t
c
=
taos_errno
(
result
);
if
(
c
!=
TSDB_CODE_SUCCESS
)
{
mnError
(
"save %s failed, reason:%s"
,
(
char
*
)
param
,
tstrerror
(
c
));
m
o
nError
(
"save %s failed, reason:%s"
,
(
char
*
)
param
,
tstrerror
(
c
));
}
else
{
int32_t
rows
=
taos_affected_rows
(
result
);
mnDebug
(
"save %s succ, rows:%d"
,
(
char
*
)
param
,
rows
);
m
o
nDebug
(
"save %s succ, rows:%d"
,
(
char
*
)
param
,
rows
);
}
taos_free_result
(
result
);
}
void
mon
itor
SaveAcctLog
(
SAcctMonitorObj
*
pMon
)
{
void
monSaveAcctLog
(
SAcctMonitorObj
*
pMon
)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
char
sql
[
1024
]
=
{
0
};
...
...
@@ -382,11 +382,11 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) {
pMon
->
totalConns
,
pMon
->
maxConns
,
pMon
->
accessState
);
mnDebug
(
"save account info, sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
mon
tior
ExecSqlCb
,
"account info"
);
m
o
nDebug
(
"save account info, sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
monExecSqlCb
,
"account info"
);
}
void
mon
itor
SaveLog
(
int32_t
level
,
const
char
*
const
format
,
...)
{
void
monSaveLog
(
int32_t
level
,
const
char
*
const
format
,
...)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
va_list
argpointer
;
...
...
@@ -403,13 +403,13 @@ void monitorSaveLog(int32_t level, const char *const format, ...) {
len
+=
sprintf
(
sql
+
len
,
"', '%s')"
,
tsLocalEp
);
sql
[
len
++
]
=
0
;
mnDebug
(
"save log, sql: %s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
mon
tior
ExecSqlCb
,
"log"
);
m
o
nDebug
(
"save log, sql: %s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
monExecSqlCb
,
"log"
);
}
void
mon
itor
ExecuteSQL
(
char
*
sql
)
{
void
monExecuteSQL
(
char
*
sql
)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
mnDebug
(
"execute sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
mon
tior
ExecSqlCb
,
"sql"
);
m
o
nDebug
(
"execute sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
monExecSqlCb
,
"sql"
);
}
tests/script/general/alter/dnode.sim
浏览文件 @
418f15e2
...
...
@@ -24,7 +24,7 @@ sql alter dnode 1 debugFlag 135
sql alter dnode 1 debugFlag 131
sql alter dnode 1 monitor 0
sql alter dnode 1 debugFlag 135
sql alter dnode 1 mon
itor
DebugFlag 135
sql alter dnode 1 monDebugFlag 135
sql alter dnode 1 vDebugFlag 135
sql alter dnode 1 mDebugFlag 135
sql alter dnode 1 cDebugFlag 135
...
...
@@ -44,15 +44,15 @@ sql_error alter dnode 2 tmrDebugFlag 135
print ======== step3
sql_error alter $hostname1 debugFlag 135
sql_error alter $hostname1 mon
itor
DebugFlag 135
sql_error alter $hostname1 monDebugFlag 135
sql_error alter $hostname1 vDebugFlag 135
sql_error alter $hostname1 mDebugFlag 135
sql_error alter dnode $hostname2 debugFlag 135
sql_error alter dnode $hostname2 mon
itor
DebugFlag 135
sql_error alter dnode $hostname2 monDebugFlag 135
sql_error alter dnode $hostname2 vDebugFlag 135
sql_error alter dnode $hostname2 mDebugFlag 135
sql alter dnode $hostname1 debugFlag 135
sql alter dnode $hostname1 mon
itor
DebugFlag 135
sql alter dnode $hostname1 monDebugFlag 135
sql alter dnode $hostname1 vDebugFlag 135
sql alter dnode $hostname1 tmrDebugFlag 131
...
...
tests/script/sh/deploy.sh
浏览文件 @
418f15e2
...
...
@@ -120,7 +120,7 @@ echo "cDebugFlag 143" >> $TAOS_CFG
echo
"jnidebugFlag 143"
>>
$TAOS_CFG
echo
"odbcdebugFlag 143"
>>
$TAOS_CFG
echo
"httpDebugFlag 143"
>>
$TAOS_CFG
echo
"mon
itorDebugFlag
143"
>>
$TAOS_CFG
echo
"mon
DebugFlag
143"
>>
$TAOS_CFG
echo
"mqttDebugFlag 143"
>>
$TAOS_CFG
echo
"qdebugFlag 143"
>>
$TAOS_CFG
echo
"rpcDebugFlag 143"
>>
$TAOS_CFG
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录