Pass args from Zabbix explicitly
* Using $0 psases the entire command, so just pass all 9 possible positioinal values. * Allow empty arguments. * Update sample config: ** Use a socket by default. ** Return a set with database discovery to be able to assign a macro.
This commit is contained in:
parent
318cdd5633
commit
7665ce08d6
@ -1,5 +1,6 @@
|
||||
host=localhost
|
||||
port=54315
|
||||
host=/var/run/postgresql
|
||||
port=5432
|
||||
user=postgres
|
||||
metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database
|
||||
metric=db_stats:row::SELECT * FROM pg_stat_database WHERE datname = '{datname}'
|
||||
metric=discover_dbs:column::SELECT datname FROM pg_database
|
||||
metric=discover_dbs:set::SELECT datname FROM pg_database
|
||||
|
||||
3
pgmon.py
3
pgmon.py
@ -389,6 +389,7 @@ class Server:
|
||||
|
||||
if len(parts) > 1:
|
||||
for arg in parts[1].split(','):
|
||||
if arg != '':
|
||||
(k, v) = arg.split('=', 1)
|
||||
args_dict[k] = v
|
||||
except socket.timeout:
|
||||
@ -500,7 +501,7 @@ class Worker(threading.Thread):
|
||||
req.set_result(json.dumps(res[0]))
|
||||
elif metric.type == 'column':
|
||||
req.set_result(json.dumps([list(r.values())[0] for r in res]))
|
||||
else:
|
||||
elif metric_type == 'set':
|
||||
req.set_result(json.dumps(res))
|
||||
|
||||
try:
|
||||
|
||||
@ -1 +1 @@
|
||||
UserParameter=pgmon[*],/usr/local/bin/pgmon.py -c /etc/zabbix/pgmon.cfg "$0"
|
||||
UserParameter=pgmon[*],/usr/local/bin/pgmon.py -c /etc/zabbix/pgmon.cfg "$1,$2,$3,$4,$5,$6,$7,$8,$9"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user