8000 refactoring: unified items names · postgrespro/mamonsu@ae604dc · GitHub
[go: up one dir, main page]

Skip to content

Commit ae604dc

Browse files
committed
refactoring: unified items names
1 parent b527b58 commit ae604dc

18 files changed

+143
-160
lines changed

mamonsu/plugins/pgsql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mamonsu.lib.platform as platform
22

33
__all__ = ['bgwriter', 'connections', 'databases']
4-
__all__ += ['health', 'instance', 'xlog']
4+
__all__ += ['health', 'instance', 'wal']
55
__all__ += ['statements', 'pg_buffercache', 'wait_sampling']
66
__all__ += ['checkpoint', 'oldest', 'pg_locks']
77
__all__ += ['cfs']

mamonsu/plugins/pgsql/archive_command.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class ArchiveCommand(Plugin):
5757
key = "pgsql.archive_command{0}"
5858
name = "PostgreSQL archive command {0}"
5959
Items = [
60-
# key, desc, color, side, graph
61-
("count_files_to_archive", "count files in archive_status need to archive", "9C8A4E", 0, 1),
62-
("size_files_to_archive", "size of files need to archive", "793F5D", 0, 0),
63-
("archived_files", "count archived files", "578159", 0, 1),
64-
("failed_trying_to_archive", "count attempts to archive files", "E57862", 0, 1),
60+
# key, desc, color, side, graph, delta, units
61+
("count_files_to_archive", "Files in archive_status Need to Archive Count", "9C8A4E", 0, 1, Plugin.DELTA.as_is, self.UNITS.none),
62+
("size_files_to_archive", "Files Need to Archive Size", "793F5D", 0, 0, Plugin.DELTA.as_is, self.UNITS.bytes),
63+
("archived_files", "Archived Files Count", "578159", 0, 1, Plugin.DELTA.simple_change, self.UNITS.none),
64+
("failed_trying_to_archive", "Attempts to Archive Files Count", "E57862", 0, 1, Plugin.DELTA.simple_change, self.UNITS.none),
6565
]
6666
old_archived_count = None
6767
old_failed_count = None
@@ -131,32 +131,15 @@ def run(self, zbx):
131131

132132
def items(self, template, dashboard=False):
133133
result = ""
134-
result += template.item({
135-
"key": self.right_type(self.key, self.Items[0][0]),
136-
"name": self.name.format(self.Items[0][1]),
137-
"value_type": self.VALUE_TYPE.numeric_unsigned,
138-
"delay": self.plugin_config("interval"),
139-
"delta": Plugin.DELTA.as_is
140-
}) + template.item({
141-
"key": self.right_type(self.key, self.Items[1][0]),
142-
"name": self.name.format(self.Items[1][1]),
143-
"value_type": self.VALUE_TYPE.numeric_unsigned,
144-
"units": self.UNITS.bytes,
145-
"delay": self.plugin_config("interval"),
146-
"delta": Plugin.DELTA.as_is
147-
}) + template.item({
148-
"key": self.right_type(self.key, self.Items[2][0]),
149-
"name": self.name.format(self.Items[2][1]),
150-
"value_type": self.VALUE_TYPE.numeric_unsigned,
151-
"delay": self.plugin_config("interval"),
152-
"delta": Plugin.DELTA.simple_change
153-
}) + template.item({
154-
"key": self.right_type(self.key, self.Items[3][0]),
155-
"name": self.name.format(self.Items[3][1]),
156-
"value_type": self.VALUE_TYPE.numeric_unsigned,
157-
"delay": self.plugin_config("interval"),
158-
"delta": Plugin.DELTA.simple_change
159-
})
134+
for item in self.Items:
135+
result += template.item({
136+
"key": self.right_type(self.key, self.Items[0][0]),
137+
"name": "PostgreSQL Archiver: {0}".format(self.name.format(self.Items[0][1])),
138+
"value_type": self.VALUE_TYPE.numeric_unsigned,
139+
"delay": self.plugin_config("interval"),
140+
"delta": self.Items[0][5],
141+
"units": self.Items[0][6]
142+
})
160143
if not dashboard:
161144
return result
162145
else:

mamonsu/plugins/pgsql/bgwriter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@ class BgWriter(Plugin):
1717
# ('graph name', color, side), units, delta
1818

