Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mamonsu/plugins/pgsql/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ def _check_connect(self):
if not self.query_completed_succ:
self.log.debug('[db: {0}] Connecting...'.format(self.database))
self._close()
host, unix_sock = os.environ.get('PGHOST'), None
if host.startswith('/'):
unix_sock, host = host, None
self.conn = connect(
user=os.environ.get('PGUSER'),
password=os.environ.get('PGPASSWORD'),
host=os.environ.get('PGHOST'),
unix_sock=unix_sock,
host=host,
port=int(os.environ.get('PGPORT') or 5432),
database=self.database
)
Expand Down
7 changes: 7 additions & 0 deletions mamonsu/plugins/pgsql/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def __init__(self, config):
# алертим, если cache hit меньше чем %
self.TriggerCacheHitLessThen = self.config.fetch(
'health', 'cache', int)
# счетчик, для сообщения в лог
self.counter = 0

def run(self, zbx):

Expand All @@ -31,6 +33,11 @@ def run(self, zbx):
from pg_stat_database')
zbx.send('pgsql.cache[hit]', int(result[0][0]))

self.counter += 1
if self.counter > 9:
self.log.info('=== Keep alive ===')
self.counter = 0

def items(self, template):
result = template.item({
'name': 'PostgreSQL: ping',
Expand Down