Add agent version
This commit is contained in:
parent
80661f1b72
commit
449c202098
8
pgmon.py
8
pgmon.py
@ -17,6 +17,8 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
|
|||||||
from http.server import ThreadingHTTPServer
|
from http.server import ThreadingHTTPServer
|
||||||
from urllib.parse import urlparse, parse_qs
|
from urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
|
VERSION = '0.1.0'
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
@ -201,6 +203,10 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
|||||||
name = parsed_path.path.strip('/')
|
name = parsed_path.path.strip('/')
|
||||||
parsed_query = parse_qs(parsed_path.query)
|
parsed_query = parse_qs(parsed_path.query)
|
||||||
|
|
||||||
|
if name == 'agent_version':
|
||||||
|
self._reply(200, f"{VERSION}")
|
||||||
|
return
|
||||||
|
|
||||||
# Note: Parse_qs returns the values as a list. Since we always expect
|
# Note: Parse_qs returns the values as a list. Since we always expect
|
||||||
# single values, just grab the first from each.
|
# single values, just grab the first from each.
|
||||||
args = {key: values[0] for key, values in parsed_query.items()}
|
args = {key: values[0] for key, values in parsed_query.items()}
|
||||||
@ -210,7 +216,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
|||||||
metric = config['metrics'][name]
|
metric = config['metrics'][name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.error(f"Unknown metric: {name}")
|
log.error(f"Unknown metric: {name}")
|
||||||
self.wfile.write(bytes('Unknown metric', 'utf-8'))
|
self._reply(404, 'Unknown metric')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get the dbname
|
# Get the dbname
|
||||||
|
|||||||
@ -11,6 +11,21 @@ zabbix_export:
|
|||||||
groups:
|
groups:
|
||||||
- name: 'My Templates'
|
- name: 'My Templates'
|
||||||
items:
|
items:
|
||||||
|
- uuid: 763920af8da84db8a9a2667d9653cb21
|
||||||
|
name: 'PostgreSQL Agent Version'
|
||||||
|
key: 'web.page.get[localhost,/agent_version,{$AGENT_PORT}]'
|
||||||
|
delay: 1h
|
||||||
|
history: 90d
|
||||||
|
value_type: TEXT
|
||||||
|
description: 'PostgreSQL monitoring agent version number'
|
||||||
|
preprocessing:
|
||||||
|
- type: REGEX
|
||||||
|
parameters:
|
||||||
|
- '\n\s?\n([\s\S]*)'
|
||||||
|
- \1
|
||||||
|
tags:
|
||||||
|
- tag: Application
|
||||||
|
value: PostgreSQL
|
||||||
- uuid: 8706eccb7edc4fa394f552fc31f401a9
|
- uuid: 8706eccb7edc4fa394f552fc31f401a9
|
||||||
name: 'Max Frozen XID Age'
|
name: 'Max Frozen XID Age'
|
||||||
key: 'web.page.get[localhost,/max_frozen_age,{$AGENT_PORT}]'
|
key: 'web.page.get[localhost,/max_frozen_age,{$AGENT_PORT}]'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user