Skip to content

Commit a83819b

Browse files
committed
Merge branch 'dev'
2 parents 5bba946 + b44260f commit a83819b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+37575
-6632
lines changed

Makefile.tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ run_builds:
55
docker run --rm -v "$(WORKDIR)":/var/tmp debian:9 /bin/bash -ex "/var/tmp/tests/build_deb.sh"
66

77
run_functional_tests:
8-
docker run --rm -v "$(WORKDIR)":/var/tmp centos:6 /bin/bash -ex "/var/tmp/tests/check.sh"
8+
docker run -v "$(WORKDIR)":/var/tmp centos:7 /bin/bash -ex "/var/tmp/tests/check.sh"

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ Install from git:
4646

4747
.. code-block:: bash
4848
49-
$ git clone ... && cd mamonsu && python setup.py build && python setup.py install
49+
$ git clone ... && cd mamonsu && python3 setup.py build && python3 setup.py install
5050
5151
Build deb:
5252

5353
.. code-block:: bash
5454
55-
$ apt-get install make dpkg-dev debhelper python-dev python-setuptools
55+
$ apt-get install make dpkg-dev debhelper python3-dev python3-setuptools
5656
$ git clone ... && cd mamonsu && make deb && dpkg -i mamonsu*.deb
5757
5858
Build rpm:
5959

6060
.. code-block:: bash
6161
62-
$ yum install make rpm-build python2-devel python-setuptools
62+
$ yum install make rpm-build python3-devel python3-setuptools
6363
$ git clone ... && cd mamonsu && make rpm && rpm -i mamonsu*.rpm
6464
6565
Build repository, `./packaging/repo/gnupg` and `./packaging/repo/rpmmacros` must be provided by caller:

examples/pg_stat_activity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def run(self, zbx):
8383
# send a resulting value to zabbix
8484
for idx, item in enumerate(self.Items):
8585
key, zbxkey, val, delta = item[0], item[1], 0, item[4]
86-
#self.log.info('{0}[{1}] '.format(zbxkey, key)+str(idx))
8786
for row in result:
8887
if key.endswith(row[0]):
8988
val = row[item[5]]

mamonsu/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__author__ = 'Dmitry Vasilyev'
22
__author_email__ = 'info@postgrespro.ru'
33
__description__ = 'Monitoring agent for PostgreSQL'
4-
__version__ = '2.4.5'
4+
__version__ = '2.5.0'
55
__licence__ = 'BSD'
66

77
__url__ = 'https://github.com/postgrespro/mamonsu'
@@ -12,7 +12,6 @@
1212
'Operating System :: POSIX :: Linux',
1313
'Operating System :: Microsoft :: Windows',
1414
'License :: OSI Approved :: BSD License',
15-
'Programming Language :: Python :: 2',
1615
'Programming Language :: Python :: 3',
1716
'Topic :: System :: Monitoring'
1817
]

mamonsu/lib/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
from mamonsu.plugins.pgsql.driver.checks import is_conn_to_db
1111
from mamonsu.lib.default_config import DefaultConfig
1212

13-
if platform.PY2:
14-
import ConfigParser as configparser
15-
else:
16-
import configparser
13+
14+
import configparser
1715

1816

1917
class Config(DefaultConfig):
@@ -76,7 +74,7 @@ def __init__(self, cfg_file=None, plugin_directories=None):
7674
sys.exit(1)
7775
else:
7876
if cfg_file is not None:
79-
self.config.readfp(open(cfg_file))
77+
self.config.read_file(open(cfg_file))
8078

8179
plugins = self.fetch('plugins', 'directory', str)
8280
if plugins is not None:

mamonsu/lib/const.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections import namedtuple
22

33
from mamonsu import __version__
4-
import mamonsu.lib.platform as platform
54

65

76
class _template(object):
@@ -27,20 +26,11 @@ class _template(object):
2726

2827
class _api(object):
2928

30-
if platform.PY2:
31-
UNKNOWN_VERSION = 'UNKNOWN_API_VERSION\n'
32-
else:
33-
UNKNOWN_VERSION = b'UNKNOWN_API_VERSION\n'
29+
UNKNOWN_VERSION = b'UNKNOWN_API_VERSION\n'
3430

35-
if platform.PY2:
36-
METRIC_NOT_FOUND = 'METRIC_NOT_FOUND\n'
37-
else:
38-
METRIC_NOT_FOUND = b'METRIC_NOT_FOUND\n'
31+
METRIC_NOT_FOUND = b'METRIC_NOT_FOUND\n'
3932

40-
if platform.PY2:
41-
VERSION = '{0}'.format(__version__)
42-
else:
43-
VERSION = bytearray('{0}'.format(__version__), 'utf-8')
33+
VERSION = bytearray('{0}'.format(__version__), 'utf-8')
4434