1919
("buffers_checkpoint", "bgwriter[buffers_checkpoint]",
20-
"bgwriter: buffers written during checkpoints",
20+
"Buffers Written During Checkpoints",
2121
("PostgreSQL bgwriter", "793F5D", 1),
2222
Plugin.DELTA.simple_change),
2323

2424
("buffers_clean", "bgwriter[buffers_clean]",
25-
"bgwriter: buffers written",
25+
"Buffers Written",
2626
("PostgreSQL bgwriter", "9C8A4E", 1),
2727
Plugin.DELTA.simple_change),
2828

2929
("maxwritten_clean", "bgwriter[maxwritten_clean]",
30-
"bgwriter: number of bgwriter stopped by max write count",
30+
"Number of bgwriter Stopped by Max Write Count",
3131
("PostgreSQL bgwriter", "8B817C", 0),
3232
Plugin.DELTA.simple_change),
3333

3434
("buffers_backend", "bgwriter[buffers_backend]",
35-
"bgwriter: buffers written directly by a backend",
35+
"Buffers Written Directly by a Backend",
3636
("PostgreSQL bgwriter", "7EB29B", 1),
3737
Plugin.DELTA.simple_change),
3838

3939
("buffers_backend_fsync", "bgwriter[buffers_backend_fsync]",
40-
"bgwriter: times a backend execute its own fsync",
40+
"Times a Backend Execute Its Own Fsync",
4141
("PostgreSQL bgwriter", "00B0B8", 0),
4242
Plugin.DELTA.simple_change),
4343

4444
("buffers_alloc", "bgwriter[buffers_alloc]",
45-
"bgwriter: buffers allocated",
45+
"Buffers Allocated",
4646
("PostgreSQL bgwriter", "3B415A", 1),
4747
Plugin.DELTA.simple_change)
4848
]
4949

50-
graph_name_buffers = "PostgreSQL bgwriter buffers"
51-
graph_name_ws = "PostgreSQL bgwriter write/sync"
50+
graph_name_buffers = "PostgreSQL bgwriter: Buffers"
51+
graph_name_ws = "PostgreSQL bgwriter: Write/Sync"
5252

