From b585766fda61b3a68bc236d6042438becd3d453f Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 2 Nov 2021 14:25:30 +0800 Subject: [PATCH] [TD-6452]: taoskeeper add HTTP status codes --- src/inc/monitor.h | 68 +++++++++++++++++++++++++++++++ src/plugins/monitor/src/monMain.c | 25 +++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/src/inc/monitor.h b/src/inc/monitor.h index 1ac8151672..d751c408d9 100644 --- a/src/inc/monitor.h +++ b/src/inc/monitor.h @@ -27,6 +27,74 @@ extern "C" { monSaveDnodeLog(level, __VA_ARGS__); \ } +#define MON_MAX_HTTP_CODE 63 + +static const char *monHttpStatusCodeTable[MON_MAX_HTTP_CODE][2] = { + {"HTTP_CODE_CONTINUE", "100"}, + {"HTTP_CODE_SWITCHING_PROTOCOL", "101"}, + {"HTTP_CODE_PROCESSING", "102"}, + {"HTTP_CODE_EARLY_HINTS", "103"}, + {"HTTP_CODE_OK", "200"}, + {"HTTP_CODE_CREATED", "201"}, + {"HTTP_CODE_ACCEPTED", "202"}, + {"HTTP_CODE_NON_AUTHORITATIVE_INFO", "203"}, + {"HTTP_CODE_NO_CONTENT", "204"}, + {"HTTP_CODE_RESET_CONTENT", "205"}, + {"HTTP_CODE_PARTIAL_CONTENT", "206"}, + {"HTTP_CODE_MULTI_STATUS", "207"}, + {"HTTP_CODE_ALREADY_REPORTED", "208"}, + {"HTTP_CODE_IM_USED", "226"}, + {"HTTP_CODE_MULTIPLE_CHOICE", "300"}, + {"HTTP_CODE_MOVED_PERMANENTLY", "301"}, + {"HTTP_CODE_FOUND", "302"}, + {"HTTP_CODE_SEE_OTHER", "303"}, + {"HTTP_CODE_NOT_MODIFIED", "304"}, + {"HTTP_CODE_USE_PROXY", "305"}, + {"HTTP_CODE_UNUSED", "306"}, + {"HTTP_CODE_TEMPORARY_REDIRECT", "307"}, + {"HTTP_CODE_PERMANENT_REDIRECT", "308"}, + {"HTTP_CODE_BAD_REQUEST", "400"}, + {"HTTP_CODE_UNAUTHORIZED", "401"}, + {"HTTP_CODE_PAYMENT_REQUIRED", "402"}, + {"HTTP_CODE_FORBIDDEN", "403"}, + {"HTTP_CODE_NOT_FOUND", "404"}, + {"HTTP_CODE_METHOD_NOT_ALLOWED", "405"}, + {"HTTP_CODE_NOT_ACCEPTABLE", "406"}, + {"HTTP_CODE_PROXY_AUTH_REQUIRED", "407"}, + {"HTTP_CODE_REQUEST_TIMEOUT", "408"}, + {"HTTP_CODE_CONFLICT", "409"}, + {"HTTP_CODE_GONE", "410"}, + {"HTTP_CODE_LENGTH_REQUIRED", "411"}, + {"HTTP_CODE_PRECONDITION_FAILED", "412"}, + {"HTTP_CODE_PAYLOAD_TOO_LARGE", "413"}, + {"HTTP_CODE_URI_TOO_LARGE", "414"}, + {"HTTP_CODE_UNSUPPORTED_MEDIA_TYPE", "415"}, + {"HTTP_CODE_RANGE_NOT_SATISFIABLE", "416"}, + {"HTTP_CODE_EXPECTATION_FAILED", "417"}, + {"HTTP_CODE_IM_A_TEAPOT", "418"}, + {"HTTP_CODE_MISDIRECTED_REQUEST", "421"}, + {"HTTP_CODE_UNPROCESSABLE_ENTITY", "422"}, + {"HTTP_CODE_LOCKED", "423"}, + {"HTTP_CODE_FAILED_DEPENDENCY", "424"}, + {"HTTP_CODE_TOO_EARLY", "425"}, + {"HTTP_CODE_UPGRADE_REQUIRED", "426"}, + {"HTTP_CODE_PRECONDITION_REQUIRED", "428"}, + {"HTTP_CODE_TOO_MANY_REQUESTS", "429"}, + {"HTTP_CODE_REQ_HDR_FIELDS_TOO_LARGE","431"}, + {"HTTP_CODE_UNAVAIL_4_LEGAL_REASONS", "451"}, + {"HTTP_CODE_INTERNAL_SERVER_ERROR", "500"}, + {"HTTP_CODE_NOT_IMPLEMENTED", "501"}, + {"HTTP_CODE_BAD_GATEWAY", "502"}, + {"HTTP_CODE_SERVICE_UNAVAILABLE", "503"}, + {"HTTP_CODE_GATEWAY_TIMEOUT", "504"}, + {"HTTP_CODE_HTTP_VER_NOT_SUPPORTED", "505"}, + {"HTTP_CODE_VARIANT_ALSO_NEGOTIATES", "506"}, + {"HTTP_CODE_INSUFFICIENT_STORAGE", "507"}, + {"HTTP_CODE_LOOP_DETECTED", "508"}, + {"HTTP_CODE_NOT_EXTENDED", "510"}, + {"HTTP_CODE_NETWORK_AUTH_REQUIRED", "511"}, +}; + typedef struct { char * acctId; int64_t currentPointsPerSecond; diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 9c6ca2a17f..085e30ece0 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -63,6 +63,8 @@ typedef enum { MON_CMD_CREATE_MT_LOGS, MON_CMD_CREATE_TB_DNODE_LOG, MON_CMD_CREATE_TB_GRANTS, + MON_CMD_CREATE_MT_RESTFUL, + MON_CMD_CREATE_TB_RESTFUL, MON_CMD_MAX } EMonCmd; @@ -344,7 +346,28 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) { "create table if not exists %s.grants_info(ts timestamp" ", expire_time binary(%d), timeseries binary(%d))", tsMonitorDbName, MAX_EXPIRE_TIME_LEN, MAX_TIMESERIES_LEN); - } + } else if (cmd == MON_CMD_CREATE_MT_RESTFUL) { + snprintf(sql, SQL_LENGTH, + "create table if not exists %s.restful_info(ts timestamp" + ", uptime float" + ", cpu_engine float, cpu_system float, cpu_cores int" + ", mem_engine float, mem_system float, mem_total float" + ", disk_engine float, disk_used float, disk_total float" + ", net_in float, net_out float" + ", io_read float, io_write float" + ", req_http int, req_http_rate float" + ", req_select int, req_select_rate float" + ", req_insert int, req_insert_success int, req_insert_rate float" + ", req_insert_batch int, req_insert_batch_sucesss int, req_insert_batch_rate float" + ", errors int" + ", vnodes_num int" + ", masters int" + ", has_mnode bool" + ") tags (dnode_id int, dnode_ep binary(%d))", + tsMonitorDbName, TSDB_EP_LEN); + } else if (cmd == MON_CMD_CREATE_TB_RESTFUL) { + snprintf(sql, SQL_LENGTH, "create table if not exists %s.restful_%d using %s.restful_info tags(%d, '%s')", tsMonitorDbName, + dnodeGetDnodeId(), tsMonitorDbName, dnodeGetDnodeId(), tsLocalEp); sql[SQL_LENGTH] = 0; } -- GitLab