Compare commits
No commits in common. "dev/logical_init" and "main" have entirely different histories.
dev/logica
...
main
@ -18,7 +18,6 @@ metrics:
|
||||
query:
|
||||
0: >
|
||||
SELECT host(client_addr) || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') AS repid,
|
||||
application_name,
|
||||
client_addr,
|
||||
state
|
||||
FROM pg_stat_replication
|
||||
|
||||
13
src/pgmon.py
13
src/pgmon.py
@ -400,7 +400,7 @@ def json_encode_special(obj):
|
||||
"""
|
||||
if isinstance(obj, Decimal):
|
||||
return float(obj)
|
||||
raise TypeError(f"Cannot serialize object of {type(obj)}")
|
||||
raise TypeError(f'Cannot serialize object of {type(obj)}')
|
||||
|
||||
|
||||
def run_query_no_retry(pool, return_type, query, args):
|
||||
@ -424,9 +424,7 @@ def run_query_no_retry(pool, return_type, query, args):
|
||||
elif return_type == "column":
|
||||
if len(res) == 0:
|
||||
return "[]"
|
||||
return json.dumps(
|
||||
[list(r.values())[0] for r in res], default=json_encode_special
|
||||
)
|
||||
return json.dumps([list(r.values())[0] for r in res], default=json_encode_special)
|
||||
elif return_type == "set":
|
||||
return json.dumps(res, default=json_encode_special)
|
||||
except:
|
||||
@ -669,12 +667,7 @@ def test_queries():
|
||||
for name, metric in config["metrics"].items():
|
||||
# If the metric has arguments to use while testing, grab those
|
||||
args = metric.get("test_args", {})
|
||||
print(
|
||||
"Testing {} [{}]".format(
|
||||
name,
|
||||
", ".join(["{}={}".format(key, value) for key, value in args.items()]),
|
||||
)
|
||||
)
|
||||
print("Testing {} [{}]".format(name, ", ".join(["{}={}".format(key, value) for key, value in args.items()])))
|
||||
# When testing against a docker container, we may end up connecting
|
||||
# before the service is truly up (it restarts during the initialization
|
||||
# phase). To cope with this, we'll allow a few connection failures.
|
||||
|
||||
@ -795,17 +795,17 @@ metrics:
|
||||
|
||||
def test_json_encode_special(self):
|
||||
# Confirm that we're getting the right type
|
||||
self.assertFalse(isinstance(Decimal("0.5"), float))
|
||||
self.assertTrue(isinstance(pgmon.json_encode_special(Decimal("0.5")), float))
|
||||
self.assertFalse(isinstance(Decimal('0.5'), float))
|
||||
self.assertTrue(isinstance(pgmon.json_encode_special(Decimal('0.5')), float))
|
||||
|
||||
# Make sure we get sane values
|
||||
self.assertEqual(pgmon.json_encode_special(Decimal("0.5")), 0.5)
|
||||
self.assertEqual(pgmon.json_encode_special(Decimal("12")), 12.0)
|
||||
self.assertEqual(pgmon.json_encode_special(Decimal('0.5')), 0.5)
|
||||
self.assertEqual(pgmon.json_encode_special(Decimal('12')), 12.0)
|
||||
|
||||
# Make sure we can still fail for other types
|
||||
self.assertRaises(TypeError, pgmon.json_encode_special, object)
|
||||
self.assertRaises(
|
||||
TypeError, pgmon.json_encode_special, object
|
||||
)
|
||||
|
||||
# Make sure we can actually serialize a Decimal
|
||||
self.assertEqual(
|
||||
json.dumps(Decimal("2.5"), default=pgmon.json_encode_special), "2.5"
|
||||
)
|
||||
self.assertEqual(json.dumps(Decimal('2.5'), default=pgmon.json_encode_special), '2.5')
|
||||
|
||||
@ -167,8 +167,7 @@ zabbix_export:
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: A
|
||||
lifetime: 30d
|
||||
enabled_lifetime_type: DISABLE_AFTER
|
||||
enabled_lifetime: 1d
|
||||
enabled_lifetime_type: DISABLE_NEVER
|
||||
item_prototypes:
|
||||
- uuid: a30babe4a6f4440bba2a3ee46eff7ce2
|
||||
name: 'Time spent executing statements on {#DBNAME}'
|
||||
@ -983,9 +982,6 @@ zabbix_export:
|
||||
type: DEPENDENT
|
||||
key: pgmon_discover_io_backend_types
|
||||
delay: '0'
|
||||
lifetime: 30d
|
||||
enabled_lifetime_type: DISABLE_AFTER
|
||||
enabled_lifetime: 1h
|
||||
item_prototypes:
|
||||
- uuid: b1ac2e56b30f4812bf33ce973ef16b10
|
||||
name: 'I/O Evictions by {#BACKEND_TYPE}'
|
||||
@ -1576,15 +1572,8 @@ zabbix_export:
|
||||
type: HTTP_AGENT
|
||||
key: pgmon_discover_rep
|
||||
delay: 10m
|
||||
filter:
|
||||
conditions:
|
||||
- macro: '{#APPLICATION_NAME}'
|
||||
value: '^pg_[0-9]+_sync_[0-9]+_[0-9]+$'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: A
|
||||
lifetime: 30d
|
||||
enabled_lifetime_type: DISABLE_AFTER
|
||||
enabled_lifetime: 7d
|
||||
enabled_lifetime_type: DISABLE_NEVER
|
||||
item_prototypes:
|
||||
- uuid: 3a5a60620e6a4db694e47251148d82f5
|
||||
name: 'Flush lag for {#REPID}'
|
||||
@ -1786,8 +1775,6 @@ zabbix_export:
|
||||
value: Raw
|
||||
url: 'http://localhost:{$AGENT_PORT}/discover_rep'
|
||||
lld_macro_paths:
|
||||
- lld_macro: '{#APPLICATION_NAME}'
|
||||
path: $.application_name
|
||||
- lld_macro: '{#CLIENT_ADDR}'
|
||||
path: $.client_addr
|
||||
- lld_macro: '{#REPID}'
|
||||
@ -1799,15 +1786,6 @@ zabbix_export:
|
||||
type: HTTP_AGENT
|
||||
key: pgmon_discover_slots
|
||||
delay: 10m
|
||||
filter:
|
||||
conditions:
|
||||
- macro: '{#SLOT_NAME}'
|
||||
value: '^pg_[0-9]+_sync_[0-9]+_[0-9]+$'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: A
|
||||
lifetime: 30d
|
||||
enabled_lifetime_type: DISABLE_AFTER
|
||||
enabled_lifetime: 7d
|
||||
item_prototypes:
|
||||
- uuid: 536c5f82e3074ddfbfd842b3a2e8d46c
|
||||
name: 'Slot {#SLOT_NAME} - Confirmed Flushed Bytes Lag'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user