44import re
55from distutils .version import LooseVersion
66import mamonsu .lib .platform as platform
7- from mamonsu .lib .plugin import PluginDisableException
87import logging
98
9+
1010class MemoryLeakDiagnostic (Plugin ):
1111 DEFAULT_CONFIG = {'enabled' : 'False' ,
1212 'private_anon_mem_threshold' : '1GB' }
@@ -45,7 +45,6 @@ def __init__(self, config):
4545 logging .error ('Error in config, section [{section}], parameter private_anon_mem_threshold. '
4646 'Possible values MB, GB, TB. For example 1GB.'
4747 .format (section = self .__class__ .__name__ .lower ()))
48- ratio = 1024 * 1024 * 1024
4948
5049 self .diff = ratio * int (private_anon_mem_threshold )
5150
@@ -54,9 +53,8 @@ def __init__(self, config):
5453 try :
5554 release_file = open (os_release_file , 'r' ).readlines ()
5655 except Exception as e :
57- self . disable ( )
56+ logging . info ( f'Cannot read file { os_release_file } : { e } ' )
5857 release_file = None
59- logging .error (f'Cannot read file { os_release_file } : { e } ' )
6058
6159 if release_file :
6260 for line in release_file :
@@ -66,6 +64,9 @@ def __init__(self, config):
6664 self .os_name = v .strip ('"\n ' )
6765 elif k == 'VERSION_ID' :
6866 self .os_version = v .strip ('"\n ' )
67+ else :
68+ self .os_name = None
69+ self .os_version = None
6970
7071 def run (self , zbx ):
7172 pids = []
@@ -75,13 +76,10 @@ def run(self, zbx):
7576
7677 for row in Pooler .query (query = self .query ):
7778 pids .append (row [0 ])
78- print (self .os_release .split ('.' )[0 ])
79- print (int (self .os_release .split ('.' )[1 ]))
80- print (self .os_name )
81- print (self .os_version )
82- if LooseVersion (self .os_release ) < LooseVersion ("4.5" ) and \
83- not (self .os_name == 'centos' and self .os_version == '7' ):
84- print ('point 1' )
79+
80+ if (LooseVersion (self .os_release ) < LooseVersion ("4.5" )
81+ and not (self .os_name == 'centos' and self .os_version == '7' ))\
82+ or (not self .os_name and not self .os_version ):
8583 for pid in pids :
8684 try :
8785 statm = open (f'/proc/{ pid } /statm' , 'r' ).read ().split (' ' )
@@ -97,7 +95,6 @@ def run(self, zbx):
9795 for diff in diffs :
9896 msg_text += 'pid: {pid}, RES {RES} - SHR {SHR} more then {diff}\n ' .format_map (diff )
9997 else :
100- print ('point 2' )
10198 for pid in pids :
10299 try :
103100 statm = open (f'/proc/{ pid } /status' , 'r' ).readlines ()
0 commit comments