File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,14 @@ def _check_connect(self):
4949 if not self .query_completed_succ :
5050 self .log .debug ('[db: {0}] Connecting...' .format (self .database ))
5151 self ._close ()
52+ host , unix_sock = os .environ .get ('PGHOST' ), None
53+ if host .startswith ('/' ):
54+ unix_sock , host = host , None
5255 self .conn = connect (
5356 user = os .environ .get ('PGUSER' ),
5457 password = os .environ .get ('PGPASSWORD' ),
55- host = os .environ .get ('PGHOST' ),
58+ unix_sock = unix_sock ,
59+ host = host ,
5660 port = int (os .environ .get ('PGPORT' ) or 5432 ),
5761 database = self .database
5862 )
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ def __init__(self, config):
1515 # алертим, если cache hit меньше чем %
1616 self .TriggerCacheHitLessThen = self .config .fetch (
1717 'health' , 'cache' , int )
18+ # счетчик, для сообщения в лог
19+ self .counter = 0
1820
1921 def run (self , zbx ):
2022
@@ -31,6 +33,11 @@ def run(self, zbx):
3133 from pg_stat_database' )
3234 zbx .send ('pgsql.cache[hit]' , int (result [0 ][0 ]))
3335
36+ self .counter += 1
37+ if self .counter > 9 :
38+ self .log .info ('=== Keep alive ===' )
39+ self .counter = 0
40+
3441 def items (self , template ):
3542 result = template .item ({
3643 'name' : 'PostgreSQL: ping' ,
You can’t perform that action at this time.
0 commit comments