Skip to content

Commit 3bfcf69

Browse files
committed
v2.2.3: plugin cfs fixes
1 parent 342d27e commit 3bfcf69

File tree

6 files changed

+126
-55
lines changed

6 files changed

+126
-55
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.2'
4+
__version__ = '2.2.3'
55
__licence__ = 'BSD'
66

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

mamonsu/plugins/pgsql/cfs.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Cfs(Plugin):
88

9-
Interval = 5 * 60
9+
Interval = 60
1010

1111
DEFAULT_CONFIG = {'force_enable': str(False)}
1212

@@ -36,9 +36,9 @@ class Cfs(Plugin):
3636

3737
activity_sql = """
3838
select
39-
cfs_gc_activity_processed_bytes(), -- writed
39+
cfs_gc_activity_processed_bytes(), -- written
4040
cfs_gc_activity_processed_pages() * 8 * 1024, -- scanned
41-
cfs_gc_activity_processed_files(), -- writed
41+
cfs_gc_activity_processed_files(), -- written
4242
cfs_gc_activity_scanned_files(); -- scanned
4343
"""
4444

@@ -50,39 +50,39 @@ def run(self, zbx):
5050
self.disable_and_exit_if_not_pgpro_ee()
5151

5252
relations, compressed_size, non_compressed_size = [], 0, 0
53-
for db in Pooler.databases:
53+
for db in Pooler.databases():
5454
for row in Pooler.query(self.compressed_ratio_sql, db):
5555
relation_name = '{0}.{1}'.format(db, row[0])
5656
relations.append({'{#COMPRESSED_RELATION}': relation_name})
5757
compressed_size += row[2]
5858
non_compressed_size += row[2] * row[1]
59-
zbx.send('pgsql.cfs.relation[{0}]'.format(row[0]), row[1])
59+
zbx.send('pgsql.cfs.compress_ratio[{0}]'.format(relation_name), row[1])
6060
zbx.send('pgsql.cfs.discovery_compressed_relations[]', zbx.json({'data': relations}))
6161
zbx.send('pgsql.cfs.activity[total_compress_ratio]', non_compressed_size / compressed_size)
6262
del(relations, compressed_size, non_compressed_size)
6363

6464
info = Pooler.query(self.activity_sql)[0]
65-
zbx.send('pgsql.cfs.activity[writed_bytes]', info[0], delta=self.DELTA_SPEED, only_positive_speed=True)
65+
zbx.send('pgsql.cfs.activity[written_bytes]', info[0], delta=self.DELTA_SPEED, only_positive_speed=True)
6666
zbx.send('pgsql.cfs.activity[scanned_bytes]', info[1], delta=self.DELTA_SPEED, only_positive_speed=True)
6767

6868
# calculate current compress ratio
69-
if ('writed_bytes' in self.prev) and ('scanned_bytes' in self.prev):
70-
if info[0] > self.prev['writed_bytes'] and info[1] > self.prev['scanned_bytes']:
71-
val = (self.prev['scanned_bytes'] - info[1]) / ((self.prev['writed_bytes'] - info[0]) * self.Interval)
69+
if ('written_bytes' in self.prev) and ('scanned_bytes' in self.prev):
70+
if info[0] > self.prev['written_bytes'] and info[1] > self.prev['scanned_bytes']:
71+
val = (self.prev['scanned_bytes'] - info[1]) / ((self.prev['written_bytes'] - info[0]) * self.Interval)
7272
zbx.send('pgsql.cfs.activity[current_compress_ratio]', val)
73-
self.prev['writed_bytes'] = info[0]
73+
self.prev['written_bytes'] = info[0]
7474
self.prev['scanned_bytes'] = info[1]
7575

7676
zbx.send('pgsql.cfs.activity[compressed_files]', info[2], delta=self.DELTA_SPEED, only_positive_speed=True)
7777
zbx.send('pgsql.cfs.activity[scanned_files]', info[3], delta=self.DELTA_SPEED, only_positive_speed=True)
7878

