Skip to content

Commit 67fb133

Browse files
committed
v2.2.4: plugin cfs fixes
1 parent 3bfcf69 commit 67fb133

File tree

6 files changed

+43
-32
lines changed

6 files changed

+43
-32
lines changed

mamonsu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__author__ = 'Dmitry Vasilyev'
22
__author_email__ = '[email protected]'
33
__description__ = 'Monitoring agent for PostgreSQL'
4-
__version__ = '2.2.3'
4+
__version__ = '2.2.4'
55
__licence__ = 'BSD'
66

77
__url__ = 'https://github.com/postgrespro/mamonsu'

mamonsu/plugins/pgsql/cfs.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
class Cfs(Plugin):
88

9-
Interval = 60
9+
ratioInterval, ratioCounter = 10, 0
10+
timeRatioInterval = ratioInterval * 60
1011

1112
DEFAULT_CONFIG = {'force_enable': str(False)}
1213

@@ -49,17 +50,20 @@ def run(self, zbx):
4950
if self.plugin_config('force_enable') == 'False':
5051
self.disable_and_exit_if_not_pgpro_ee()
5152

52-
relations, compressed_size, non_compressed_size = [], 0, 0
53-
for db in Pooler.databases():
54-
for row in Pooler.query(self.compressed_ratio_sql, db):
55-
relation_name = '{0}.{1}'.format(db, row[0])
56-
relations.append({'{#COMPRESSED_RELATION}': relation_name})
57-
compressed_size += row[2]
58-
non_compressed_size += row[2] * row[1]
59-
zbx.send('pgsql.cfs.compress_ratio[{0}]'.format(relation_name), row[1])
60-
zbx.send('pgsql.cfs.discovery_compressed_relations[]', zbx.json({'data': relations}))
61-
zbx.send('pgsql.cfs.activity[total_compress_ratio]', non_compressed_size / compressed_size)
62-
del(relations, compressed_size, non_compressed_size)
53+
if self.ratioCounter == self.ratioInterval:
54+
relations, compressed_size, non_compressed_size = [], 0, 0
55+
for db in Pooler.databases():
56+
for row in Pooler.query(self.compressed_ratio_sql, db):
57+
relation_name = '{0}.{1}'.format(db, row[0])
58+
relations.append({'{#COMPRESSED_RELATION}': relation_name})
59+
compressed_size += row[2]
60+
non_compressed_size += row[2] * row[1]
61+
zbx.send('pgsql.cfs.compress_ratio[{0}]'.format(relation_name), row[1])
62+
zbx.send('pgsql.cfs.discovery_compressed_relations[]', zbx.json({'data': relations}))
63+
zbx.send('pgsql.cfs.activity[total_compress_ratio]', non_compressed_size / compressed_size)
64+
del(relations, compressed_size, non_compressed_size)
65+
self.ratioCounter = 0
66+
self.ratioCounter += 1
6367

6468
info = Pooler.query(self.activity_sql)[0]
6569
zbx.send('pgsql.cfs.activity[written_bytes]', info[0], delta=self.DELTA_SPEED, only_positive_speed=True)
@@ -73,33 +77,40 @@ def run(self, zbx):
7377
self.prev['written_bytes'] = info[0]
7478
self.prev['scanned_bytes'] = info[1]
7579

76-
zbx.send('pgsql.cfs.activity[compressed_files]', info[2], delta=self.DELTA_SPEED, only_positive_speed=True)
77-
zbx.send('pgsql.cfs.activity[scanned_files]', info[3], delta=self.DELTA_SPEED, only_positive_speed=True)
80+
# information about files
81+
zbx.send('pgsql.cfs.activity[compressed_files]', info[2] * self.Interval, delta=self.DELTA_SPEED, only_positive_speed=True)
82+
zbx.send('pgsql.cfs.activity[scanned_files]', info[3] * self.Interval, delta=self.DELTA_SPEED, only_positive_speed=True)
7883

7984
def items(self, template):
8085
return template.item({
8186
'name': 'PostgreSQL cfs compression: written byte/s',
8287
'key': 'pgsql.cfs.activity[written_bytes]',
88+
'units': self.UNITS.bytes,
8389
'delay': self.Interval
8490
}) + template.item({
8591
'name': 'PostgreSQL cfs compression: scanned byte/s',
8692
'key': 'pgsql.cfs.activity[scanned_bytes]',
93+
'units': self.UNITS.bytes,
8794
'delay': self.Interval
8895
}) + template.item({
89-
'name': 'PostgreSQL cfs compression: compressed files/s',
96+
'name': 'PostgreSQL cfs compression: compressed files',
9097
'key': 'pgsql.cfs.activity[compressed_files]',
98+
'units': self.UNITS.none,
9199
'delay': self.Interval
92100
}) + template.item({
93-
'name': 'PostgreSQL cfs compression: scanned files/s',
101+
'name': 'PostgreSQL cfs compression: scanned files',
94102
'key': 'pgsql.cfs.activity[scanned_files]',
103+
'units': self.UNITS.none,
95104
'delay': self.Interval
96105
}) + template.item({
97106
'name': 'PostgreSQL cfs compression: current ratio',
98107
'key': 'pgsql.cfs.activity[current_compress_ratio]',
108+
'units': self.UNITS.none,
99109
'delay': self.Interval
100110
}) + template.item({
101111
'name': 'PostgreSQL cfs compression: total ratio',
102112
'key': 'pgsql.cfs.activity[total_compress_ratio]',
113+
'units': self.UNITS.none,
103114
'delay': self.Interval
104115
})
105116

