Skip to content

Commit

Permalink
add graph for backup overview
Browse files Browse the repository at this point in the history
  • Loading branch information
nedjitef committed Dec 7, 2021
1 parent 3d6c471 commit 0b95fab
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 8 deletions.
16 changes: 10 additions & 6 deletions agent_based/proxmox_bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def proxmox_bs_checks(item, params, section):
running_tasks = []
value_store = get_value_store()

group_count = 0
total_backups = 0

for n, k, c in proxmox_bs_subsections_checks(section):
if n == "proxmox-backup-manager task list":
task_list = json.loads(c)
Expand All @@ -126,12 +129,9 @@ def proxmox_bs_checks(item, params, section):
if "upid" in gc:
upid = gc["upid"]
if (n == "proxmox-backup-client list") and (k == item):
i, n = 0, 0
for e in json.loads(c):
i=i+1
n=n+int(e["backup-count"])
yield Metric('group_count', i)
yield Metric('total_backups', n)
group_count=group_count+1
total_backups=total_backups+int(e["backup-count"])
if (n == "proxmox-backup-client snapshot list") and (k == item):
nr, np, ok, nok = 0, [], 0, []
try:
Expand All @@ -146,10 +146,14 @@ def proxmox_bs_checks(item, params, section):
np.append(e)
else:
nr = nr+1
yield Metric('group_count', group_count)
yield Metric('total_backups', total_backups)
yield Metric('verify_ok', ok)
yield Metric('verify_failed', len(nok))
yield Metric('verify_unknown', len(np))
yield Metric('not_verified_yet', nr)
yield Metric('not_verified_yet', nr,
levels=(group_count, group_count*2)
)
yield Result(state=State.OK, summary=(
'Snapshots Verified: %d' % ok
))
Expand Down
5 changes: 3 additions & 2 deletions info
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
'files': {'agent_based': ['proxmox_bs.py'],
'agents': ['plugins/proxmox_bs'],
'lib': ['check_mk/base/cee/plugins/bakery/proxmox_bs.py'],
'web': ['plugins/wato/proxmox_bs.py']},
'web': ['plugins/wato/proxmox_bs.py',
'plugins/metrics/proxmox_bs.py']},
'name': 'proxmox_bs',
'num_files': 4,
'title': 'Proxmox Backup Server',
'version': '0.3.5',
'version': '0.3.6',
'version.min_required': '2.0.0',
'version.packaged': '2.0.0p3',
'version.usable_until': None}
64 changes: 64 additions & 0 deletions web/plugins/metrics/proxmox_bs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# Copyright (c) 2021 inett GmbH
# License: GNU General Public License v2
# A file is subject to the terms and conditions defined in the file LICENSE,
# which is part of this source code package.

from cmk.gui.i18n import _
from cmk.gui.plugins.metrics import (
check_metrics,
metric_info,
graph_info,
MB,
)

metric_info['group_count'] = {
'title': _('Number of backup groups'),
'unit' : 'count',
'color': indexed_color(1, 6),
}

metric_info['total_backups'] = {
'title': _('Number of backups'),
'unit' : 'count',
'color': indexed_color(2, 6),
}
metric_info['verify_ok'] = {
'title': _('Snapshots successfully verified'),
'unit' : 'count',
'color': indexed_color(3, 6),
}
metric_info['verify_failed'] = {
'title': _('Snapshots with failed verification'),
'unit' : 'count',
'color': indexed_color(4, 6),
}
metric_info['verify_unknown'] = {
'title': _('Snapshots with unknown verification status'),
'unit' : 'count',
'color': indexed_color(5, 6),
}
metric_info['not_verified_yet'] = {
'title': _('Snapshots yet to be verified'),
'unit' : 'count',
'color': indexed_color(6, 6),
}

graph_info['snapshots'] = {
'title': _('Backups'),
'metrics': [
('verify_ok', 'stack', metric_info['verify_ok']['title']),
('verify_failed', 'stack', metric_info['verify_failed']['title']),
('verify_unknown', 'stack', metric_info['verify_unknown']['title']),
('not_verified_yet', 'stack', metric_info['not_verified_yet']['title']),
],
'optional_metrics': [
'verify_ok',
'verify_failed',
'verify_unknown',
'not_verified_yet',
],
}

0 comments on commit 0b95fab

Please sign in to comment.