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