@@ -143,12 +154,12 @@ def discovery_rules(self, template):
143154
items = [
144155
{'key': 'pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]',
145156
'name': 'Relation {#COMPRESSED_RELATION}: compress ratio',
146-
'delay': self.Interval}
157+
'delay': self.timeRatioInterval}
147158
]
148159
graphs = [
149160
{
150161
'name': 'Relation {#COMPRESSED_RELATION}: compress ratio',
151-
'delay': self.Interval,
162+
'delay': self.timeRatioInterval,
152163
'items': [
153164
{'color': '00CC00',
154165
'key': 'pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]'}]

packaging/conf/template.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
<value_type>0</value_type>
289289
<allowed_hosts/>
290290
<valuemap/>
291-
<units/>
291+
<units>b</units>
292292
<delta>0</delta>
293293
<snmpv3_contextname/>
294294
<snmpv3_securityname/>
@@ -330,7 +330,7 @@
330330
<value_type>0</value_type>
331331
<allowed_hosts/>
332332
<valuemap/>
333-
<units/>
333+
<units>b</units>
334334
<delta>0</delta>
335335
<snmpv3_contextname/>
336336
<snmpv3_securityname/>
@@ -358,7 +358,7 @@
358358
</applications>
359359
</item>
360360
<item>
361-
<name>PostgreSQL cfs compression: compressed files/s</name>
361+
<name>PostgreSQL cfs compression: compressed files</name>
362362
<type>2</type>
363363
<snmp_community/>
364364
<multiplier>0</multiplier>
@@ -400,7 +400,7 @@
400400
</applications>
401401
</item>
402402
<item>
403-
<name>PostgreSQL cfs compression: scanned files/s</name>
403+
<name>PostgreSQL cfs compression: scanned files</name>
404404
<type>2</type>
405405
<snmp_community/>
406406
<multiplier>0</multiplier>
@@ -4683,7 +4683,7 @@
46834683
<history>7</history>
46844684
<trends>365</trends>
46854685
<status>0</status>
4686-
<delay>60</delay>
4686+
<delay>600</delay>
46874687
<value_type>0</value_type>
46884688
<allowed_hosts/>
46894689
<valuemap/>

packaging/conf/template_win32.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
<value_type>0</value_type>
289289
<allowed_hosts/>
290290
<valuemap/>
291-
<units/>
291+
<units>b</units>
292292
<delta>0</delta>
293293
<snmpv3_contextname/>
294294
<snmpv3_securityname/>
@@ -330,7 +330,7 @@
330330
<value_type>0</value_type>
331331
<allowed_hosts/>
332332
<valuemap/>
333-
<units/>
333+
<units>b</units>
334334
<delta>0</delta>
335335
<snmpv3_contextname/>
336336
<snmpv3_securityname/>
@@ -358,7 +358,7 @@
358358
</applications>
359359
</item>
360360
<item>
361-
<name>PostgreSQL cfs compression: compressed files/s</name>
361+
<name>PostgreSQL cfs compression: compressed files</name>
362362
<type>2</type>
363363
<snmp_community/>
364364
<multiplier>0</multiplier>
@@ -400,7 +400,7 @@
400400
</applications>
401401
</item>
402402
<item>
403-
<name>PostgreSQL cfs compression: scanned files/s</name>
403+
<name>PostgreSQL cfs compression: scanned files</name>
404404
<type>2</type>
405405
<snmp_community/>
406406
<multiplier>0</multiplier>
@@ -3801,7 +3801,7 @@
38013801
<history>7</history>
38023802
<trends>365</trends>
38033803
<status>0</status>
3804-
<delay>60</delay>
3804+
<delay>600</delay>
38053805
<value_type>0</value_type>
38063806
<allowed_hosts/>
38073807
<valuemap/>

packaging/debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mamonsu (2.2.3-1) stable; urgency=low
1+
mamonsu (2.2.4-1) stable; urgency=low
22

33
* add cfs compression plugin
44

packaging/rpm/SPECS/mamonsu.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: mamonsu
2-
Version: 2.2.3
2+
Version: 2.2.4
33
Release: 1%{?dist}
44
Summary: Monitoring agent for PostgreSQL
55
Group: Applications/Internet
@@ -70,7 +70,7 @@ chown mamonsu.mamonsu /var/log/mamonsu
7070
/sbin/chkconfig --del mamonsu
7171

7272
%changelog
73-
* Thu Nov 17 2016 Dmitry Vasilyev <[email protected]> - 2.2.3-1
73+
* Thu Nov 17 2016 Dmitry Vasilyev <[email protected]> - 2.2.4-1
7474
- add cfs compression plugin
7575

7676
* Tue Nov 15 2016 Dmitry Vasilyev <[email protected]> - 2.2.1-1

0 commit comments

Comments
 (0)