mirror of
https://github.com/emqx/neuron.git
synced 2026-10-30 07:45:59 +08:00
Compare commits
20
Commits
v2.8-batch
...
2.4.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f6d9d1c41 | ||
|
|
3f75222410 | ||
|
|
ddf5d252f6 | ||
|
|
6e467f5f27 | ||
|
|
fd1266bc9e | ||
|
|
d8b605ef1c | ||
|
|
c9122b5b7c | ||
|
|
8c11cb3466 | ||
|
|
80680c55f5 | ||
|
|
132c25b4ad | ||
|
|
cc7e5d092a | ||
|
|
2e3f6d6db2 | ||
|
|
43a95b7910 | ||
|
|
053be086b0 | ||
|
|
66dba0f69a | ||
|
|
c6752c5761 | ||
|
|
53f5c496ea | ||
|
|
1e28e4bc0e | ||
|
|
2bbcc6a154 | ||
|
|
00d6418288 |
@@ -7,6 +7,11 @@ on:
|
||||
types:
|
||||
- published
|
||||
|
||||
|
||||
env:
|
||||
BRANCH: v2.4
|
||||
|
||||
|
||||
jobs:
|
||||
clang_format_check:
|
||||
runs-on: ubuntu-20.04
|
||||
@@ -40,7 +45,7 @@ jobs:
|
||||
|
||||
ut:
|
||||
runs-on: ubuntu-20.04
|
||||
container: neugates/build:x86_64-main
|
||||
container: ghcr.io/neugates/build:x86_64-v2.4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -61,7 +66,7 @@ jobs:
|
||||
|
||||
ft:
|
||||
runs-on: ubuntu-20.04
|
||||
container: neugates/build:x86_64-main
|
||||
container: ghcr.io/neugates/build:x86_64-v2.4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@@ -8,9 +8,9 @@ on:
|
||||
- published
|
||||
|
||||
env:
|
||||
VERSION: 2.4.0
|
||||
UI_VERSION: 2.4.0
|
||||
BRANCH: main
|
||||
VERSION: 2.4.1
|
||||
UI_VERSION: 2.4.1
|
||||
BRANCH: v2.4
|
||||
|
||||
jobs:
|
||||
cross-build:
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
- [aarch64-linux-gnu, aarch64, arm64]
|
||||
- [arm-linux-gnueabihf, armv4, armhf]
|
||||
- [x86_64-linux-gnu, x86_64, amd64]
|
||||
container: neugates/build:${{ matrix.arch[1] }}-main
|
||||
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-v2.4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
matrix:
|
||||
arch:
|
||||
- [x86_64-linux-gnu, x86_64, amd64]
|
||||
container: neugates/build:${{ matrix.arch[1] }}-main
|
||||
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-v2.4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@@ -9,5 +9,5 @@ file_format = "%d [%V] %f:%L %m%n"
|
||||
|
||||
[rules]
|
||||
|
||||
*.* "./logs/%c.log", 100MB * 10 ~ "./logs/%c.#2s.log"; file_format
|
||||
*.* "./logs/%c.log", 50MB * 1 ~ "./logs/%c.#2s.log"; file_format
|
||||
*.* >stdout; stdout_format
|
||||
|
||||
@@ -40,6 +40,12 @@ typedef enum neu_conn_tty_baud {
|
||||
NEU_CONN_TTY_BAUD_9600,
|
||||
NEU_CONN_TTY_BAUD_4800,
|
||||
NEU_CONN_TTY_BAUD_2400,
|
||||
NEU_CONN_TTY_BAUD_1800,
|
||||
NEU_CONN_TTY_BAUD_1200,
|
||||
NEU_CONN_TTY_BAUD_600,
|
||||
NEU_CONN_TTY_BAUD_300,
|
||||
NEU_CONN_TTY_BAUD_200,
|
||||
NEU_CONN_TTY_BAUD_150,
|
||||
} neu_conn_tty_baud_e;
|
||||
|
||||
typedef enum neu_conn_tty_parity {
|
||||
|
||||
@@ -32,6 +32,10 @@ static void plugin_group_free(neu_plugin_group_t *pgp);
|
||||
|
||||
int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
|
||||
{
|
||||
neu_adapter_update_metric_cb_t update_metric =
|
||||
plugin->common.adapter_callbacks->update_metric;
|
||||
int64_t rtt = NEU_METRIC_LAST_RTT_MS_MAX;
|
||||
|
||||
struct file_group_data *gd = NULL;
|
||||
int length = plugin->file_length;
|
||||
|
||||
@@ -83,6 +87,8 @@ int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
|
||||
strncpy(dvalue.value.str, buf, strlen(buf));
|
||||
fclose(f);
|
||||
|
||||
rtt = 1;
|
||||
|
||||
dvalue_result:
|
||||
plugin->common.adapter_callbacks->driver.update(
|
||||
plugin->common.adapter, group->group_name, tag->name, dvalue);
|
||||
@@ -90,6 +96,8 @@ int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
update_metric(plugin->common.adapter, NEU_METRIC_LAST_RTT_MS, rtt, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+15
-3
@@ -16,12 +16,24 @@
|
||||
"name_zh": "QoS 等级",
|
||||
"description": "MQTT QoS level for message delivery",
|
||||
"description_zh": "MQTT消息传输使用的服务质量等级",
|
||||
"type": "int",
|
||||
"type": "map",
|
||||
"attribute": "optional",
|
||||
"default": 0,
|
||||
"valid": {
|
||||
"min": 0,
|
||||
"max": 2
|
||||
"map": [
|
||||
{
|
||||
"key": "QoS 0",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"key": "QoS 1",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"key": "QoS 2",
|
||||
"value": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"format": {
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
#include "log_handle.h"
|
||||
#include "utils/utarray.h"
|
||||
|
||||
UT_array *collect_log_files();
|
||||
|
||||
void handle_logs_files(nng_aio *aio)
|
||||
{
|
||||
void * data = NULL;
|
||||
@@ -114,94 +112,43 @@ void handle_log_level(nng_aio *aio)
|
||||
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
|
||||
aio, neu_json_update_log_level_req_t,
|
||||
neu_json_decode_update_log_level_req, {
|
||||
char node_name[NEU_NODE_NAME_LEN] = { 0 };
|
||||
int ret = 0;
|
||||
neu_reqresp_head_t header = { 0 };
|
||||
neu_req_update_log_level_t cmd = { 0 };
|
||||
zlog_category_t * ct = zlog_get_category(req->node_name);
|
||||
zlog_category_t * neuron = zlog_get_category("neuron");
|
||||
|
||||
UT_array *log_files = collect_log_files();
|
||||
|
||||
utarray_foreach(log_files, char **, log_file)
|
||||
{
|
||||
if (strncmp(*log_file, req->node_name, strlen(*log_file) - 4) ==
|
||||
0) {
|
||||
strcpy(node_name, req->node_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(node_name) == 0) {
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_NODE_NOT_EXIST, {
|
||||
ret = zlog_level_switch(ct, ZLOG_LEVEL_DEBUG);
|
||||
if (ret != 0) {
|
||||
nlog_error("Modify node log level fail, node_name:%s, "
|
||||
"ret: %d,",
|
||||
req->node_name, ret);
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_EINTERNAL, {
|
||||
neu_http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
} else {
|
||||
int ret = 0;
|
||||
neu_reqresp_head_t header = { 0 };
|
||||
neu_req_update_log_level_t cmd = { 0 };
|
||||
zlog_category_t * ct = zlog_get_category(node_name);
|
||||
zlog_category_t * neuron = zlog_get_category("neuron");
|
||||
|
||||
ret = zlog_level_switch(ct, ZLOG_LEVEL_DEBUG);
|
||||
if (ret != 0) {
|
||||
nlog_error("Modify node log level fail, node_name:%s, "
|
||||
"ret: %d,",
|
||||
node_name, ret);
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_EINTERNAL, {
|
||||
neu_http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
}
|
||||
|
||||
ret = zlog_level_switch(neuron, ZLOG_LEVEL_DEBUG);
|
||||
if (ret != 0) {
|
||||
nlog_error("Modify neuron log level fail, ret: %d", ret);
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_EINTERNAL, {
|
||||
neu_http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
}
|
||||
|
||||
header.ctx = aio;
|
||||
header.type = NEU_REQ_UPDATE_LOG_LEVEL;
|
||||
strcpy(cmd.node, req->node_name);
|
||||
|
||||
ret = neu_plugin_op(plugin, header, &cmd);
|
||||
if (ret != 0) {
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
|
||||
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
utarray_free(log_files);
|
||||
ret = zlog_level_switch(neuron, ZLOG_LEVEL_DEBUG);
|
||||
if (ret != 0) {
|
||||
nlog_error("Modify neuron log level fail, ret: %d", ret);
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_EINTERNAL, {
|
||||
neu_http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
}
|
||||
|
||||
header.ctx = aio;
|
||||
header.type = NEU_REQ_UPDATE_LOG_LEVEL;
|
||||
strcpy(cmd.node, req->node_name);
|
||||
|
||||
ret = neu_plugin_op(plugin, header, &cmd);
|
||||
if (ret != 0) {
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
|
||||
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static inline bool ends_with(const char *str, const char *suffix)
|
||||
{
|
||||
size_t m = strlen(str);
|
||||
size_t n = strlen(suffix);
|
||||
return m >= n && !strcmp(str + m - n, suffix);
|
||||
}
|
||||
|
||||
UT_array *collect_log_files()
|
||||
{
|
||||
DIR *dp = opendir("./logs");
|
||||
if (NULL == dp) {
|
||||
nlog_error("open logs directory fail");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UT_array *log_files = NULL;
|
||||
utarray_new(log_files, &ut_str_icd);
|
||||
|
||||
struct dirent *de = NULL;
|
||||
while (NULL != (de = readdir(dp))) {
|
||||
char *name = de->d_name;
|
||||
if (ends_with(de->d_name, ".log")) {
|
||||
utarray_push_back(log_files, &name);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
|
||||
return log_files;
|
||||
}
|
||||
|
||||
int read_file(const char *file_name, void **datap, size_t *lenp)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -302,6 +302,8 @@ void neu_adapter_driver_write_tag(neu_adapter_driver_t *driver,
|
||||
(double) (cmd->value.value.d64 / tag->decimal);
|
||||
} else if (cmd->value.type == NEU_TYPE_DOUBLE) {
|
||||
cmd->value.value.d64 = cmd->value.value.d64 / tag->decimal;
|
||||
} else if (cmd->value.type == NEU_TYPE_FLOAT) {
|
||||
cmd->value.value.f32 = cmd->value.value.f32 / tag->decimal;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -360,8 +362,11 @@ void neu_adapter_driver_write_tag(neu_adapter_driver_t *driver,
|
||||
}
|
||||
break;
|
||||
case NEU_TYPE_FLOAT:
|
||||
cmd->value.type = NEU_TYPE_FLOAT;
|
||||
cmd->value.value.f32 = (float) cmd->value.value.d64;
|
||||
if (NEU_TYPE_FLOAT != cmd->value.type) {
|
||||
cmd->value.value.f32 = (float) cmd->value.value.d64;
|
||||
cmd->value.type = NEU_TYPE_FLOAT;
|
||||
}
|
||||
|
||||
switch (tag->option.value32.endian) {
|
||||
case NEU_DATATAG_ENDIAN_LB32:
|
||||
neu_ntohs_p((uint16_t *) cmd->value.value.bytes);
|
||||
|
||||
@@ -728,6 +728,30 @@ static void conn_connect(neu_conn_t *conn)
|
||||
cfsetospeed(&tty_opt, B2400);
|
||||
cfsetispeed(&tty_opt, B2400);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_1800:
|
||||
cfsetospeed(&tty_opt, B1800);
|
||||
cfsetispeed(&tty_opt, B1800);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_1200:
|
||||
cfsetospeed(&tty_opt, B1200);
|
||||
cfsetispeed(&tty_opt, B1200);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_600:
|
||||
cfsetospeed(&tty_opt, B600);
|
||||
cfsetispeed(&tty_opt, B600);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_300:
|
||||
cfsetospeed(&tty_opt, B300);
|
||||
cfsetispeed(&tty_opt, B300);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_200:
|
||||
cfsetospeed(&tty_opt, B200);
|
||||
cfsetispeed(&tty_opt, B200);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_150:
|
||||
cfsetospeed(&tty_opt, B150);
|
||||
cfsetispeed(&tty_opt, B150);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (conn->param.params.tty_client.parity) {
|
||||
|
||||
Reference in New Issue
Block a user