diff --git a/mamonsu/plugins/pgsql/_connection.py b/mamonsu/plugins/pgsql/_connection.py index 3461b0b4..211d64e3 100644 --- a/mamonsu/plugins/pgsql/_connection.py +++ b/mamonsu/plugins/pgsql/_connection.py @@ -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 ) diff --git a/mamonsu/plugins/pgsql/health.py b/mamonsu/plugins/pgsql/health.py index af7c0e47..3c8a00b4 100644 --- a/mamonsu/plugins/pgsql/health.py +++ b/mamonsu/plugins/pgsql/health.py @@ -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): @@ -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',