Skip to content

Commit 8b5d21f

Browse files
committed
Merge branch 'dev'
2 parents faa38a3 + f273e2b commit 8b5d21f

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

.github/workflows/mamonsu-tests-master.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
if: "contains(matrix.docker_os, 'centos')"
4242
run: docker run -t -d --name $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) --privileged=true ${{ matrix.docker_os }} /usr/sbin/init
4343
- name: Run docker Ubuntu image
44-
if: contains(matrix.docker_os, 'ubuntu')
44+
if: "contains(matrix.docker_os, 'ubuntu')"
4545
run: docker run -t -d --name $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) --privileged=true ${{ matrix.docker_os }}
4646

4747
- name: Install Zabbix ${{ matrix.zabbix_version }} on VM
@@ -57,6 +57,7 @@ jobs:
5757
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) mkdir -p -m 755 /mamonsu/
5858
- run: docker cp . $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ):/mamonsu
5959
- name: Install prequisites
60+
if: "(matrix.pg_version != '9.6' && (matrix.docker_os == 'centos:8')"
6061
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/tests.sh --os="${{ matrix.docker_os }}" --pg-version="${{ matrix.pg_version }}"
6162

6263
- name: Build and install Mamonsu

mamonsu/lib/zbx_template.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ def _get_all(self, items='items', plugins=None, dashboard=False):
214214
# result_graphs = ''
215215
# for graph in graphs:
216216
# if 'dashboard' in graph and graph['dashboard']['page'] == page:
217-
# result_graphs += '<{3}><type>GRAPH_CLASSIC</type><name>{0}</name><width>{1}</width>' \
218-
# '<height>{2}</height><fields><field><type>GRAPH</type><value>' \
219-
# '<name>{0}</name></value></field></fields></{3}>'.format(graph['dashboard']['name'],
217+
# result_graphs += ('<{3}><type>GRAPH_CLASSIC</type><name>{0}</name><width>{1}</width>' +
218+
# '<height>{2}</height><fields><field><type>GRAPH</type><value>' +
219+
# '<name>{0}</name></value></field></fields></{3}>').format(graph['dashboard']['name'],
220220
# graph['dashboard']['size']['width'],
221221
# graph['dashboard']['size']['height'],
222222
# xml_key)
@@ -263,19 +263,19 @@ def screen_items(self, page, plugins=None, xml_key='screen_item'):
263263
result = ''
264264
for resourcetype, graph in dashboard_widgets:
265265
if 'dashboard' in graph and graph['dashboard']['page'] == page['name']:
266-
result += '<{5}><resourcetype>{8}</resourcetype>' \
267-
'<width>{2}</width><height>{3}</height><x>{6}</x><y>{7}</y>{0}' \
268-
'<resource><{9}>{1}</{9}><host>{4}</host></resource>' \
269-
'</{5}>'.format(self._format_args(self.screen_graph_defaults, {}),
270-
graph['dashboard']['name'],
271-
graph['dashboard']['size']['width'],
272-
graph['dashboard']['size']['height'],
273-
self.Template,
274-
xml_key,
275-
x,
276-
y,
277-
resourcetype,
278-
'name' if resourcetype == 0 else 'key')
266+
result += ('<{5}><resourcetype>{8}</resourcetype>' +
267+
'<width>{2}</width><height>{3}</height><x>{6}</x><y>{7}</y>{0}' +
268+
'<resource><{9}>{1}</{9}><host>{4}</host></resource>' +
269+
'</{5}>').format(self._format_args(self.screen_graph_defaults, {}),
270+
graph['dashboard']['name'],
271+
graph['dashboard']['size']['width'],
272+
graph['dashboard']['size']['height'],
273+
self.Template,
274+
xml_key,
275+
x,
276+
y,
277+
resourcetype,
278+
'name' if resourcetype == 0 else 'key')
279279
x = (x + 1) % page['hsize']
280280
if x == 0:
281281
y += 1
@@ -287,8 +287,8 @@ def screen(self, plugins=None, xml_key='screen'):
287287
plugins = []
288288
result = ''
289289
for page in self.dashboard_pages:
290-
result += '<{4}><name>{0}</name><hsize>{1}</hsize><vsize>' \
291-
'{2}</vsize>{3}</{4}>'.format('Mamonsu ' + page['name'],
290+
result += ('<{4}><name>{0}</name><hsize>{1}</hsize><vsize>' +
291+
'{2}</vsize>{3}</{4}>').format('Mamonsu ' + page['name'],
292292
page['hsize'],
293293
page['vsize'],
294294
self.screen_items(page, plugins),
@@ -433,7 +433,7 @@ def _format_args(self, defaults, override):
433433
except KeyError:
434434
val = pair[1]
435435
if val is None:
436-
row = '<{0}/>'.format(key)
436+
row = '<{0}>{1}</{0}>'.format(key, pair[1]) if pair[1] else '<{0}/>'.format(key)
437437
else:
438438
row = '<{0}>{1}</{0}>'.format(key, val)
439439
result += row

mamonsu/plugins/pgsql/memory_leak_diagnostic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class MemoryLeakDiagnostic(Plugin):
1616
query = 'select pid from pg_stat_activity'
1717
key_count_diff = 'pgsql.memory_leak_diagnostic.count_diff[]'
1818
key_count_diff_error = 'pgsql.memory_leak_diagnostic.msg_text[]'
19-
name_count_diff = 'PostgreSQL: number of pids which private anonymous memory exceeds ' \
20-
'private_anon_mem_threshold'
21-
name_count_diff_error = 'PostgreSQL: number of pids which private anonymous memory ' \
22-
'exceeds private_anon_mem_threshold, text of message'
19+
name_count_diff = ('PostgreSQL: number of pids which private anonymous memory exceeds ' +
20+
'private_anon_mem_threshold')
21+
name_count_diff_error = ('PostgreSQL: number of pids which private anonymous memory ' +
22+
'exceeds private_anon_mem_threshold, text of message')
2323

2424
def __init__(self, config):
2525
super(Plugin, self).__init__(config)
@@ -131,8 +131,8 @@ def run(self, zbx):
131131
'diff': self.diff})
132132
if diffs:
133133
for diff in diffs:
134-
msg_text += 'pid: {pid}, RssAnon {RssAnon} more then {diff}, VmRSS {VmRSS}, ' \
135-
'RssFile {RssFile}, RssShmem {RssShmem} \n'.format_map(diff)
134+
msg_text += ('pid: {pid}, RssAnon {RssAnon} more then {diff}, VmRSS {VmRSS}, ' +
135+
'RssFile {RssFile}, RssShmem {RssShmem} \n').format_map(diff)
136136