5353
def run(self, zbx):
5454
columns = [x[0] for x in self.Items]
@@ -67,7 +67,7 @@ def items(self, template, dashboard=False):
6767
for item in self.Items:
6868
result += template.item({
6969
"key": self.right_type(self.key, item[0]),
70-
"name": "PostgreSQL {0}".format(item[2]),
70+
"name": "PostgreSQL bgwriter: {0}".format(item[2]),
7171
"value_type": self.VALUE_TYPE.numeric_unsigned,
7272
"delay": self.plugin_config("interval"),
7373
"delta": delta

mamonsu/plugins/pgsql/cfs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,32 @@ def run(self, zbx):
9595
def items(self, template, dashboard=False):
9696
if not dashboard:
9797
return template.item({
98-
"name": "PostgreSQL cfs compression: written byte/s",
98+
"name": "PostgreSQL CFS: Written byte/s",
9999
"key": "pgsql.cfs.activity[written_bytes]",
100100
"units": self.UNITS.bytes_per_second,
101101
"delay": self.Interval
102102
}) + template.item({
103-
"name": "PostgreSQL cfs compression: scanned byte/s",
103+
"name": "PostgreSQL CFS: Scanned byte/s",
104104
"key": "pgsql.cfs.activity[scanned_bytes]",
105105
"units": self.UNITS.bytes_per_second,
106106
"delay": self.Interval
107107
}) + template.item({
108-
"name": "PostgreSQL cfs compression: compressed files",
108+
"name": "PostgreSQL CFS: Compressed Files",
109109
"key": "pgsql.cfs.activity[compressed_files]",
110110
"units": self.UNITS.none,
111111
"delay": self.Interval
112112
}) + template.item({
113-
"name": "PostgreSQL cfs compression: scanned files",
113+
"name": "PostgreSQL CFS: Scanned Files",
114114
"key": "pgsql.cfs.activity[scanned_files]",
115115
"units": self.UNITS.none,
116116
"delay": self.Interval
117117
}) + template.item({
118-
"name": "PostgreSQL cfs compression: current ratio",
118+
"name": "PostgreSQL CFS: Current Ratio",
119119
"key": "pgsql.cfs.activity[current_compress_ratio]",
120120
"units": self.UNITS.none,
121121
"delay": self.Interval
122122
}) + template.item({
123-
"name": "PostgreSQL cfs compression: total ratio",
123+
"name": "PostgreSQL CFS: Total Ratio",
124124
"key": "pgsql.cfs.activity[total_compress_ratio]",
125125
"units": self.UNITS.none,
126126
"delay": self.Interval

mamonsu/plugins/pgsql/checkpoint.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,28 @@ class Checkpoint(Plugin):
2828
# ('graph name', color, side), units, delta, factor
2929

3030
("checkpoints_timed", "count_timed",
31-
"checkpoints: by timeout (in hour)",
32-
("PostgreSQL checkpoint", "578159", 0),
31+
"by Timeout (in hour)",
32+
("PostgreSQL: checkpoint", "578159", 0),
3333
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
3434

3535
("checkpoints_req", "count_wal",
36-
"checkpoints: by wal (in hour)",
37-
("PostgreSQL checkpoint", "793F5D", 0),
36+
"by WAL (in hour)",
37+
("PostgreSQL: Checkpoint", "793F5D", 0),
3838
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
3939

4040
("checkpoint_write_time", "write_time",
41-
"checkpoint: write time",
42-
("PostgreSQL checkpoints", "00B0B8", 1),
41+
"Write Time",
42+
("PostgreSQL: Checkpoints", "00B0B8", 1),
4343
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
4444

4545
("checkpoint_sync_time", "checkpoint_sync_time",
46-
"checkpoint: sync time",
47-
("PostgreSQL checkpoints", "9C8A4E", 1),
46+
"Sync Time",
47+
("PostgreSQL: checkpoints", "9C8A4E", 1),
4848
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
4949
]
5050

51-
graph_name_count = "PostgreSQL checkpoints count"
52-
graph_name_ws = "PostgreSQL checkpoints write/sync"
51+
graph_name_count = "PostgreSQL Checkpoints: Count (in hour)"
52+
graph_name_ws = "PostgreSQL Checkpoints: Write/Sync"
5353

5454
def run(self, zbx):
5555
columns = [x[0] for x in self.Items]
@@ -68,7 +68,7 @@ def items(self, template, dashboard=False):
6868
for item in self.Items:
6969
result += template.item({
7070
"key": self.right_type(self.key, item[1]),
71-
"name": "PostgreSQL {0}".format(item[2]),
71+
"name": "PostgreSQL Checkpoints: {0}".format(item[2]),
7272
"value_type": Plugin.VALUE_TYPE.numeric_float,
7373
"units": item[4],
7474
"delay": self.plugin_config("interval"),
@@ -107,13 +107,13 @@ def graphs(self, template, dashboard=False):
107107
return result
108108
else:
109109
return [{
110-
"dashboard": {"name": "PostgreSQL checkpoints count",
110+
"dashboard": {"name": "PostgreSQL Checkpoints: Count (in hour)",
111111
"page": ZbxTemplate.dashboard_page_overview["name"],
112112
"size": ZbxTemplate.dashboard_widget_size_medium,
113113
"position": 9}
114114
},
115115
{
116-
"dashboard": {"name": "PostgreSQL checkpoints write/sync",
116+
"dashboard": {"name": "PostgreSQL Checkpoints: Write/Sync",
117117
"page": ZbxTemplate.dashboard_page_overview["name"],
118118
"size": ZbxTemplate.dashboard_widget_size_medium,
119119
"position": 10}

mamonsu/plugins/pgsql/connections.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ class Connections(Plugin):
1414
}
1515
# (state, key, name, graph item color)
1616
Items = [
17-
("active", "active", "number of active user connections", "578159"),
18-
("idle", "idle", "number of idle user connections", "8B817C"),
17+
("active", "active", "Number of Active User Connections", "578159"),
18+
("idle", "idle", "Number of Idle User Connections", "8B817C"),
1919
("idle in transaction", "idle_in_transaction",
20-
"number of user idle in transaction connections", "9C8A4E"),
20+
"Number of Idle in Transaction User Connections", "9C8A4E"),
2121
("idle in transaction (aborted)", "idle_in_transaction_aborted",
22-
"number of user idle in transaction (aborted) connections", "F6CB93"),
22+
"Number of Idle in Transaction (Aborted) User Connections", "F6CB93"),
2323
("fastpath function call", "fastpath_function_call",
24-
"number of user fastpath function call connections", "00B0B8"),
24+
"Number of Fastpath Function Call User Connections", "00B0B8"),
2525
("disabled", "disabled",
26-
"number of user disabled connections",
26+
"Number of Disabled User Connections",
2727
"3B415A")
2828
]
2929

@@ -68,7 +68,7 @@ class Connections(Plugin):
6868
WHERE name = 'max_connections';
6969
"""
7070
key = "pgsql.connections{0}"
71-
graph_name = "PostgreSQL connections"
71+
graph_name = "PostgreSQL Connections: Overview"
7272

7373
def run(self, zbx):
7474
if Pooler.is_bootstraped() and Pooler.bootstrap_version_greater("2.3.4"):
@@ -141,31 +141,31 @@ def run(self, zbx):
141141

142142
def items(self, template, dashboard=False):
143143
result = template.item({
144-
"name": "PostgreSQL: number of user total connections",
144+
"name": "PostgreSQL Connections: Number of Total User Connections",
145145
"key": self.right_type(self.key, "total"),
146146
"delay": self.plugin_config("interval")
147147
})
148148
result += template.item({
149-
"name": "PostgreSQL: number of user waiting connections",
149+
"name": "PostgreSQL Connections: Number of Waiting User Connections",
150150
"key": self.right_type(self.key, "waiting"),
151151
"delay": self.plugin_config("interval")
152152
})
153153
result += template.item({
154-
"name": "PostgreSQL: max connections",
154+
"name": "PostgreSQL Connections: Max Connections",
155155
"key": self.right_type(self.key, "max_connections"),
156156
"delay": self.plugin_config("interval")
157157
})
158158

159159
for item in self.Items:
160160
result += template.item({
161-
"name": "PostgreSQL: {0}".format(item[2]),
161+
"name": "PostgreSQL Connections: {0}".format(item[2]),
162162
"key": self.right_type(self.key, item[1]),
163163
"delay": self.plugin_config("interval")
164164
})
165165

166166
if Pooler.server_version_greater("10.0"):
167167
result += template.item({
168-
"name": "PostgreSQL: number of other connections",
168+
"name": "PostgreSQL Connections: Number of Other Connections",
169169
"key": self.right_type(self.key, "other"),
170170
"delay": self.plugin_config("interval")
171171
})

mamonsu/plugins/pgsql/databases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def run(self, zbx):
9191
def items(self, template, dashboard=False):
9292
if not dashboard:
9393
return template.item({
94-
"name": "PostgreSQL: count of autovacuum workers",
94+
"name": "PostgreSQL Autovacuum: Count of Autovacuum Workers",
9595
"key": self.right_type(self.key_autovacumm),
9696
"delay": self.plugin_config("interval")
9797
})

mamonsu/plugins/pgsql/health.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ def items(self, template, dashboard=False):
4646
delay = 5 # TODO check delay
4747
value_type = Plugin.VALUE_TYPE.numeric_float
4848
result += template.item({
49-
"name": "PostgreSQL: ping",
49+
"name": "PostgreSQL Health: Ping",
5050
"key": self.right_type(self.key_ping),
5151
"value_type": Plugin.VALUE_TYPE.numeric_float,
5252
"units": Plugin.UNITS.ms,
5353
"delay": delay
5454
}) + template.item({
55-
"name": "PostgreSQL: cache hit ratio",
55+
"name": "PostgreSQL Health: Cache Hit Ratio",
5656
"key": self.right_type(self.key_cache, "hit"),
5757
"value_type": Plugin.VALUE_TYPE.numeric_float,
5858
"units": Plugin.UNITS.percent,
5959
"type": Plugin.TYPE.CALCULATED,
6060
"params": "last(pgsql.blocks[hit])*100/(last(pgsql.blocks[hit])+last(pgsql.blocks[read]))"
6161
}) + template.item({
62-
"name": "PostgreSQL: service uptime",
62+
"name": "PostgreSQL Health: Service Uptime",
6363
"key": self.right_type(self.key_uptime),
6464
"value_type": value_type,
6565
"delay": delay,
6666
"units": Plugin.UNITS.unixtime
6767
}) + template.item({
68-
"name": "PostgreSQL: server version",
68+
"name": "PostgreSQL Health: Server Version",
6969
"key": self.right_type(self.key_version),
7070
"value_type": Plugin.VALUE_TYPE.text,
7171
"delay": delay,

0 commit comments

Comments
 (0)
0