Fix verbose flag, and some queries
* Make the verbose flag do something (sets stderr logging to DEBUG) * Coalesce potentially NULL values to 0 in db stats * Cast the stats reset time difference to float since the python json library can't serialize a Decimal type.
This commit is contained in:
parent
8edda91f2a
commit
695ad60b43
@ -7,8 +7,8 @@ metric=version:value::SHOW server_version_num
|
|||||||
metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database
|
metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database
|
||||||
|
|
||||||
# Per-database metrics
|
# Per-database metrics
|
||||||
metric=db_stats:row::SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, blk_read_time, blk_write_time, extract('epoch' from stats_reset) FROM pg_stat_database WHERE datname = '{datname}'
|
metric=db_stats:row::SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, blk_read_time, blk_write_time, extract('epoch' from stats_reset)::float FROM pg_stat_database WHERE datname = '{datname}'
|
||||||
metric=db_stats:row:160000:SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, checksum_failures, blk_read_time, blk_write_time, session_time, active_time, idle_in_transaction_time, sessions, sessions_abandoned, sessions_fatal, sessions_killed, extract('epoch' from stats_reset) FROM pg_stat_database WHERE datname = '{datname}'
|
metric=db_stats:row:140000:SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, COALESCE(checksum_failures, 0) AS checksum_failures, blk_read_time, blk_write_time, session_time, active_time, idle_in_transaction_time, sessions, sessions_abandoned, sessions_fatal, sessions_killed, extract('epoch' from stats_reset)::float FROM pg_stat_database WHERE datname = '{datname}'
|
||||||
|
|
||||||
# Per-replication metrics
|
# Per-replication metrics
|
||||||
metric=rep_stats:row::SELECT * FROM pg_stat_database WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'
|
metric=rep_stats:row::SELECT * FROM pg_stat_database WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'
|
||||||
|
|||||||
5
pgmon.py
5
pgmon.py
@ -234,6 +234,9 @@ class Config:
|
|||||||
self.log_file = args.logfile
|
self.log_file = args.logfile
|
||||||
if args.socket is not None:
|
if args.socket is not None:
|
||||||
self.ipc_socket = args.socket
|
self.ipc_socket = args.socket
|
||||||
|
if args.verbose:
|
||||||
|
self.stderr_log_level = 'DEBUG'
|
||||||
|
|
||||||
|
|
||||||
def read_file(self, config_file, read_metrics, read_clusters):
|
def read_file(self, config_file, read_metrics, read_clusters):
|
||||||
"""
|
"""
|
||||||
@ -473,6 +476,7 @@ class Config:
|
|||||||
db = DB(self, cluster_name)
|
db = DB(self, cluster_name)
|
||||||
cluster.pg_version = int(db.query('SHOW server_version_num')[0]['server_version_num'])
|
cluster.pg_version = int(db.query('SHOW server_version_num')[0]['server_version_num'])
|
||||||
db.close()
|
db.close()
|
||||||
|
logger.debug("Got cluster version: {}".format(cluster.pg_version))
|
||||||
|
|
||||||
# Return the version number
|
# Return the version number
|
||||||
return cluster.pg_version
|
return cluster.pg_version
|
||||||
@ -1265,6 +1269,7 @@ class Worker(threading.Thread):
|
|||||||
else:
|
else:
|
||||||
req.set_result("{}".format(list(res[0].values())[0]))
|
req.set_result("{}".format(list(res[0].values())[0]))
|
||||||
elif metric.type == 'row':
|
elif metric.type == 'row':
|
||||||
|
logger.debug("Serializing row: {}".format(res[0]))
|
||||||
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]))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user