11# -*- coding: utf-8 -*-
2+ import sys
23
34from mamonsu .plugins .pgsql .plugin import PgsqlPlugin as Plugin
4- from distutils .version import LooseVersion
55from .pool import Pooler
66from mamonsu .lib .zbx_template import ZbxTemplate
77
@@ -157,7 +157,7 @@ def items(self, template, dashboard=False):
157157
158158 def keys_and_queries (self , template_zabbix ):
159159 result = []
160- if LooseVersion ( self . VersionPG ) < LooseVersion ( "10 " ):
160+ if Pooler . server_version_less ( "9.6 " ):
161161 result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wall .format ("[*]" ), self .query_xlog_lsn_diff ))
162162 result .append (
163163 "{0},$2 $1 -c \" {1}\" " .format (self .key_count_wall .format ("[*]" ),
@@ -166,14 +166,13 @@ def keys_and_queries(self, template_zabbix):
166166 result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wall .format ("[*]" ), self .query_wal_lsn_diff ))
167167 result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_count_wall .format ("[*]" ),
168168 Pooler .SQL ["count_wal_files" ][0 ].format ("wal" )))
169-
170- if LooseVersion (self .VersionPG ) >= LooseVersion ("14" ):
171- result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wal_records .format ("[*]" ), self .query_wal_records ))
172- result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wal_fpi .format ("[*]" ), self .query_wal_fpi ))
173- result .append (
174- "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_buffers_full .format ("[*]" ), self .query_wal_buffers_full ))
175- result .append (
176- "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_write_time .format ("[*]" ), self .query_wal_write_time ))
177- result .append (
178- "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_sync_time .format ("[*]" ), self .query_wal_sync_time ))
169+ if Pooler .server_version_greater ("14" ):
170+ result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wal_records .format ("[*]" ), self .query_wal_records ))
171+ result .append ("{0},$2 $1 -c \" {1}\" " .format (self .key_wal_fpi .format ("[*]" ), self .query_wal_fpi ))
172+ result .append (
173+ "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_buffers_full .format ("[*]" ), self .query_wal_buffers_full ))
174+ result .append (
175+ "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_write_time .format ("[*]" ), self .query_wal_write_time ))
176+ result .append (
177+ "{0},$2 $1 -c \" {1}\" " .format (self .key_wal_sync_time .format ("[*]" ), self .query_wal_sync_time ))
179178 return template_zabbix .key_and_query (result )
0 commit comments