Skip to content

Commit e55ac1a

Browse files
author
Alexander Popov
committed
fix: chanfe disable and change MemoryLeakDiagnostic
1 parent 9f6765f commit e55ac1a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

mamonsu/lib/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def is_enabled(self):
135135
return self._enabled
136136

137137
def disable(self):
138+
self._plugin_config['enabled'] = 'False'
138139
self._enabled = False
139140

140141
def set_sender(self, sender):

mamonsu/plugins/pgsql/memory_leak_diagnostic.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import re
55
from distutils.version import LooseVersion
66
import mamonsu.lib.platform as platform
7-
from mamonsu.lib.plugin import PluginDisableException
87
import logging
98

9+
1010
class 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

Comments
 (0)