4535
METRIC_LIST_URLS = ['/list', '/list/']
4636
METRIC_GET_URLS = ['/get', '/get/']

mamonsu/lib/get_keys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
class GetKeys(object):
66
plg_type = 'all'
77

8-
def txt(self, type, plugins=None):
8+
def txt(self, plg_type, plugins=None):
99
# sort plugins!
1010
if plugins is None:
1111
plugins = []
12-
self.plg_type = type
12+
self.plg_type = plg_type
1313
plugins.sort(key=lambda x: x.__class__.__name__)
1414
# create template
1515
template_data = self._get_all('keys_and_queries', plugins) # get data from all plugins

mamonsu/lib/platform.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@
44
WINDOWS = (sys.platform == 'win32' or sys.platform == 'win64')
55
FREEBSD = ('freebsd' in sys.platform)
66
UNIX = LINUX or FREEBSD
7-
8-
PY2 = (sys.version_info[0] == 2)
9-
PY3 = (sys.version_info[0] == 3)
10-
11-
if PY2:
12-
INTEGER_TYPES = (int, long)
13-
if PY3:
14-
INTEGER_TYPES = int,
7+
INTEGER_TYPES = int,

mamonsu/lib/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Plugin(object):
3333
Interval = 60
3434

3535
# plugin config
36-
DEFAULT_CONFIG = {} # type: dict[str, str]
36+
DEFAULT_CONFIG = {} # type
3737

3838
_thread = None # type: Thread
3939
_sender = False

mamonsu/lib/runner.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from mamonsu.lib.plugin import Plugin
1414
from mamonsu.lib.zbx_template import ZbxTemplate
1515
from mamonsu.lib.get_keys import GetKeys
16-
from distutils.version import LooseVersion
1716
from mamonsu.plugins.system.linux.scripts import Scripts
1817

1918

@@ -86,8 +85,8 @@ def quit_handler(_signo=None, _stack_frame=None):
8685
if len(commands) == 2:
8786
commands.append('postgrespro_agent.conf')
8887
for klass in Plugin.only_child_subclasses():
89-
if klass.__name__ != "PgWaitSampling" and klass.__name__ != "Cfs":
90-
plugins.append(klass(cfg))
88+
if klass.__name__ != "PgWaitSampling" and klass.__name__ != "Cfs":
89+
plugins.append(klass(cfg))
9190
args.plugin_type = correct_plugin_type(args.plugin_type)
9291
if args.plugin_type == 'pg' or args.plugin_type == 'sys' or args.plugin_type == 'all':
9392
template = GetKeys()
@@ -111,7 +110,7 @@ def quit_handler(_signo=None, _stack_frame=None):
111110
Plugin.PATH = path
112111
# create directory for scripts along the path of conf file if needed
113112
if not os.path.exists(path):
114-
os.makedirs(path)
113+
os.makedirs(path)
115114
for key in Scripts.Bash:
116115
with codecs.open(path + "/" + key + ".sh", 'w+', 'utf-8') as f:
117116
# configuration file for zabbix-agent is generated for selected plugin-type
@@ -139,7 +138,7 @@ def quit_handler(_signo=None, _stack_frame=None):
139138
if len(commands) == 2:
140139
commands.append('postgrespro.xml')
141140
for klass in Plugin.only_child_subclasses():
142-
plugins.append(klass(cfg))
141+
plugins.append(klass(cfg))
143142
template = ZbxTemplate(args.template, args.application)
144143
try:
145144
fd = codecs.open(commands[2], 'w', 'utf-8')
@@ -158,7 +157,7 @@ def quit_handler(_signo=None, _stack_frame=None):
158157
if args.plugin_type == 'pg' or args.plugin_type == 'sys' or args.plugin_type == 'all':
159158
for klass in Plugin.only_child_subclasses():
160159
if klass.__name__ != "PgWaitSampling" and klass.__name__ != "Cfs": # check if plugin is for EE
161-
plugins.append(klass(cfg))
160+
plugins.append(klass(cfg))
162161
template = ZbxTemplate(args.template, args.application)
163162
try:
164163
fd = codecs.open(commands[2], 'w', 'utf-8')
@@ -243,7 +242,7 @@ def correct_plugin_type(plugin_type):
243242
print("Got equal plugin types. See help 'mamonsu -- help' ")
244243
sys.exit(2)
245244
# if plugin type name is wrong
246-
if False in [type in valid_plugin_types for type in types]:
245+
if False in [t in valid_plugin_types for t in types]:
247246
print("Got wrong plugin types. See help 'mamonsu -- help' ")
248247
sys.exit(2)
249248
else:

0 commit comments

Comments
 (0)