-
Notifications
You must be signed in to change notification settings - Fork 1
/
pg_alert.conf
215 lines (175 loc) · 8.83 KB
/
pg_alert.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
###############################################################################
### COPYRIGHT NOTICE FOLLOWS. DO NOT REMOVE
###############################################################################
### Copyright (c) 2012 - 2021, SQLEXEC LLC
###
### This program is bound by the following licenses:
### GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
### MIT licensing privileges also conveyed on top of GNU V3.
###
### Permission to use, copy, modify, and distribute this software and its
### documentation for any purpose, without fee, and without a written agreement
### is hereby granted, provided that the above copyright notice and this paragraph
### and the following two paragraphs appear in all copies.
###
### IN NO EVENT SHALL SQLEXEC LLC BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
### SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
### ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
### SQLEXEC LLC HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###
### SQLEXEC LLC SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
### LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
### PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
### AND SQLEXEC LLC HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
### ENHANCEMENTS, OR MODIFICATIONS.
###
###############################################################################
### CONFIGURATION FILE FOR PG_ALERT.PY PROGRAM
###
### Michael Vitale 6/22/2012 Original coding
### Michael Vitale 12/25/2016 New parameters added
### Michael Vitale 01/28/2017 SMTP parameters added
### Michael Vitale 05/22/2021 RDS, DBID parameters added
### Michael Vitale 06/06/2021 Modified local log file logic. Also, PGPORT renamed to DBPORT
###
### 2 sections in this configuration file: required and optional
### Optional fields have defaults as specified.
###
### # indicates a comment line
### Commas are the default delimiter unless specified otherwise.
###
### Some optional fields are dynamic, meaning a changed value will be
### picked up by the program within the next 5 minutes.
### Look for keyword, "dynamic" in the commented description of the field.
###
### boolean fields can be either yes/no or true/false
###
###############################################################################
[required]
# an identifier that will show up in the subject line of the alert email
CLUSTERID=PROD
# space separates multiple recipients. Used by MAIL_METHOD=MAIL
# SMPT and SSMTP use the email account
TO=whoever@whatever.com
# MAIL and SSMTP use FROM. SMPT uses SMTP_ACCOUNT
FROM=sysdba@ec2.com
# whether email alerts will be sent. Otherwise, you are just logging to the alerts file.
EMAILALERTS=yes
# useful for debugging
VERBOSE=false
# internal debugging
DEBUG=false
# directory where the alerts-history file, the alerts file, and the pg log file will be found if in rds mode.
ALERTLOG_DIRECTORY=/home/centos/tools
# specifies how long the program will run. Consider this to be set something close to
# the number of minutes in a day to effectively monitor every day.
# This is also a commmand line parameter, which overrides any configuration set value
MINUTES=1440
# specifies how many minutes to refresh the log file and parameter changes. Should be much less than MINUTES value.
REFRESH=2
# DB CONNECTION FIELDS FOLLOW. These fields can also be specified as command line parameters.
# command line parameters over-ride configuration file settings.
RDS=true
DBID=<RDS DB Identifier>
DBNAME=mydb
DBUSER=myuser
DBHOST=mydbhost
DBPORT=5432
############################
# OPTIONAL SECTION FOLLOWS #
############################
[optional]
# FOR REMOTE DBs, we can check on some things but user must provide values. These only apply when DBREMOTE=True
# example: db.r5.4xlargeb --> 16 CPUs 128 GB RAM
CPUS=16
# The main driver for this program. This is the grep command that will be used for the pg log file tail.
# All other filtering commands are based on the analysis of this resulting GREP'd file.
GREPFILTER=ERROR: \|FATAL: \|WARN: \|CONTEXT: \|STATEMENT: \|HINT: \|still waiting for \| acquired ShareLock on transaction\| acquired ExclusiveLock on\| terminating walsender process\|ALTER DATABASE \|:LOG: temporary file:
GREPEXCLUDE=terminating connection due\|connection to client lost\|,DISCARD ALL,\|DETAIL: parameters: $1 =
# Choices are MAIL, SMTP, or SSMTP. Must be provided if EMAILALERTS=yes. Default not applicable.
MAIL_METHOD=MAIL
# must be one of the following: default, custom1, custom2
# try custom1 or custom2 if you have mailx bash output problems
#MAILX_FORMAT=default
MAILX_FORMAT=custom1
################################################################
# SMTP CONFIGURATION: self explanatory
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_ACCOUNT=myemail@gmail.com
SMTP_PASSWORD=
SMS=7036667777@vtext.com
################################################################
# dynamic: tells pg_alert to defer alerts until suspended is set back to "no".
# This is useful for cases where a bunch of alerts are going off in a short
# duration. This buys you time to set other dynamic fields to restrict
# the alerting or until the reason for the bunched alerts is gone. Default is false.
SUSPENDED=no
# Specifies the limit of alerts during this execution session of pg_alert
# If exceeded the program will terminate. (default=100)
MAX_ALERTS=200
# Determines how long to keep the 2 pg_alert log files. Default is keep forever.
KEEPLOGDAYS=0
# if PGLOG_DIRECTORY specified, this will take precendence over postgresql.conf default setting.
# Default setting is <pg data directory>/<postgresql.conf setting>
PGLOG_DIRECTORY=
# For every log that has a wait transaction record, only alert on those transactions that
# are waiting longer than this many seconds. Default is 1 second. You may want to increase
# this slightly to avoid a lot of log alerts.
LOCKWAIT=5
# Specifies the time to wait in seconds before analyzing other non-PG log files criteria like
# queries (connections, slave lag, etc) and host metrics (cpu, etc.). Default is 300 (5 minutes)
CHECKINTERVAL=120
# Percentage value related to host load.
# If any 1, 5, 15 minute check exceeds this value, alert on it. Default is 100%
LOADTHRESHOLD=85
# Percentage value related to used size of pg data directory and location of pg_xlog directory.
# If uses size percentage exceeds this value, alert on it. Default is 99.%
DIRTHRESHOLD=85
# Number of seconds before "idle in transaction" transactions will cause an alert.
# Default:9999 or almost never.
IDLETRANSTHRESHOLD=30
# Number of seconds before long running query transactions will cause an alert.
# Default:9999 or almost never.
QUERYTRANSTHRESHOLD=30
# Number of bytes allowed in PG temp directory(pgsql_tmp) before causing an alert
PGSQL_TMP_THRESHOLD=300000000
# A threshold for alerting based on db_stats temp bytes for every database.
# Default is no check
TEMPBYTESTHRESHOLD=100000000
# Whether to ignore autovacuum queries captured in pg_stat_activity. Default is true.
IGNORE_AUTOVACDAEMON=yes
# Whether to ignore user-initiated vacuums or analyzes. Default is true.
IGNORE_USERVAC=yes
# Whether slave lag will cause alerts. This will cause an alert if sent and write locations are not the same.
# Default is false;
MONITORLAG=no
# Determines if system generated statement timeouts will cause alerts. Default is false.
ALERT_STMT_TIMEOUT=no
# a substring to search for and bypass if the string contains one of these:
# 'acquired ShareLock on transaction'
# 'acquired ExclusiveLock on '
LOCKFILTER=
# list of slaves to monitor assuming the host is the master. Comma-separated list.
SLAVES=
########################################################################################################
# To ignore apps and queries, put the entire app/query here and separate them with delimiter, *|*.
# DO NOT ADD A TRAILING DELIMITER AT THE END
########################################################################################################
IGNOREUSERS=
IGNOREAPPS=
IGNOREQUERIES=
########################################################################################################
# the following states and codes will be ignored. They are both comma-delimited lists.
# 42P01,42601,42703 - sql syntax type errors are in "Class 42"
# SQLCODES are reported in the postgresql log file as sqlstate, so SQLCODE is ignored.
# You can also specify a class to ignore based on official postgresql documentation:
# http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
# SQLCLASS=42 will ignore all sqlstates in wildcard=42*
# In the following example, SQLSTATES is redundant since both values appear in Class 42.
########################################################################################################
# SQLSTATE=42P01, 42P01
# SQLSTATE=23505
# SQLCLASS=42
SQLSTATE=
SQLCLASS=