-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzabbix_agentd.conf
517 lines (446 loc) · 23.2 KB
/
zabbix_agentd.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# This is a configuration file for Zabbix agent daemon (Unix)
# To get more information about Zabbix, visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
### Option: PidFile
# Name of PID file.
#
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_agentd.pid
PidFile=/var/run/zabbix/zabbix_agentd.pid
### Option: LogType
# Specifies where log messages are written to:
# system - syslog
# file - file specified with LogFile parameter
# console - standard output
#
# Mandatory: no
# Default:
# LogType=file
### Option: LogFile
# Log file name for LogType 'file' parameter.
#
# Mandatory: no
# Default:
# LogFile=
LogFile=/var/log/zabbix/zabbix_agentd.log
### Option: LogFileSize
# Maximum size of log file in MB.
# 0 - disable automatic log rotation.
#
# Mandatory: no
# Range: 0-1024
# Default:
# LogFileSize=1
LogFileSize=0
### Option: DebugLevel
# Specifies debug level:
# 0 - basic information about starting and stopping of Zabbix processes
# 1 - critical information
# 2 - error information
# 3 - warnings
# 4 - for debugging (produces lots of information)
# 5 - extended debugging (produces even more information)
#
# Mandatory: no
# Range: 0-5
# Default:
# DebugLevel=3
### Option: SourceIP
# Source IP address for outgoing connections.
#
# Mandatory: no
# Default:
# SourceIP=
### Option: EnableRemoteCommands
# Whether remote commands from Zabbix server are allowed.
# 0 - not allowed
# 1 - allowed
#
# Mandatory: no
# Default:
# EnableRemoteCommands=0
### Option: LogRemoteCommands
# Enable logging of executed shell commands as warnings.
# 0 - disabled
# 1 - enabled
#
# Mandatory: no
# Default:
# LogRemoteCommands=0
##### Passive checks related
### Option: Server
# List of comma delimited IP addresses (or hostnames) of Zabbix servers.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: no
# Default:
# Server=
Server=127.0.0.1
### Option: ListenPort
# Agent will listen on this port for connections from the server.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10050
### Option: ListenIP
# List of comma delimited IP addresses that the agent should listen on.
# First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
#
# Mandatory: no
# Default:
# ListenIP=0.0.0.0
### Option: StartAgents
# Number of pre-forked instances of zabbix_agentd that process passive checks.
# If set to 0, disables passive checks and the agent will not listen on any TCP port.
#
# Mandatory: no
# Range: 0-100
# Default:
# StartAgents=3
##### Active checks related
### Option: ServerActive
# List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
# If port is not specified, default port is used.
# IPv6 addresses must be enclosed in square brackets if port for that host is specified.
# If port is not specified, square brackets for IPv6 addresses are optional.
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#
# Mandatory: no
# Default:
# ServerActive=
ServerActive=127.0.0.1
### Option: Hostname
# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server.
# Value is acquired from HostnameItem if undefined.
#
# Mandatory: no
# Default:
# Hostname=
Hostname=Zabbix server
### Option: HostnameItem
# Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
# Does not support UserParameters or aliases.
#
# Mandatory: no
# Default:
# HostnameItem=system.hostname
### Option: HostMetadata
# Optional parameter that defines host metadata.
# Host metadata is used at host auto-registration process.
# An agent will issue an error and not start if the value is over limit of 255 characters.
# If not defined, value will be acquired from HostMetadataItem.
#
# Mandatory: no
# Range: 0-255 characters
# Default:
# HostMetadata=
### Option: HostMetadataItem
# Optional parameter that defines an item used for getting host metadata.
# Host metadata is used at host auto-registration process.
# During an auto-registration request an agent will log a warning message if
# the value returned by specified item is over limit of 255 characters.
# This option is only used when HostMetadata is not defined.
#
# Mandatory: no
# Default:
# HostMetadataItem=
### Option: RefreshActiveChecks
# How often list of active checks is refreshed, in seconds.
#
# Mandatory: no
# Range: 60-3600
# Default:
# RefreshActiveChecks=120
### Option: BufferSend
# Do not keep data longer than N seconds in buffer.
#
# Mandatory: no
# Range: 1-3600
# Default:
# BufferSend=5
### Option: BufferSize
# Maximum number of values in a memory buffer. The agent will send
# all collected data to Zabbix Server or Proxy if the buffer is full.
#
# Mandatory: no
# Range: 2-65535
# Default:
# BufferSize=100
### Option: MaxLinesPerSecond
# Maximum number of new lines the agent will send per second to Zabbix Server
# or Proxy processing 'log' and 'logrt' active checks.
# The provided value will be overridden by the parameter 'maxlines',
# provided in 'log' or 'logrt' item keys.
#
# Mandatory: no
# Range: 1-1000
# Default:
# MaxLinesPerSecond=20
############ ADVANCED PARAMETERS #################
### Option: Alias
# Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one.
# Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed.
# Different Alias keys may reference the same item key.
# For example, to retrieve the ID of user 'zabbix':
# Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1]
# Now shorthand key zabbix.userid may be used to retrieve data.
# Aliases can be used in HostMetadataItem but not in HostnameItem parameters.
#
# Mandatory: no
# Range:
# Default:
### Option: Timeout
# Spend no more than Timeout seconds on processing
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3
### Option: AllowRoot
# Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent
# will try to switch to the user specified by the User configuration option instead.
# Has no effect if started under a regular user.
# 0 - do not allow
# 1 - allow
#
# Mandatory: no
# Default:
# AllowRoot=0
### Option: User
# Drop privileges to a specific, existing user on the system.
# Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
# User=zabbix
### Option: Include
# You may include individual files or all files in a directory in the configuration file.
# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include=
Include=/etc/zabbix/zabbix_agentd.d/
# Include=/usr/local/etc/zabbix_agentd.userparams.conf
# Include=/usr/local/etc/zabbix_agentd.conf.d/
# Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS #######
### Option: UnsafeUserParameters
# Allow all characters to be passed in arguments to user-defined parameters.
# The following characters are not allowed:
# \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
# Additionally, newline characters are not allowed.
# 0 - do not allow
# 1 - allow
#
# Mandatory: no
# Range: 0-1
# Default:
# UnsafeUserParameters=0
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
# UserParameter=
####### LOADABLE MODULES #######
### Option: LoadModulePath
# Full path to location of agent modules.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# LoadModulePath=${libdir}/modules
### Option: LoadModule
# Module to load at agent startup. Modules are used to extend functionality of the agent.
# Format: LoadModule=<module.so>
# The modules must be located in directory specified by LoadModulePath.
# It is allowed to include multiple LoadModule parameters.
#
# Mandatory: no
# Default:
# LoadModule=
####### TLS-RELATED PARAMETERS #######
### Option: TLSConnect
# How the agent should connect to server or proxy. Used for active checks.
# Only one value can be specified:
# unencrypted - connect without encryption
# psk - connect using TLS and a pre-shared key
# cert - connect using TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
# TLSConnect=unencrypted
### Option: TLSAccept
# What incoming connections to accept.
# Multiple values can be specified, separated by comma:
# unencrypted - accept connections without encryption
# psk - accept connections secured with TLS and a pre-shared key
# cert - accept connections secured with TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
# TLSAccept=unencrypted
### Option: TLSCAFile
# Full pathname of a file containing the top-level CA(s) certificates for
# peer certificate verification.
#
# Mandatory: no
# Default:
# TLSCAFile=
### Option: TLSCRLFile
# Full pathname of a file containing revoked certificates.
#
# Mandatory: no
# Default:
# TLSCRLFile=
### Option: TLSServerCertIssuer
# Allowed server certificate issuer.
#
# Mandatory: no
# Default:
# TLSServerCertIssuer=
### Option: TLSServerCertSubject
# Allowed server certificate subject.
#
# Mandatory: no
# Default:
# TLSServerCertSubject=
### Option: TLSCertFile
# Full pathname of a file containing the agent certificate or certificate chain.
#
# Mandatory: no
# Default:
# TLSCertFile=
### Option: TLSKeyFile
# Full pathname of a file containing the agent private key.
#
# Mandatory: no
# Default:
# TLSKeyFile=
### Option: TLSPSKIdentity
# Unique, case sensitive string used to identify the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKIdentity=
### Option: TLSPSKFile
# Full pathname of a file containing the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKFile=
# Background writer statistics. http://www.postgresql.org/docs/9.3/static/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
UserParameter=pgsql.bgwriter.checkpoints_timed[*],psql -qAtX $1 -c "select checkpoints_timed from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.checkpoints_req[*],psql -qAtX $1 -c "select checkpoints_req from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.checkpoint_write_time[*],psql -qAtX $1 -c "select checkpoint_write_time from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.checkpoint_sync_time[*],psql -qAtX $1 -c "select checkpoint_sync_time from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.buffers_checkpoint[*],psql -qAtX $1 -c "select buffers_checkpoint from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.buffers_clean[*],psql -qAtX $1 -c "select buffers_clean from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.maxwritten_clean[*],psql -qAtX $1 -c "select maxwritten_clean from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.buffers_backend[*],psql -qAtX $1 -c "select buffers_backend from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.buffers_backend_fsync[*],psql -qAtX $1 -c "select buffers_backend_fsync from pg_stat_bgwriter"
UserParameter=pgsql.bgwriter.buffers_alloc[*],psql -qAtX $1 -c "select buffers_alloc from pg_stat_bgwriter"
# pgbuffercache - extension which allow examining what's happening in the shared buffer cache in real time. http://www.postgresql.org/docs/9.3/static/pgbuffercache.html
UserParameter=pgsql.buffercache.clear[*],psql -qAtX $1 -c "select count(*) from pg_buffercache where not isdirty"
UserParameter=pgsql.buffercache.dirty[*],psql -qAtX $1 -c "select count(*) from pg_buffercache where isdirty"
UserParameter=pgsql.buffercache.used[*],psql -qAtX $1 -c "select count(*) from pg_buffercache where reldatabase is not null"
UserParameter=pgsql.buffercache.total[*],psql -qAtX $1 -c "select count(*) from pg_buffercache"
# General info
UserParameter=pgsql.ping[*],/bin/echo -e "\\\timing \n select 1" | psql -qAtX $1 | tail -n 1 |cut -d' ' -f2
UserParameter=pgsql.uptime[*],psql -qAtX $1 -c "select date_part('epoch', now() - pg_postmaster_start_time())::int"
UserParameter=pgsql.cache.hit[*],psql -qAtX $1 -c "select round(sum(blks_hit)*100/sum(blks_hit+blks_read), 2) from pg_stat_database"
# Connections
UserParameter=pgsql.connections.active[*],psql -qAtX $1 -c "select count(*) from pg_stat_activity where state = 'active'"
UserParameter=pgsql.connections.idle[*],psql -qAtX $1 -c "select count(*) from pg_stat_activity where state = 'idle'"
UserParameter=pgsql.connections.idle_in_transaction[*],psql -qAtX $1 -c "select count(*) from pg_stat_activity where state = 'idle in transaction'"
UserParameter=pgsql.connections.total[*],psql -qAtX $1 -c "select count(*) from pg_stat_activity"
UserParameter=pgsql.connections.total_pct[*],psql -qAtX $1 -c "select count(*)*100/(select current_setting('max_connections')::int) from pg_stat_activity"
UserParameter=pgsql.connections.waiting[*],psql -qAtX $1 -c "select count(*) from pg_stat_activity where waiting"
UserParameter=pgsql.connections.prepared[*],psql -qAtX $1 -c "select count(*) from pg_prepared_xacts"
# Size of database, table or indexes of specified table
UserParameter=pgsql.db.size[*],psql -qAtX $1 -c "select pg_database_size('$2')"
UserParameter=pgsql.table.size[*],psql -qAtX $1 -c "select pg_relation_size('$2')"
UserParameter=pgsql.index.size[*],psql -qAtX $1 -c "select pg_total_relation_size('$2') - pg_relation_size('$2')"
# Summary database statistics
UserParameter=pgsql.dbstat.sum.numbackends[*],psql -qAtX $1 -c "select sum(numbackends) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.xact_commit[*],psql -qAtX $1 -c "select sum(xact_commit) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.xact_rollback[*],psql -qAtX $1 -c "select sum(xact_rollback) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.blks_read[*],psql -qAtX $1 -c "select sum(blks_read) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.blks_hit[*],psql -qAtX $1 -c "select sum(blks_hit) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.tup_returned[*],psql -qAtX $1 -c "select sum(tup_returned) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.tup_fetched[*],psql -qAtX $1 -c "select sum(tup_fetched) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.tup_inserted[*],psql -qAtX $1 -c "select sum(tup_inserted) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.tup_updated[*],psql -qAtX $1 -c "select sum(tup_updated) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.tup_deleted[*],psql -qAtX $1 -c "select sum(tup_deleted) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.conflicts[*],psql -qAtX $1 -c "select sum(conflicts) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.temp_files[*],psql -qAtX $1 -c "select sum(temp_files) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.temp_bytes[*],psql -qAtX $1 -c "select sum(temp_bytes) from pg_stat_database"
UserParameter=pgsql.dbstat.sum.deadlocks[*],psql -qAtX $1 -c "select sum(deadlocks) from pg_stat_database"
# Specified database statistics
UserParameter=pgsql.dbstat.numbackends[*],psql -qAtX $1 -c "select numbackends from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.xact_commit[*],psql -qAtX $1 -c "select xact_commit from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.xact_rollback[*],psql -qAtX $1 -c "select xact_rollback from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.blks_read[*],psql -qAtX $1 -c "select blks_read from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.blks_hit[*],psql -qAtX $1 -c "select blks_hit from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.tup_returned[*],psql -qAtX $1 -c "select tup_returned from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.tup_fetched[*],psql -qAtX $1 -c "select tup_fetched from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.tup_inserted[*],psql -qAtX $1 -c "select tup_inserted from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.tup_updated[*],psql -qAtX $1 -c "select tup_updated from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.tup_deleted[*],psql -qAtX $1 -c "select tup_deleted from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.conflicts[*],psql -qAtX $1 -c "select conflicts from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.temp_files[*],psql -qAtX $1 -c "select temp_files from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.temp_bytes[*],psql -qAtX $1 -c "select temp_bytes from pg_stat_database where datname = '$2'"
UserParameter=pgsql.dbstat.deadlocks[*],psql -qAtX $1 -c "select deadlocks from pg_stat_database where datname = '$2'"
# Table statistics (pg_stat_user_tables and pg_statio_user_tables)
UserParameter=pgsql.table.stat.heap_blks_read[*],psql -qAtX $1 -c "select coalesce(heap_blks_read,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.heap_blks_hit[*],psql -qAtX $1 -c "select coalesce(heap_blks_hit,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.idx_blks_read[*],psql -qAtX $1 -c "select coalesce(idx_blks_read,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.idx_blks_hit[*],psql -qAtX $1 -c "select coalesce(idx_blks_hit,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.toast_blks_read[*],psql -qAtX $1 -c "select coalesce(toast_blks_read,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.toast_blks_hit[*],psql -qAtX $1 -c "select coalesce(toast_blks_hit,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.tidx_blks_read[*],psql -qAtX $1 -c "select coalesce(tidx_blks_read,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.tidx_blks_hit[*],psql -qAtX $1 -c "select coalesce(tidx_blks_hit,0) from pg_statio_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.seq_scan[*],psql -qAtX $1 -c "select coalesce(seq_scan,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.seq_tup_read[*],psql -qAtX $1 -c "select coalesce(seq_tup_read,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.idx_scan[*],psql -qAtX $1 -c "select coalesce(idx_scan,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.idx_tup_fetch[*],psql -qAtX $1 -c "select coalesce(idx_tup_fetch,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_tup_ins[*],psql -qAtX $1 -c "select coalesce(n_tup_ins,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_tup_del[*],psql -qAtX $1 -c "select coalesce(n_tup_del,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_tup_upd[*],psql -qAtX $1 -c "select coalesce(n_tup_upd,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_tup_hot_upd[*],psql -qAtX $1 -c "select coalesce(n_tup_hot_upd,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_live_tup[*],psql -qAtX $1 -c "select coalesce(n_live_tup,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.n_dead_tup[*],psql -qAtX $1 -c "select coalesce(n_dead_tup,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.vacuum_count[*],psql -qAtX $1 -c "select coalesce(vacuum_count,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.autovacuum_count[*],psql -qAtX $1 -c "select coalesce(autovacuum_count,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.analyze_count[*],psql -qAtX $1 -c "select coalesce(analyze_count,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
UserParameter=pgsql.table.stat.autoanalyze_count[*],psql -qAtX $1 -c "select coalesce(autoanalyze_count,0) from pg_stat_user_tables where (schemaname || '.' || relname) = '$2'"
# Streaming replication
UserParameter=pgsql.streaming.count[*],psql -qAtX $1 -c "select count(*) from pg_stat_replication"
UserParameter=pgsql.streaming.state[*],psql -qAtX $1 -c "select pg_is_in_recovery()"
UserParameter=pgsql.streaming.lag.bytes[*],psql -qAtX $1 -c "select greatest(0,pg_xlog_location_diff(pg_current_xlog_location(), replay_location)) from pg_stat_replication where client_addr = '$2'"
UserParameter=pgsql.streaming.lag.seconds[*],psql -qAtX -h $2 $1 -c "select extract(epoch from now() - pg_last_xact_replay_timestamp())"
# Transactions
UserParameter=pgsql.transactions.idle[*],psql -qAtX $1 -c "select coalesce(extract(epoch from max(age(now(), query_start))), 0) from pg_stat_activity where state='idle in transaction'"
UserParameter=pgsql.transactions.active[*],psql -qAtX $1 -c "select coalesce(extract(epoch from max(age(now(), query_start))), 0) from pg_stat_activity where state <> 'idle in transaction' and state <> 'idle'"
UserParameter=pgsql.transactions.waiting[*],psql -qAtX $1 -c "select coalesce(extract(epoch from max(age(now(), query_start))), 0) from pg_stat_activity where waiting"
UserParameter=pgsql.transactions.prepared[*],psql -qAtX $1 -c "select coalesce(extract(epoch from max(age(now(), prepared))), 0) from pg_prepared_xacts"
# pg_stat_statements
UserParameter=pgsql.pgstatstatements.avg_query_time[*],psql -qAtX $1 -c "select round((sum(total_time) / sum(calls))::numeric,2) from pg_stat_statements"
# Others
UserParameter=pgsql.table.tuples[*],psql -qAtX $1 -c "select count(*) from $2"
UserParameter=pgsql.setting[*],psql -qAtX $1 -c "select current_setting('$2')"
UserParameter=pgsql.trigger[*],psql -qAtX $1 -c "select count(*) from pg_trigger where tgenabled='O' and tgname='$2'"
UserParameter=pgsql.wal.write[*],psql -qAtX $1 -c "select pg_xlog_location_diff(pg_current_xlog_location(),'0/00000000')"
UserParameter=pgsql.wal.count[*],psql -qAtX $1 -c "select count(*) from pg_ls_dir('pg_xlog')"
# Discovery
UserParameter=pgsql.db.discovery[*],/bin/echo -n '{"data":['; for db in $(psql -qAtX $1 -c "select datname from pg_database where not datistemplate and datallowconn and datname!='postgres'"); do /bin/echo -n "{\"{#DBNAME}\": \"$db\"},"; done |sed -e 's:,$::'; /bin/echo -n ']}'
UserParameter=pgsql.table.discovery[*],/bin/echo -n '{"data":['; for table in $(psql -qAtX -F. $1 -c "select n.nspname,c.relname from pg_catalog.pg_class c left join pg_catalog.pg_namespace n on n.oid = c.relnamespace where c.relkind in ('r','s','') and n.nspname not in ('^pg_toast','information_schema','pg_catalog')"); do /bin/echo -n "{\"{#TABLENAME}\": \"$table\"},"; done |sed -e 's:\},$:\}:'; /bin/echo -n ']}'
UserParameter=pgsql.streaming.discovery[*],/bin/echo -n '{"data":['; for replica in $(psql -qAtX $1 -c "select client_addr from pg_stat_replication"); do /bin/echo -n "{\"{#HOTSTANDBY}\": \"$replica\"},"; done |sed -e 's:,$::'; /bin/echo -n ']}'