137137
zbx.send(self.key_count_diff, int(count_diff))
138138
zbx.send(self.key_count_diff_error, msg_text)

mamonsu/plugins/pgsql/plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ def extension_schema(self, extension, db=None):
4040
def disable_and_exit_if_extension_is_not_installed(self, ext, db=None):
4141
if not self.extension_installed(ext, db=db, silent=True):
4242
self.disable()
43-
raise PluginDisableException("""Disable plugin and exit, because '{0}' \
44-
extension is not installed. Enable it in PostgreSQL instance: '{1}', \
43+
raise PluginDisableException("""Disable plugin and exit, because '{0}'
44+
extension is not installed. Enable it in PostgreSQL instance: '{1}',
4545
if needed and restart.""".format(ext, Pooler.connection_string(db)))
4646

4747
def disable_and_exit_if_not_pgpro_ee(self, db=None):
4848
if not Pooler.is_pgpro_ee(db):
4949
self.disable()
50-
raise PluginDisableException("""Disable plugin and exit, because \
50+
raise PluginDisableException("""Disable plugin and exit, because
5151
PostgresPro Enterprise Edition is not detected [instance: '{0}']
5252
""".format(Pooler.connection_string(db)))
5353

5454
def disable_and_exit_if_archive_mode_is_not_on(self, db=None):
5555
param = Pooler.get_sys_param('archive_mode', db=db)
5656
if param != 'on' and param != 'always':
5757
self.disable()
58-
raise PluginDisableException("""Disable plugin and exit, because '{0}' \
59-
parameter is neither 'on' nor 'always'. Enable it "{1}" or "{2}" in PostgreSQL instance, \
58+
raise PluginDisableException("""Disable plugin and exit, because '{0}'
59+
parameter is neither 'on' nor 'always'. Enable it "{1}" or "{2}" in PostgreSQL instance,
6060
if needed and restart.""".format('archive_mode', 'alter system set archive_mode = on;',
6161
'alter system set archive_mode = always;'))

mamonsu/plugins/system/linux/pg_probackup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def run(self, zbx):
9191
for backup in instance.get('backups', []):
9292
status = backup['status']
9393
if status in ['ERROR', 'CORRUPT', 'ORPHAN']:
94-
error = 'Backup with id: {backup_id} in instance: {instance_name} in pg_probackup dir: ' \
95-
'{backup_catalog} has status: {status}.'.format(backup_id=backup['id'],
96-
instance_name=instance['instance'],
97-
status=status, backup_catalog=_dir)
94+
error = ('Backup with id: {backup_id} in instance: {instance_name} in pg_probackup dir: ' +
95+
'{backup_catalog} has status: {status}.').format(backup_id=backup['id'],
96+
instance_name=instance['instance'],
97+
status=status, backup_catalog=_dir)
9898
self.log.info(error)
9999
no_error = False
100100
zbx.send(self.key_dir_error.format('[' + _dir + ']'), error)

mamonsu/tools/sysinfo/linux.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ def fetch_first(reg, info):
304304
result['_FLAGS_IMPORTANT'] = ', '.join(flags)
305305
result['speed'] = fetch_first(
306306
r'^cpu MHz\s+\:\s+(\d+\.\d+)$', info) + ' MHz'
307-
result['_TOTAL'] = 'physical = {0}, cores = {1}, ' \
308-
'virtual = {2}, hyperthreading = {3}'.format(
307+
result['_TOTAL'] = ('physical = {0}, cores = {1}, ' +
308+
'virtual = {2}, hyperthreading = {3}').format(
309309
result['physical'], result['cores'],
310310
result['virtual'], result['hyperthreading']
311311
)

0 commit comments

Comments
 (0)