7979
def items(self, template):
8080
return template.item({
81-
'name': 'PostgreSQL cfs compression: Writed byte/s',
82-
'key': 'pgsql.cfs.activity[writed_bytes]',
81+
'name': 'PostgreSQL cfs compression: written byte/s',
82+
'key': 'pgsql.cfs.activity[written_bytes]',
8383
'delay': self.Interval
8484
}) + template.item({
85-
'name': 'PostgreSQL cfs compression: Scanned byte/s',
85+
'name': 'PostgreSQL cfs compression: scanned byte/s',
8686
'key': 'pgsql.cfs.activity[scanned_bytes]',
8787
'delay': self.Interval
8888
}) + template.item({
@@ -119,9 +119,16 @@ def graphs(self, template):
119119
}]
120120
})
121121
result += template.graph({
122-
'name': 'PostgreSQL cfs compression: writed bytes',
122+
'name': 'PostgreSQL cfs compression: written bytes',
123123
'items': [{
124-
'key': 'pgsql.cfs.activity[writed_bytes]',
124+
'key': 'pgsql.cfs.activity[written_bytes]',
125+
'color': '00CC00'
126+
}]
127+
})
128+
result += template.graph({
129+
'name': 'PostgreSQL cfs compression: total ratio',
130+
'items': [{
131+
'key': 'pgsql.cfs.activity[total_compress_ratio]',
125132
'color': '00CC00'
126133
}]
127134
})
@@ -134,17 +141,17 @@ def discovery_rules(self, template):
134141
'filter': '{#COMPRESSED_RELATION}:.*'
135142
}
136143
items = [
137-
{'key': 'pgsql.cfs.relation[{#COMPRESSED_RELATION}]',
138-
'name': 'Relation {#COMPRESSED_RELATION}: compression ratio',
144+
{'key': 'pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]',
145+
'name': 'Relation {#COMPRESSED_RELATION}: compress ratio',
139146
'delay': self.Interval}
140147
]
141148
graphs = [
142149
{
143-
'name': 'Relation {#COMPRESSED_RELATION}: compression ratio',
150+
'name': 'Relation {#COMPRESSED_RELATION}: compress ratio',
144151
'delay': self.Interval,
145152
'items': [
146153
{'color': '00CC00',
147-
'key': 'pgsql.cfs.relation[{#COMPRESSED_RELATION}]'}]
154+
'key': 'pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]'}]
148155
},
149156
]
150157
return template.discovery_rule(rule=rule, items=items, graphs=graphs)

