Calculate percentage of blocked queries only of there is at least one blocked query to prevent division-by-zero issues (leading to None)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
4ac52263e9
commit
a9e93ba1f8
|
@ -417,7 +417,11 @@ int api_stats_database_summary(struct ftl_conn *api)
|
|||
"WHERE timestamp >= :from AND timestamp <= :until";
|
||||
const int total_clients = db_query_int_from_until(db, querystr, from, until);
|
||||
|
||||
const float percent_blocked = 1e2f*sum_blocked/sum_queries;
|
||||
// Calculate percentage of blocked queries, substituting 0.0 if there
|
||||
// are no blocked queries
|
||||
float percent_blocked = 0.0;
|
||||
if(sum_queries > 0.0)
|
||||
percent_blocked = 1e2f*sum_blocked/sum_queries;
|
||||
|
||||
if(sum_queries < 0 || sum_blocked < 0 || total_clients < 0)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,9 @@ void set_all_debug(const bool status)
|
|||
// Set status
|
||||
conf_item->v.b = status;
|
||||
}
|
||||
|
||||
// Update debug flags
|
||||
set_debug_flags();
|
||||
}
|
||||
|
||||
// Extract and store key from full path
|
||||
|
|
|
@ -821,7 +821,7 @@ static void readDebugingSettingsLegacy(FILE *fp)
|
|||
}
|
||||
|
||||
// Parse debug options
|
||||
parse_debug_options();
|
||||
set_debug_flags();
|
||||
|
||||
if(debug_any)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ bool readFTLtoml(void)
|
|||
}
|
||||
|
||||
// Report debug config if enabled
|
||||
parse_debug_options();
|
||||
set_debug_flags();
|
||||
reportDebugConfig();
|
||||
|
||||
// Free memory allocated by the TOML parser and return success
|
||||
|
|
|
@ -30,7 +30,10 @@ static const char *process = "";
|
|||
bool debug_any = false;
|
||||
bool debug_flags[DEBUG_MAX] = { false };
|
||||
|
||||
void parse_debug_options(void)
|
||||
// Set debug flags from config struct to global debug_flags array
|
||||
// This is called whenever the config is reloaded and debug flags may have
|
||||
// changed
|
||||
void set_debug_flags(void)
|
||||
{
|
||||
// Reset debug flags
|
||||
debug_any = false;
|
||||
|
|
Loading…
Reference in New Issue