mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 05:56:21 +00:00
PG-174: Code cleanup.
This commit is contained in:
251
guc.c
251
guc.c
@@ -19,6 +19,8 @@
|
||||
#include "pg_stat_monitor.h"
|
||||
|
||||
GucVariable conf[13];
|
||||
static void DefineIntGUC(GucVariable *conf);
|
||||
static void DefineBoolGUC(GucVariable *conf);
|
||||
|
||||
/*
|
||||
* Define (or redefine) custom GUC variables.
|
||||
@@ -27,253 +29,178 @@ void
|
||||
init_guc(void)
|
||||
{
|
||||
int i = 0;
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_max",
|
||||
.guc_desc = "Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor.",
|
||||
.guc_default = 100,
|
||||
.guc_min = 1,
|
||||
.guc_max = 1000,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = GUC_UNIT_MB,
|
||||
.guc_value = &PGSM_MAX
|
||||
};
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_query_max_len",
|
||||
.guc_desc = "Sets the maximum length of query.",
|
||||
.guc_default = 1024,
|
||||
.guc_min = 1024,
|
||||
.guc_max = INT_MAX,
|
||||
.guc_restart = true
|
||||
.guc_unit = 0,
|
||||
.guc_restart = true,
|
||||
.guc_value = &PGSM_QUERY_MAX_LEN
|
||||
};
|
||||
conf[i++] = (GucVariable) {
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_enable",
|
||||
.guc_desc = "Enable/Disable statistics collector.",
|
||||
.guc_default = 1,
|
||||
.guc_min = 0,
|
||||
.guc_max = 0,
|
||||
.guc_restart = true
|
||||
.guc_restart = false,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_ENABLED
|
||||
};
|
||||
conf[i++] = (GucVariable) {
|
||||
DefineBoolGUC(&conf[i++]);
|
||||
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_track_utility",
|
||||
.guc_desc = "Selects whether utility commands are tracked.",
|
||||
.guc_default = 0,
|
||||
.guc_min = 0,
|
||||
.guc_max = 0,
|
||||
.guc_restart = false
|
||||
.guc_restart = false,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_TRACK_UTILITY
|
||||
};
|
||||
DefineBoolGUC(&conf[i++]);
|
||||
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_normalized_query",
|
||||
.guc_desc = "Selects whether save query in normalized format.",
|
||||
.guc_default = 1,
|
||||
.guc_min = 0,
|
||||
.guc_max = 0,
|
||||
.guc_restart = false
|
||||
.guc_restart = false,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_NORMALIZED_QUERY
|
||||
};
|
||||
conf[i++] = (GucVariable) {
|
||||
DefineBoolGUC(&conf[i++]);
|
||||
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_max_buckets",
|
||||
.guc_desc = "Sets the maximum number of buckets.",
|
||||
.guc_default = 10,
|
||||
.guc_min = 1,
|
||||
.guc_max = 10,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_MAX_BUCKETS
|
||||
};
|
||||
conf[i++] = (GucVariable) {
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_bucket_time",
|
||||
.guc_desc = "Sets the time in seconds per bucket.",
|
||||
.guc_default = 60,
|
||||
.guc_min = 1,
|
||||
.guc_max = INT_MAX,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_BUCKET_TIME
|
||||
};
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_histogram_min",
|
||||
.guc_desc = "Sets the time in millisecond.",
|
||||
.guc_default = 0,
|
||||
.guc_min = 0,
|
||||
.guc_max = INT_MAX,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_HISTOGRAM_MIN
|
||||
};
|
||||
conf[i++] = (GucVariable) {
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_histogram_max",
|
||||
.guc_desc = "Sets the time in millisecond.",
|
||||
.guc_default = 10,
|
||||
.guc_min = 10,
|
||||
.guc_max = INT_MAX,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_HISTOGRAM_MAX
|
||||
};
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_histogram_buckets",
|
||||
.guc_desc = "Sets the maximum number of histogram buckets",
|
||||
.guc_default = 10,
|
||||
.guc_min = 2,
|
||||
.guc_max = INT_MAX,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_HISTOGRAM_BUCKETS
|
||||
};
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_query_shared_buffer",
|
||||
.guc_desc = "Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor.",
|
||||
.guc_default = 20,
|
||||
.guc_min = 1,
|
||||
.guc_max = 10000,
|
||||
.guc_restart = true
|
||||
.guc_restart = true,
|
||||
.guc_unit = GUC_UNIT_MB,
|
||||
.guc_value = &PGSM_QUERY_SHARED_BUFFER
|
||||
};
|
||||
DefineIntGUC(&conf[i++]);
|
||||
|
||||
#if PG_VERSION_NUM >= 130000
|
||||
conf[i++] = (GucVariable) {
|
||||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_track_planning",
|
||||
.guc_desc = "Selects whether planning statistics are tracked.",
|
||||
.guc_default = 1,
|
||||
.guc_min = 0,
|
||||
.guc_max = 0,
|
||||
.guc_restart = false
|
||||
.guc_restart = false,
|
||||
.guc_unit = 0,
|
||||
.guc_value = &PGSM_TRACK_PLANNING
|
||||
};
|
||||
DefineBoolGUC(&conf[i++]);
|
||||
#endif
|
||||
}
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_max",
|
||||
"Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor.",
|
||||
static void
|
||||
DefineIntGUC(GucVariable *conf)
|
||||
{
|
||||
DefineCustomIntVariable(conf->guc_name,
|
||||
conf->guc_desc,
|
||||
NULL,
|
||||
&PGSM_MAX,
|
||||
100,
|
||||
1,
|
||||
1000,
|
||||
PGC_POSTMASTER,
|
||||
GUC_UNIT_MB,
|
||||
conf->guc_value,
|
||||
conf->guc_default,
|
||||
conf->guc_min,
|
||||
conf->guc_max,
|
||||
conf->guc_restart ? PGC_POSTMASTER : PGC_USERSET,
|
||||
conf->guc_unit,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_query_max_len",
|
||||
"Sets the maximum length of query.",
|
||||
}
|
||||
static void
|
||||
DefineBoolGUC(GucVariable *conf)
|
||||
{
|
||||
DefineCustomBoolVariable(conf->guc_name,
|
||||
conf->guc_desc,
|
||||
NULL,
|
||||
&PGSM_QUERY_MAX_LEN,
|
||||
1024,
|
||||
1024,
|
||||
INT_MAX,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_enable",
|
||||
"Enable/Disable statistics collector.",
|
||||
NULL,
|
||||
(bool*)&PGSM_ENABLED,
|
||||
true,
|
||||
PGC_USERSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_track_utility",
|
||||
"Selects whether utility commands are tracked by pg_stat_monitor.",
|
||||
NULL,
|
||||
(bool*)&PGSM_TRACK_UTILITY,
|
||||
true,
|
||||
PGC_USERSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_normalized_query",
|
||||
"Selects whether save query in normalized format.",
|
||||
NULL,
|
||||
(bool*)&PGSM_NORMALIZED_QUERY,
|
||||
true,
|
||||
PGC_USERSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_max_buckets",
|
||||
"Sets the maximum number of buckets.",
|
||||
NULL,
|
||||
&PGSM_MAX_BUCKETS,
|
||||
10,
|
||||
1,
|
||||
10,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_bucket_time",
|
||||
"Sets the time in seconds per bucket.",
|
||||
NULL,
|
||||
&PGSM_BUCKET_TIME,
|
||||
60,
|
||||
1,
|
||||
INT_MAX,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_histogram_min",
|
||||
"Sets the time in millisecond.",
|
||||
NULL,
|
||||
&PGSM_HISTOGRAM_MIN,
|
||||
0,
|
||||
0,
|
||||
INT_MAX,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_histogram_max",
|
||||
"Sets the time in millisecond.",
|
||||
NULL,
|
||||
&PGSM_HISTOGRAM_MAX,
|
||||
10,
|
||||
10,
|
||||
INT_MAX,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_histogram_buckets",
|
||||
"Sets the total number of histogram buckets",
|
||||
NULL,
|
||||
&PGSM_HISTOGRAM_BUCKETS,
|
||||
10,
|
||||
2,
|
||||
INT_MAX,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_query_shared_buffer",
|
||||
"Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor.",
|
||||
NULL,
|
||||
&PGSM_QUERY_BUF_SIZE,
|
||||
20,
|
||||
1,
|
||||
10000,
|
||||
PGC_POSTMASTER,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_track_planning",
|
||||
"Selects whether track planning statistics.",
|
||||
NULL,
|
||||
(bool*)&PGSM_TRACK_PLANNING,
|
||||
true,
|
||||
PGC_SUSET,
|
||||
(bool*)conf->guc_value,
|
||||
conf->guc_default,
|
||||
conf->guc_restart ? PGC_POSTMASTER : PGC_USERSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
Reference in New Issue
Block a user