packaging/conf/template.xml

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,17 @@
274274
</applications>
275275
</item>
276276
<item>
277-
<name>PostgreSQL cfs compression: Writed byte/s</name>
277+
<name>PostgreSQL cfs compression: written byte/s</name>
278278
<type>2</type>
279279
<snmp_community/>
280280
<multiplier>0</multiplier>
281281
<inventory_link>0</inventory_link>
282-
<key>pgsql.cfs.activity[writed_bytes]</key>
282+
<key>pgsql.cfs.activity[written_bytes]</key>
283283
<snmp_oid/>
284284
<history>7</history>
285285
<trends>365</trends>
286286
<status>0</status>
287-
<delay>300</delay>
287+
<delay>60</delay>
288288
<value_type>0</value_type>
289289
<allowed_hosts/>
290290
<valuemap/>
@@ -316,7 +316,7 @@
316316
</applications>
317317
</item>
318318
<item>
319-
<name>PostgreSQL cfs compression: Scanned byte/s</name>
319+
<name>PostgreSQL cfs compression: scanned byte/s</name>
320320
<type>2</type>
321321
<snmp_community/>
322322
<multiplier>0</multiplier>
@@ -326,7 +326,7 @@
326326
<history>7</history>
327327
<trends>365</trends>
328328
<status>0</status>
329-
<delay>300</delay>
329+
<delay>60</delay>
330330
<value_type>0</value_type>
331331
<allowed_hosts/>
332332
<valuemap/>
@@ -368,7 +368,7 @@
368368
<history>7</history>
369369
<trends>365</trends>
370370
<status>0</status>
371-
<delay>300</delay>
371+
<delay>60</delay>
372372
<value_type>0</value_type>
373373
<allowed_hosts/>
374374
<valuemap/>
@@ -410,7 +410,7 @@
410410
<history>7</history>
411411
<trends>365</trends>
412412
<status>0</status>
413-
<delay>300</delay>
413+
<delay>60</delay>
414414
<value_type>0</value_type>
415415
<allowed_hosts/>
416416
<valuemap/>
@@ -452,7 +452,7 @@
452452
<history>7</history>
453453
<trends>365</trends>
454454
<status>0</status>
455-
<delay>300</delay>
455+
<delay>60</delay>
456456
<value_type>0</value_type>
457457
<allowed_hosts/>
458458
<valuemap/>
@@ -494,7 +494,7 @@
494494
<history>7</history>
495495
<trends>365</trends>
496496
<status>0</status>
497-
<delay>300</delay>
497+
<delay>60</delay>
498498
<value_type>0</value_type>
499499
<allowed_hosts/>
500500
<valuemap/>
@@ -4673,17 +4673,17 @@
46734673
<key>pgsql.cfs.discovery_compressed_relations[]</key>
46744674
<item_prototypes>
46754675
<item_prototype>
4676-
<name>Relation {#COMPRESSED_RELATION}: compression ratio</name>
4676+
<name>Relation {#COMPRESSED_RELATION}: compress ratio</name>
46774677
<type>2</type>
46784678
<snmp_community/>
46794679
<multiplier>0</multiplier>
46804680
<inventory_link>0</inventory_link>
4681-
<key>pgsql.cfs.relation[{#COMPRESSED_RELATION}]</key>
4681+
<key>pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]</key>
46824682
<snmp_oid/>
46834683
<history>7</history>
46844684
<trends>365</trends>
46854685
<status>0</status>
4686-
<delay>300</delay>
4686+
<delay>60</delay>
46874687
<value_type>0</value_type>
46884688
<allowed_hosts/>
46894689
<valuemap/>
@@ -4718,7 +4718,7 @@
47184718
<trigger_prototypes/>
47194719
<graph_prototypes>
47204720
<graph_prototype>
4721-
<name>Relation {#COMPRESSED_RELATION}: compression ratio</name>
4721+
<name>Relation {#COMPRESSED_RELATION}: compress ratio</name>
47224722
<width>900</width>
47234723
<height>200</height>
47244724
<yaxismin>0.0</yaxismin>
@@ -4744,7 +4744,7 @@
47444744
<type>0</type>
47454745
<item>
47464746
<host>PostgresPro-Linux</host>
4747-
<key>pgsql.cfs.relation[{#COMPRESSED_RELATION}]</key>
4747+
<key>pgsql.cfs.compress_ratio[{#COMPRESSED_RELATION}]</key>
47484748
</item>
47494749
</graph_item>
47504750
</graph_items>
@@ -6116,7 +6116,39 @@
61166116
</graph_items>
61176117
</graph>
61186118
<graph>
6119-
<name>PostgreSQL cfs compression: writed bytes</name>
6119+
<name>PostgreSQL cfs compression: written bytes</name>
6120+
<width>900</width>
6121+
<height>200</height>
6122+
<yaxismin>0.0</yaxismin>
6123+
<yaxismax>100.0</yaxismax>
6124+
<show_work_period>1</show_work_period>
6125+
<show_triggers>1</show_triggers>
6126+
<type>0</type>
6127+
<show_legend>1</show_legend>
6128+
<show_3d>0</show_3d>
6129+
<percent_left>0.0</percent_left>
6130+
<percent_right>0.0</percent_right>
6131+
<ymin_type_1>0</ymin_type_1>
6132+
<ymax_type_1>0</ymax_type_1>
6133+
<ymin_item_1>0</ymin_item_1>
6134+
<ymax_item_1>0</ymax_item_1>
6135+
<graph_items>
6136+
<graph_item>
6137+
<sortorder>0</sortorder>
6138+
<drawtype>0</drawtype>
6139+
<color>00CC00</color>
6140+
<yaxisside>0</yaxisside>
6141+
<calc_fnc>2</calc_fnc>
6142+
<type>0</type>
6143+
<item>
6144+
<host>PostgresPro-Linux</host>
6145+
<key>pgsql.cfs.activity[written_bytes]</key>
6146+
</item>
6147+
</graph_item>
6148+
</graph_items>
6149+
</graph>
6150+
<graph>
6151+
<name>PostgreSQL cfs compression: total ratio</name>
61206152
<width>900</width>
61216153
<height>200</height>
61226154
<yaxismin>0.0</yaxismin>
@@ -6142,7 +6174,7 @@
61426174
<type>0</type>
61436175
<item>
61446176
<host>PostgresPro-Linux</host>
6145-
<key>pgsql.cfs.activity[writed_bytes]</key>
6177+
<key>pgsql.cfs.activity[total_compress_ratio]</key>
61466178
</item>
61476179
</graph_item>
61486180
</graph_items>

0 commit comments

Comments
 (0)