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
|
host=/var/run/postgresql
|
||||||
port=54315
|
port=5432
|
||||||
|
user=postgres
|
||||||
metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database
|
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=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
|
||||||
|
|||||||
7
pgmon.py
7
pgmon.py
@ -389,8 +389,9 @@ class Server:
|
|||||||
|
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
for arg in parts[1].split(','):
|
for arg in parts[1].split(','):
|
||||||
(k, v) = arg.split('=', 1)
|
if arg != '':
|
||||||
args_dict[k] = v
|
(k, v) = arg.split('=', 1)
|
||||||
|
args_dict[k] = v
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
print("IPC communication timeout receiving request")
|
print("IPC communication timeout receiving request")
|
||||||
conn.close()
|
conn.close()
|
||||||
@ -500,7 +501,7 @@ class Worker(threading.Thread):
|
|||||||
req.set_result(json.dumps(res[0]))
|
req.set_result(json.dumps(res[0]))
|
||||||
elif metric.type == 'column':
|
elif metric.type == 'column':
|
||||||
req.set_result(json.dumps([list(r.values())[0] for r in res]))
|
req.set_result(json.dumps([list(r.values())[0] for r in res]))
|
||||||
else:
|
elif metric_type == 'set':
|
||||||
req.set_result(json.dumps(res))
|
req.set_result(json.dumps(res))
|
||||||
|
|
||||||
try:
|
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