Issue - (#33): Display all the custom configuration parameters used for pg_stat_monitor.

A new view named (pg_stat_monitor_settings) is added to see all the custom
configuration parameters and its default, min, max, and type.
This commit is contained in:
Ibrar Ahmed
2020-05-25 11:58:22 +00:00
parent 6b5b2e0948
commit 5536041539
6 changed files with 272 additions and 85 deletions

136
guc.c
View File

@@ -12,17 +12,111 @@
#include "postgres.h"
#include "pg_stat_monitor.h"
/*
* Define (or redefine) custom GUC variables.
*/
void
init_guc(void)
{
int i = 0;
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_max",
.guc_desc = "Sets the maximum number of statements tracked by pg_stat_monitor.",
.guc_default = 5000,
.guc_min = 5000,
.guc_max = INT_MAX,
.guc_restart = true
};
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
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_track",
.guc_desc = "Selects which statements are tracked by pg_stat_monitor.",
.guc_default = 0,
.guc_min = 0,
.guc_max = 0,
.guc_restart = false
};
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
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_normalized_query",
.guc_desc = "Selects whether save query in normalized format.",
.guc_default = 0,
.guc_min = 0,
.guc_max = 0,
.guc_restart = false
};
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
};
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
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_object_cache",
.guc_desc = "Sets the maximum number of object cache",
.guc_default = 5,
.guc_min = 5,
.guc_max = 10,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_respose_time_lower_bound",
.guc_desc = "Sets the time in millisecond.",
.guc_default = 1,
.guc_min = 1,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_respose_time_step",
.guc_desc = "Sets the respose time steps in millisecond.",
.guc_default = 1,
.guc_min = 1,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.shared_buffer",
.guc_desc = "Sets the shared_buffer size.",
.guc_default = 500000,
.guc_min = 500000,
.guc_max = INT_MAX,
.guc_restart = true
};
DefineCustomIntVariable("pg_stat_monitor.max",
"Sets the maximum number of statements tracked by pg_stat_monitor.",
NULL,
&pgsm_max,
&PGSM_MAX,
5000,
5000,
INT_MAX,
@@ -35,7 +129,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.query_max_len",
"Sets the maximum length of query",
NULL,
&pgsm_query_max_len,
&PGSM_QUERY_MAX_LEN,
1024,
1024,
INT_MAX,
@@ -48,8 +142,8 @@ init_guc(void)
DefineCustomEnumVariable("pg_stat_monitor.track",
"Selects which statements are tracked by pg_stat_monitor.",
NULL,
&pgsm_track,
pgsm_track_TOP,
&PGSM_TRACK,
PGSM_TRACK_TOP,
track_options,
PGC_SUSET,
0,
@@ -60,7 +154,7 @@ init_guc(void)
DefineCustomBoolVariable("pg_stat_monitor.track_utility",
"Selects whether utility commands are tracked by pg_stat_monitor.",
NULL,
&pgsm_track_utility,
(bool*)&PGSM_TRACK_UTILITY,
true,
PGC_SUSET,
0,
@@ -71,7 +165,7 @@ init_guc(void)
DefineCustomBoolVariable("pg_stat_monitor.normalized_query",
"Selects whether save query in normalized format.",
NULL,
&pgsm_normalized_query,
(bool*)&PGSM_NORMALIZED_QUERY,
true,
PGC_SUSET,
0,
@@ -79,10 +173,10 @@ init_guc(void)
NULL,
NULL);
DefineCustomIntVariable("pg_stat_monitor.pgsm_max_buckets ",
DefineCustomIntVariable("pg_stat_monitor.PGSM_MAX_buckets ",
"Sets the maximum number of buckets.",
NULL,
&pgsm_max_buckets,
&PGSM_MAX_BUCKETS,
10,
1,
10,
@@ -95,7 +189,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.bucket_time",
"Sets the time in seconds per bucket.",
NULL,
&pgsm_bucket_time,
&PGSM_BUCKET_TIME,
60,
1,
INT_MAX,
@@ -109,7 +203,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.pgsm_object_cache ",
"Sets the maximum number of object cache",
NULL,
&pgsm_object_cache,
&PGSM_OBJECT_CACHE,
5,
5,
10,
@@ -119,12 +213,12 @@ init_guc(void)
NULL,
NULL);
DefineCustomRealVariable("pg_stat_monitor.pgsm_respose_time_lower_bound",
DefineCustomIntVariable("pg_stat_monitor.pgsm_respose_time_lower_bound",
"Sets the time in millisecond.",
NULL,
&pgsm_respose_time_lower_bound,
.1,
.1,
&PGSM_RESPOSE_TIME_LOWER_BOUND,
1,
1,
INT_MAX,
PGC_POSTMASTER,
0,
@@ -132,12 +226,12 @@ init_guc(void)
NULL,
NULL);
DefineCustomRealVariable("pg_stat_monitor.pgsm_respose_time_step",
DefineCustomIntVariable("pg_stat_monitor.pgsm_respose_time_step",
"Sets the respose time steps in millisecond.",
NULL,
&pgsm_respose_time_step,
.1,
.1,
&PGSM_RESPOSE_TIME_STEP,
1,
1,
INT_MAX,
PGC_POSTMASTER,
0,
@@ -145,10 +239,10 @@ init_guc(void)
NULL,
NULL);
DefineCustomIntVariable("pg_stat_monitor.shared_buffer",
DefineCustomIntVariable("pg_stat_monitor.query_shared_buffer",
"Sets the shared_buffer size",
NULL,
&pgsm_query_buf_size,
&PGSM_QUERY_BUF_SIZE,
500000,
500000,
INT_MAX,