diff options
| author | lijia <[email protected]> | 2020-11-12 22:29:33 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2020-11-12 22:29:33 +0800 |
| commit | 80eeac67ec031a6d040858678bd0c266683fa669 (patch) | |
| tree | 91dfc65bec83938fbd6c996426c62054a22d2587 | |
| parent | f51e78467a0a50b1b89bd2ab77e6f660d5357c13 (diff) | |
支持prometheus状态监控.v4.1.16
Conflicts:
src/config/config_parse.cpp
| -rw-r--r-- | bin/etc/sapp.toml | 5 | ||||
| -rw-r--r-- | include/private/sapp_global_val.h | 8 | ||||
| -rw-r--r-- | src/config/config_parse.cpp | 6 | ||||
| -rw-r--r-- | src/entry/sapp_main.c | 2 | ||||
| -rw-r--r-- | src/inner_plug/g_device_plug.c | 2 | ||||
| -rw-r--r-- | src/inner_plug/sapp_assistant.cpp | 16 |
6 files changed, 37 insertions, 2 deletions
diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml index 1023c98..8c35b33 100644 --- a/bin/etc/sapp.toml +++ b/bin/etc/sapp.toml @@ -136,6 +136,11 @@ dictator_enable=1 ### note, metric_type option value: [default, json] metric_type = default app_name=sapp + + [profiling.log.prometheus] + prometheus_enabled=1 + prometheus_port=9273 + prometheus_url_path="/metrics" [TOOLS] [tools.pkt_dump] diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h index c225537..189a643 100644 --- a/include/private/sapp_global_val.h +++ b/include/private/sapp_global_val.h @@ -138,12 +138,20 @@ typedef struct{ sapp_config_profiling_log_remote_field_stat2_t field_stat2; }sapp_config_profiling_log_remote_t; +typedef struct{ + int enabled; + int port; /* host order */ + char url_path[NAME_MAX]; +}sapp_config_profiling_log_prometheus_t; + + typedef struct{ int level; int interval; sapp_config_profiling_log_local_t local; sapp_config_profiling_log_remote_t remote; + sapp_config_profiling_log_prometheus_t prometheus; }sapp_config_profiling_log_t; diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp index 6d940ea..97843aa 100644 --- a/src/config/config_parse.cpp +++ b/src/config/config_parse.cpp @@ -710,6 +710,12 @@ int sapp_parse_config(void) tomlc99_wrap_load_int_def(default_config_file, (char *)"profiling.log.remote", (char *)"enabled", (int *)&pconfig->profiling.log.remote.enabled, 0); tomlc99_wrap_load_string_def(default_config_file, (char *)"profiling.log.remote", (char *)"server_ip", pconfig->profiling.log.remote.server_ip, INET_ADDRSTRLEN, "#"); tomlc99_wrap_load_int_def(default_config_file, (char *)"profiling.log.remote", (char *)"server_port", (int *)&pconfig->profiling.log.remote.server_port, 0); + /******************************* PROFILING.LOG.prometheus **********************/ + tomlc99_wrap_load_int_def(default_config_file, (char *)"profiling.log.prometheus", (char *)"prometheus_enabled", (int *)&pconfig->profiling.log.prometheus.enabled, 1); + tomlc99_wrap_load_int_def(default_config_file, (char *)"profiling.log.prometheus", (char *)"prometheus_port", (int *)&pconfig->profiling.log.prometheus.port, 9273); + tomlc99_wrap_load_string_def(default_config_file, (char *)"profiling.log.prometheus", (char *)"prometheus_url_path", pconfig->profiling.log.prometheus.url_path, NAME_MAX, "/metrics"); + + #if 0 //tomlc99_wrap_load_string_def(default_config_file, (char *)"profiling.log.remote", (char *)"remote_send_out_type", pconfig->profiling.log.remote.remote_send_out_type, NAME_MAX, "field_stat2"); /******************************* PROFILING.LOG.remote.field_stat2 **********************/ diff --git a/src/entry/sapp_main.c b/src/entry/sapp_main.c index 4502e06..9835518 100644 --- a/src/entry/sapp_main.c +++ b/src/entry/sapp_main.c @@ -5,7 +5,7 @@ extern "C" { #endif -const unsigned char MESA_art_log[] = +static const unsigned char MESA_art_log[] = { 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x5F, 0x5F, 0x20, 0x20, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, diff --git a/src/inner_plug/g_device_plug.c b/src/inner_plug/g_device_plug.c index 757b334..cfd9550 100644 --- a/src/inner_plug/g_device_plug.c +++ b/src/inner_plug/g_device_plug.c @@ -460,7 +460,7 @@ static void *gdev_keepalive_log_thread(void *arg) continue; } platform_thread_num = get_thread_count(); - timet_to_str(g_CurrentTime, cur_time_str, 64); + timet_to_str(time(NULL), cur_time_str, 64); fprintf(gdev_status_fp, "%-20s %-16s %-11s %-5s %-5s %-16s %-16s\n", "Last-update-time", "Gdev-ip", "Service-Num", "Ctrl", "Type", "Rcv-pkt", "Snd-pkt"); diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp index 8d041a9..463a5f7 100644 --- a/src/inner_plug/sapp_assistant.cpp +++ b/src/inner_plug/sapp_assistant.cpp @@ -899,6 +899,17 @@ static int sapp_fs2_init(void) return -1; } + if(sapp_global_val->config.profiling.log.prometheus.enabled){ + FS_library_set_prometheus_port((unsigned short)sapp_global_val->config.profiling.log.prometheus.port); + FS_library_set_prometheus_url_path(sapp_global_val->config.profiling.log.prometheus.url_path); + if(FS_library_init() < 0){ + sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n", + sapp_global_val->config.profiling.log.prometheus.port, + sapp_global_val->config.profiling.log.prometheus.url_path); + return -1; + } + } + fs2_handle = sapp_global_val->individual_fixed.field_stat2_para.field_stat2_handle; if(fs2_remote_enabled){ sapp_global_val->individual_fixed.profiling_log_remote_handle = fs2_handle; @@ -933,6 +944,11 @@ static int sapp_fs2_init(void) } FS_set_para(fs2_handle, METRIS_FORMAT, &sapp_global_val->config.profiling.log.remote.field_stat2.metrics_type, sizeof(int)); + + if(sapp_global_val->config.profiling.log.prometheus.enabled){ + fs2_opt = 1; + FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int)); + } pfs_para->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt"); pfs_para->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit"); |
