Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
向上的车轮
TDengine
提交
126baf46
TDengine
项目概览
向上的车轮
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
126baf46
编写于
5月 29, 2020
作者:
T
Tao Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-424] divide audit tables;
上级
6a56036c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
6 deletion
+43
-6
src/inc/tlog.h
src/inc/tlog.h
+7
-0
src/modules/monitor/src/monitorSystem.c
src/modules/monitor/src/monitorSystem.c
+22
-4
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+14
-2
未找到文件。
src/inc/tlog.h
浏览文件 @
126baf46
...
...
@@ -25,11 +25,16 @@ extern "C" {
#include <string.h>
#include "tglobalcfg.h"
#define DEBUG_ERROR 1U
#define DEBUG_WARN 2U
#define DEBUG_TRACE 4U
#define DEBUG_DUMP 8U
#define AUDIT_INFO 0
#define AUDIT_WARN 1
#define AUDIT_ERROR 2
#define DEBUG_FILE 0x80
#define DEBUG_SCREEN 0x40
...
...
@@ -58,6 +63,8 @@ void taosPrintLongString(const char *const flags, int dflag, const char *const f
int
taosOpenLogFileWithMaxLines
(
char
*
fn
,
int
maxLines
,
int
maxFileNum
);
void
taosAuditRecord
(
int
level
,
char
*
dbuser
,
char
*
result
,
char
*
content
);
void
taosCloseLog
();
void
taosResetLogFile
();
...
...
src/modules/monitor/src/monitorSystem.c
浏览文件 @
126baf46
...
...
@@ -200,13 +200,12 @@ void dnodeBuildMonitorSql(char *sql, int cmd) {
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_DB_AUDIT
)
{
char
*
auditDBname
=
"audit"
;
snprintf
(
sql
,
SQL_LENGTH
,
"create database if not exists %s replica 1 days 10 keep 3650 rows 1024 cache 2048"
,
auditDBname
);
"create database if not exists %s replica 1 days 10 keep 3650 rows 1024 cache 2048 ablocks 2 tblocks 32 tables 32 precision 'us'"
,
auditDBname
);
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_TB_AUDIT
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists audit.audit(ts timestamp, level tinyint, "
"dbuser binary(%d), result binary(%d),
ipaddr binary(%d),
content binary(%d))"
,
TSDB_USER_LEN
,
LOG_RESULT_LEN
,
IP_LEN_STR
,
LOG_LEN_STR
);
"dbuser binary(%d), result binary(%d), content binary(%d))"
,
TSDB_USER_LEN
,
LOG_RESULT_LEN
,
LOG_LEN_STR
);
}
}
...
...
@@ -296,6 +295,16 @@ void dnodeMontiorInsertLogCallback(void *param, TAOS_RES *result, int code) {
}
}
void
dnodeMontiorInsertAuditCallback
(
void
*
param
,
TAOS_RES
*
result
,
int
code
)
{
if
(
code
<
0
)
{
monitorError
(
"monitor:%p, save audit failed, code:%d"
,
monitor
->
conn
,
code
);
}
else
if
(
code
==
0
)
{
monitorError
(
"monitor:%p, save audit failed, affect rows:%d"
,
monitor
->
conn
,
code
);
}
else
{
monitorTrace
(
"monitor:%p, save audit info success, code:%d"
,
monitor
->
conn
,
code
);
}
}
// unit is MB
int
monitorBuildMemorySql
(
char
*
sql
)
{
float
sysMemoryUsedMB
=
0
;
...
...
@@ -455,3 +464,12 @@ void monitorExecuteSQL(char *sql) {
monitorTrace
(
"monitor:%p, execute sql: %s"
,
monitor
->
conn
,
sql
);
taos_query_a
(
monitor
->
conn
,
sql
,
NULL
,
NULL
);
}
void
taosAuditRecord
(
int
level
,
char
*
dbuser
,
char
*
result
,
char
*
content
){
char
sqlcmd
[
1024
]
=
{
0
};
int64_t
ts
=
taosGetTimestampUs
();
int
pos
=
snprintf
(
sqlcmd
,
SQL_LENGTH
,
"insert into audit.audit values(%"
PRId64
,
ts
);
pos
+=
snprintf
(
sqlcmd
+
pos
,
SQL_LENGTH
-
pos
,
", %d,
\'
%s
\'
,
\'
%s
\'
,
\'
%s
\'
)"
,
level
,
dbuser
,
result
,
content
);
taos_query_a
(
monitor
->
conn
,
sqlcmd
,
dnodeMontiorInsertAuditCallback
,
"audit"
);
}
\ No newline at end of file
src/system/detail/src/mgmtShell.c
浏览文件 @
126baf46
...
...
@@ -201,7 +201,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
char
db
[
TSDB_DB_NAME_LEN
+
1
]
=
{
0
};
extractDBName
(
pInfo
->
meterId
,
db
);
if
(
strncasecmp
(
db
,
"audit"
,
5
)
==
0
&&
pConn
->
pUser
->
auditAuth
==
0
&&
pConn
->
pUser
->
superAuth
==
0
)
{
if
(
strncasecmp
(
db
,
"audit"
,
5
)
==
0
&&
pConn
->
pUser
->
auditAuth
==
0
&&
pConn
->
pUser
->
superAuth
==
0
&&
strncasecmp
(
pConn
->
pUser
->
user
,
"monitor"
,
7
)
!=
0
)
{
if
((
pStart
=
mgmtAllocMsg
(
pConn
,
size
,
&
pMsg
,
&
pRsp
))
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METERINFO_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
0
;
...
...
@@ -215,7 +215,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METERINFO_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
0
;
}
pRsp
->
code
=
TSDB_CODE_NO_R
EAD_ACCES
S
;
pRsp
->
code
=
TSDB_CODE_NO_R
IGHT
S
;
pMsg
++
;
goto
_exit_code
;
}
...
...
@@ -590,6 +590,9 @@ int mgmtProcessCreateDbMsg(char *pMsg, int msgLen, SConnObj *pConn) {
code
=
mgmtCreateDb
(
pConn
->
pAcct
,
pCreate
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"DB:%s is created by %s"
,
pCreate
->
db
,
pConn
->
pUser
->
user
);
char
content
[
1024
];
sprintf
(
content
,
"DB:%s is created by %s"
,
pCreate
->
db
,
pConn
->
pUser
->
user
);
taosAuditRecord
(
AUDIT_INFO
,
pConn
->
pUser
->
user
,
"success"
,
content
);
}
}
...
...
@@ -620,6 +623,9 @@ int mgmtProcessAlterDbMsg(char *pMsg, int msgLen, SConnObj *pConn) {
code
=
mgmtAlterDb
(
pConn
->
pAcct
,
pAlter
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"DB:%s is altered by %s"
,
pAlter
->
db
,
pConn
->
pUser
->
user
);
char
content
[
1024
];
sprintf
(
content
,
"DB:%s is altered by %s"
,
pAlter
->
db
,
pConn
->
pUser
->
user
);
taosAuditRecord
(
AUDIT_INFO
,
pConn
->
pUser
->
user
,
"success"
,
content
);
}
}
...
...
@@ -685,6 +691,9 @@ int mgmtProcessCreateUserMsg(char *pMsg, int msgLen, SConnObj *pConn) {
code
=
mgmtCreateUser
(
pConn
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s is created by %s"
,
pCreate
->
user
,
pConn
->
pUser
->
user
);
char
content
[
1024
];
sprintf
(
content
,
"user:%s is created by %s"
,
pCreate
->
user
,
pConn
->
pUser
->
user
);
taosAuditRecord
(
AUDIT_INFO
,
pConn
->
pUser
->
user
,
"success"
,
content
);
}
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
...
...
@@ -745,6 +754,9 @@ int mgmtProcessAlterUserMsg(char *pMsg, int msgLen, SConnObj *pConn) {
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
code
=
mgmtUpdateUser
(
pUser
);
mLPrint
(
"user:%s password is altered by %s, code:%d"
,
pAlter
->
user
,
pConn
->
pUser
->
user
,
code
);
char
content
[
1024
];
sprintf
(
content
,
"user:%s password is altered by %s, code:%d"
,
pAlter
->
user
,
pConn
->
pUser
->
user
,
code
);
taosAuditRecord
(
AUDIT_INFO
,
pConn
->
pUser
->
user
,
"success"
,
content
);
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录