11from mamonsu .plugins .pgsql .plugin import PgsqlPlugin as Plugin
22import os
33from .pool import Pooler
4- import logging
54import re
65from distutils .version import LooseVersion
76import mamonsu .lib .platform as platform
7+ from mamonsu .lib .plugin import PluginDisableException
88
99class MemoryLeakDiagnostic (Plugin ):
1010 DEFAULT_CONFIG = {'enabled' : 'False' ,
@@ -22,8 +22,8 @@ class MemoryLeakDiagnostic(Plugin):
2222 def __init__ (self , config ):
2323 super (Plugin , self ).__init__ (config )
2424 if not platform .LINUX :
25- logging .info ('Plugin {name} work only on Linux. ' .format (name = self .__class__ .__name__ ))
2625 self .disable ()
26+ raise PluginDisableException ('Plugin {name} work only on Linux. ' .format (name = self .__class__ .__name__ ))
2727
2828 if self .is_enabled ():
2929 self .page_size = os .sysconf ('SC_PAGE_SIZE' )
@@ -40,28 +40,27 @@ def __init__(self, config):
4040 elif prefix == 'TB' :
4141 ratio = 1024 * 1024 * 1024 * 1024
4242 else :
43- logging .error ('Error in config, section [{section}], parameter private_anon_mem_threshold. '
43+ self .disable ()
44+ raise PluginDisableException ('Error in config, section [{section}], parameter private_anon_mem_threshold. '
4445 'Possible values MB, GB, TB. For example 1GB.'
4546 .format (section = self .__class__ .__name__ .lower ()))
46- self .disable ()
4747 self .diff = ratio * int (private_anon_mem_threshold )
4848
4949 self .os_release = os .uname ().release
5050 os_release_file = '/etc/os-release'
5151 try :
5252 release_file = open (os_release_file , 'r' ).readlines ()
5353 except Exception as e :
54- logging .error (f'Cannot read file { os_release_file } : { e } ' )
55- release_file = None
5654 self .disable ()
57- if release_file :
58- for line in release_file :
59- if line .strip ('"\n ' ) != '' :
60- k , v = line .split ('=' , 1 )
61- if k == 'ID' :
62- self .os_name = v .strip ('"\n ' )
63- elif k == 'VERSION_ID' :
64- self .os_version = v .strip ('"\n ' )
55+ raise PluginDisableException (f'Cannot read file { os_release_file } : { e } ' )
56+
57+ for line in release_file :
58+ if line .strip ('"\n ' ) != '' :
59+ k , v = line .split ('=' , 1 )
60+ if k == 'ID' :
61+ self .os_name = v .strip ('"\n ' )
62+ elif k == 'VERSION_ID' :
63+ self .os_version = v .strip ('"\n ' )
6564
6665 def run (self , zbx ):
6766 pids = []
0 commit comments