33from .pool import Pooler
44import logging
55import re
6-
6+ from distutils .version import LooseVersion
7+ import mamonsu .lib .platform as platform
78
89class MemoryLeakDiagnostic (Plugin ):
910 DEFAULT_CONFIG = {'enabled' : 'False' ,
@@ -20,6 +21,9 @@ class MemoryLeakDiagnostic(Plugin):
2021
2122 def __init__ (self , config ):
2223 super (Plugin , self ).__init__ (config )
24+ if not platform .LINUX :
25+ logging .info ('Plugin {name} work only on Linux. ' .format (name = self .__class__ .__name__ ))
26+ self .disable ()
2327
2428 if self .is_enabled ():
2529 self .page_size = os .sysconf ('SC_PAGE_SIZE' )
@@ -51,11 +55,12 @@ def __init__(self, config):
5155 self .disable ()
5256
5357 for line in release_file :
54- k , v = line .split ('=' , 1 )
55- if k == 'ID' :
56- self .os_name = v .strip ('"\n ' )
57- elif k == 'VERSION_ID' :
58- self .os_version = v .strip ('"\n ' )
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 ' )
5964
6065 def run (self , zbx ):
6166 pids = []
@@ -69,10 +74,8 @@ def run(self, zbx):
6974 print (int (self .os_release .split ('.' )[1 ]))
7075 print (self .os_name )
7176 print (self .os_version )
72- if int (self .os_release .split ('.' )[0 ]) <= 4 and \
73- int (self .os_release .split ('.' )[1 ]) < 5 and \
74- self .os_name != 'centos' and \
75- self .os_version != '7' :
77+ if LooseVersion (self .os_release ) < LooseVersion ("4.5" ) and \
78+ not (self .os_name == 'centos' and self .os_version == '7' ):
7679 print ('point 1' )
7780 for pid in pids :
7881 try :
0 commit comments