Skip to content

Commit 0b95fab

Browse files
committed
add graph for backup overview
1 parent 3d6c471 commit 0b95fab

File tree

3 files changed

+77
-8
lines changed

3 files changed

+77
-8
lines changed

agent_based/proxmox_bs.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def proxmox_bs_checks(item, params, section):
109109
running_tasks = []
110110
value_store = get_value_store()
111111

112+
group_count = 0
113+
total_backups = 0
114+
112115
for n, k, c in proxmox_bs_subsections_checks(section):
113116
if n == "proxmox-backup-manager task list":
114117
task_list = json.loads(c)
@@ -126,12 +129,9 @@ def proxmox_bs_checks(item, params, section):
126129
if "upid" in gc:
127130
upid = gc["upid"]
128131
if (n == "proxmox-backup-client list") and (k == item):
129-
i, n = 0, 0
130132
for e in json.loads(c):
131-
i=i+1
132-
n=n+int(e["backup-count"])
133-
yield Metric('group_count', i)
134-
yield Metric('total_backups', n)
133+
group_count=group_count+1
134+
total_backups=total_backups+int(e["backup-count"])
135135
if (n == "proxmox-backup-client snapshot list") and (k == item):
136136
nr, np, ok, nok = 0, [], 0, []
137137
try:
@@ -146,10 +146,14 @@ def proxmox_bs_checks(item, params, section):
146146
np.append(e)
147147
else:
148148
nr = nr+1
149+
yield Metric('group_count', group_count)
150+
yield Metric('total_backups', total_backups)
149151
yield Metric('verify_ok', ok)
150152
yield Metric('verify_failed', len(nok))
151153
yield Metric('verify_unknown', len(np))
152-
yield Metric('not_verified_yet', nr)
154+
yield Metric('not_verified_yet', nr,
155+
levels=(group_count, group_count*2)
156+
)
153157
yield Result(state=State.OK, summary=(
154158
'Snapshots Verified: %d' % ok
155159
))

info

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
'files': {'agent_based': ['proxmox_bs.py'],
55
'agents': ['plugins/proxmox_bs'],
66
'lib': ['check_mk/base/cee/plugins/bakery/proxmox_bs.py'],
7-
'web': ['plugins/wato/proxmox_bs.py']},
7+
'web': ['plugins/wato/proxmox_bs.py',
8+
'plugins/metrics/proxmox_bs.py']},
89
'name': 'proxmox_bs',
910
'num_files': 4,
1011
'title': 'Proxmox Backup Server',
11-
'version': '0.3.5',
12+
'version': '0.3.6',
1213
'version.min_required': '2.0.0',
1314
'version.packaged': '2.0.0p3',
1415
'version.usable_until': None}

web/plugins/metrics/proxmox_bs.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python3
2+
# -*- encoding: utf-8; py-indent-offset: 4 -*-
3+
4+
# Copyright (c) 2021 inett GmbH
5+
# License: GNU General Public License v2
6+
# A file is subject to the terms and conditions defined in the file LICENSE,
7+
# which is part of this source code package.
8+
9+
from cmk.gui.i18n import _
10+
from cmk.gui.plugins.metrics import (
11+
check_metrics,
12+
metric_info,
13+
graph_info,
14+
MB,
15+
)
16+
17+
metric_info['group_count'] = {
18+
'title': _('Number of backup groups'),
19+
'unit' : 'count',
20+
'color': indexed_color(1, 6),
21+
}
22+
23+
metric_info['total_backups'] = {
24+
'title': _('Number of backups'),
25+
'unit' : 'count',
26+
'color': indexed_color(2, 6),
27+
}
28+
metric_info['verify_ok'] = {
29+
'title': _('Snapshots successfully verified'),
30+
'unit' : 'count',
31+
'color': indexed_color(3, 6),
32+
}
33+
metric_info['verify_failed'] = {
34+
'title': _('Snapshots with failed verification'),
35+
'unit' : 'count',
36+
'color': indexed_color(4, 6),
37+
}
38+
metric_info['verify_unknown'] = {
39+
'title': _('Snapshots with unknown verification status'),
40+
'unit' : 'count',
41+
'color': indexed_color(5, 6),
42+
}
43+
metric_info['not_verified_yet'] = {
44+
'title': _('Snapshots yet to be verified'),
45+
'unit' : 'count',
46+
'color': indexed_color(6, 6),
47+
}
48+
49+
graph_info['snapshots'] = {
50+
'title': _('Backups'),
51+
'metrics': [
52+
('verify_ok', 'stack', metric_info['verify_ok']['title']),
53+
('verify_failed', 'stack', metric_info['verify_failed']['title']),
54+
('verify_unknown', 'stack', metric_info['verify_unknown']['title']),
55+
('not_verified_yet', 'stack', metric_info['not_verified_yet']['title']),
56+
],
57+
'optional_metrics': [
58+
'verify_ok',
59+
'verify_failed',
60+
'verify_unknown',
61+
'not_verified_yet',
62+
],
63+
}
64+

0 commit comments

Comments
 (0)