使用Proxmox VE API,我想获取所有已配置的所有备份作业(在cluster/backup/{id}/
下可以找到这些状态)的状态信息。在这里,我可以看到正在备份哪些VM的虚拟机,并且应该在何时备份的但没有看到上次备份的状态(最好是最后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
。我在那里找到一个退出状态和一个控制台日志:
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
我可以从这里获得相关数据(通过解析日志):
node/{node}/tasks/{upid}/status
退出状态我所缺少的:
node/{node}/tasks/{upid}
链接到cluster/backup/{id}
的方法(对我来说node/{node}/tasks/{upid}/status/id
始终为空)有没有办法让我直接通过API获取这样的信息??
答案 0 :(得分:0)
目前没有类似的东西-您必须解析可通过nodes/{node}/tasks/{upid}/log
上的API通过API检索的日志条目。
如果您现在需要如何:Checkmk出于内部目的读取日志,则可以在BackupTask
类中的https://github.com/tribe29/checkmk/blob/master/cmk/special_agents/agent_proxmox.py中找到代码。
免责声明:我是tribe29员工,在发布此问题后 写下了这段代码。