Skip to content

Commit

Permalink
cfg - add tpool and webhook debugs config controls
Browse files Browse the repository at this point in the history
  • Loading branch information
astibal committed Jul 4, 2024
1 parent 9ebe333 commit 31834df
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/service/cfgapi/cfgapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ bool CfgFactory::upgrade_schema(int upgrade_to_num) {
log.event(INF, "added tls_profile.[x].alerts");
return true;
}
else if(upgrade_to_num == 1032) {
log.event(INF, "added settings.tpool_log");
log.event(INF, "added settings.webhook.task_debug");
log.event(INF, "added settings.webhook.task_debug_dump");
return true;
}

return false;
}
Expand Down Expand Up @@ -688,6 +694,10 @@ bool CfgFactory::load_settings () {
load_if_exists(cfgapi.getRoot()["settings"], "dtls_port",listen_dtls_port_base); listen_dtls_port = listen_dtls_port_base;
load_if_exists(cfgapi.getRoot()["settings"], "dtls_workers",num_workers_dtls);

bool collect_val = false;
load_if_exists(cfgapi.getRoot()["settings"], "tpool_log", collect_val);
sx::tp::ThreadPool::collect_tasks_info = collect_val;


if(cfgapi.getRoot()["settings"].exists("nameservers")) {

Expand Down Expand Up @@ -905,6 +915,9 @@ bool CfgFactory::load_settings () {
load_if_exists(cfgapi.getRoot()["settings"]["webhook"], "nbr_update_interval", settings_webhook.nbr_update_interval);
load_if_exists(cfgapi.getRoot()["settings"]["webhook"], "nbr_tag_refresh_age", settings_webhook.nbr_tag_refresh_age);

load_if_exists(cfgapi.getRoot()["settings"]["webhook"], "task_debug", sx::http::Request::DEBUG);
load_if_exists(cfgapi.getRoot()["settings"]["webhook"], "task_debug_dump", sx::http::Request::DEBUG_DUMP_OK);

if(not settings_webhook.hostid.empty()) sx::http::webhooks::set_hostid(settings_webhook.hostid);
}

Expand Down Expand Up @@ -5027,6 +5040,8 @@ int save_settings(Config& ex) {
objects.add("dtls_port", Setting::TypeString) = CfgFactory::get()->listen_dtls_port_base;
objects.add("dtls_workers", Setting::TypeInt) = CfgFactory::get()->num_workers_dtls;

objects.add("tpool_log", Setting::TypeBoolean) = sx::tp::ThreadPool::collect_tasks_info;

//udp quick ports
Setting& it_quick = objects.add("udp_quick_ports", Setting::TypeArray);
if(CfgFactory::get()->db_udp_quick_ports.empty()) {
Expand Down Expand Up @@ -5117,6 +5132,10 @@ int save_settings(Config& ex) {
webhook_objects.add("ping_interval", Setting::TypeInt) = (int)CfgFactory::get()->settings_webhook.ping_interval;
webhook_objects.add("nbr_update_interval", Setting::TypeInt) = CfgFactory::get()->settings_webhook.nbr_update_interval;
webhook_objects.add("nbr_tag_refresh_age", Setting::TypeInt) = CfgFactory::get()->settings_webhook.nbr_tag_refresh_age;

webhook_objects.add("task_debug", Setting::TypeBoolean) = sx::http::Request::DEBUG;
webhook_objects.add("task_debug_dump", Setting::TypeBoolean) = sx::http::Request::DEBUG_DUMP_OK;

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/cfgapi/cfgapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class CfgFactory : public CfgFactoryBase {
public:
// Each version bump implies a config upgrade - we start on 1000
// see upgrade_schema() - control config upgrade
constexpr static inline const int SCHEMA_VERSION = 1031;
constexpr static inline const int SCHEMA_VERSION = 1032;

static inline std::atomic_bool LOAD_ERRORS = false;

Expand Down
65 changes: 60 additions & 5 deletions src/service/cfgapi/cfgvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ void CfgValueHelp::init() {
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("settings.admin", "administration options");
add("settings.admin.group", "system group with granted access; empty means root.")
.help_quick("<string>: existing group name")
.may_be_empty(true);

add("settings.http_api", "API access options");
add("settings.http_api.keys", "API access keys to retrieve API access tokens");
add("settings.http_api.key_timeout", "Expiration timeout for session tokens")
Expand Down Expand Up @@ -434,11 +439,6 @@ void CfgValueHelp::init() {
.value_filter(CfgValue::VALUE_BOOL);


add("settings.admin", "administration options");
add("settings.admin.group", "system group with granted access; empty means root.")
.help_quick("<string>: existing group name")
.may_be_empty(true);

add("settings.http_api.key_extend_on_access", "If set, tokens are refreshed when used")
.help_quick("<bool>: set true to refresh tokens when used (default: true)")
.may_be_empty(false)
Expand All @@ -450,6 +450,61 @@ void CfgValueHelp::init() {
.value_filter(CfgValue::VALUE_BOOL);


add("settings.webhook.enabled", "enable sending http(s) webhooks updates to compatible service")
.help_quick("<bool>: set true to enable (default: false)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("settings.webhook.url", "http(s) webhook service URL")
.help_quick("<bool>: set true to enable (default: false)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_ANY);

add("settings.webhook.tls_verify", "https webhooks service certificate validity check")
.help_quick("<bool>: set false to disable - not recommended (default: true)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("settings.webhook.hostid", "webhook identity value override")
.help_quick("<string>: override hostid string to custom value (default: <hostname>)")
.may_be_empty(true)
.value_filter(CfgValue::VALUE_ANY);

add("settings.webhook.bind_interface", "bind updates to custom interface (ie. to work with VRFs)")
.help_quick("<string>: interface name (default: <hostname>)")
.may_be_empty(true)
.value_filter(CfgValue::VALUE_ANY);

add("settings.webhook.api_override", "override temporarily webhook URL (even empty) via API from your app")
.help_quick("<bool>: set true to enable (default: false)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("settings.webhook.ping_interval", "send ping + info each <interval> seconds")
.help_quick("<int>: set custom value - not recommended (default: 120s)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_UINT);

add("settings.webhook.nbr_update_interval", "send neighbor update each <interval> seconds")
.help_quick("<int>: set custom value - not recommended (default: 120s)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_UINT);

add("settings.webhook.nbr_tag_refresh_age", "request neighbor tags update each <interval> seconds")
.help_quick("<int>: set custom value - not recommended (default: 180s)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_UINT);

add("settings.webhook.task_debug", "collect debug information for webhook thread tasks")
.help_quick("<bool>: set true to enable - (small performance hit) (default: false)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("settings.webhook.task_debug_dump", "collect debug dumps for webhook thread tasks")
.help_quick("<bool>: set true to enable - (performance hit likely) (default: false)")
.may_be_empty(false)
.value_filter(CfgValue::VALUE_BOOL);

add("debug.log_data_crc", "calculate received CRC data (helps to identify proxy bugs)");

add("proto_objects", "IP protocols")
Expand Down

0 comments on commit 31834df

Please sign in to comment.