如何通过 Proxmox VE API 获取 VM 备份状态?

How to get VM backup status via Proxmox VE API?

使用 Proxmox VE API 我想获取所有已配置 备份作业 的状态信息(您可以在下面找到 cluster/backup/{id}/)。在那里我可以看到正在备份哪些虚拟机以及何时备份应该发生但我看不到上次备份的状态(最好是最后一个 N).

我需要的是这样的信息:

VMID  |   Job-ID  |             Started | Status | Duration  |   Size
 123  | a39..8ab  | 2020-01-16 00:00:02 |     OK |     1:23  | 7.81GB
 131  | f3h..ab4  | 2020-01-16 00:00:02 |     OK |     0:37  | 1.23GB

可以看到的是给定节点上已经运行的任务列表,比如node/{node}/tasks/{upid}/status|log。我在那里找到了 exit statusconsole log:

INFO: starting new backup job: vzdump 101 102 103 104 105 100 --compress lzo --quiet 1 --storage QNAP --mailnotification always --mode snapshot --mailto ***@**.com
INFO: Starting Backup of VM 100 (qemu)
INFO: Backup started at 2020-01-16 00:00:02
INFO: status = running
INFO: update VM 100: -lock backup
INFO: VM Name: ****.**.tribe29.com
INFO: include disk 'scsi0' 'local-zfs:vm-100-disk-0' 60G
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: creating archive '/mnt/pve/QNAP/dump/vzdump-qemu-100-2020_01_16-00_00_02.vma.lzo'
INFO: started backup task 'd9f7c327-e610-4e38-931e-2251c9548e76'
INFO: status: 0% (319356928/64424509440), sparse 0% (115822592), duration 4, read/write 79/50 MB/s
INFO: status: 1% (678428672/64424509440), sparse 0% (151867392), duration 7, read/write 119/107 MB/s
INFO: status: 2% (1372258304/64424509440), sparse 0% (212226048), duration 17, read/write 69/63 MB/s
...
INFO: status: 98% (63369576448/64424509440), sparse 85% (54797918208), duration 164, read/write 399/86 MB/s
INFO: status: 100% (64424509440/64424509440), sparse 86% (55852843008), duration 165, read/write 1054/0 MB/s
INFO: transferred 64424 MB in 165 seconds (390 MB/s)
INFO: archive file size: 4.53GB

可以从这里获取相关数据(通过解析日志):

我缺少的是:

那么有没有办法让我直接通过 API 获取这样的信息:?

目前没有这样的东西 - 您必须解析可以通过 nodes/{node}/tasks/{upid}/log 上的 API 检索的日志条目。

如果您现在需要如何:Checkmk 读取日志用于内部目的,您可以在此处找到代码:https://github.com/tribe29/checkmk/blob/master/cmk/special_agents/agent_proxmox.py,在 class BackupTask.

免责声明:我是 tribe29 的员工,在发布此问题后编写了这段代码。