Thank you for the detailed answer! I would never have discovered this otherwise. (Maybe I should document it somewhere?)
I used the info you provided to search source code - it seems part of the logline is constructed in
pve-common/src/PVE/Tools.pm.
1. One question - what is “dtype”? Are the various possible values stored somewhere?
I just checked
/var/log/pveproxy/access.log - here are the equivalent log lines there.
Starting a VM:
Code:
127.0.0.1 - root@pam [03/07/2019:23:06:17 +1000] "POST /api2/extjs/nodes/syd1/qemu/108/status/start HTTP/1.1" 200 81
Shutdown a VM:
Code:
127.0.0.1 - root@pam [03/07/2019:23:07:20 +1000] "POST /api2/extjs/nodes/syd1/qemu/108/status/shutdown HTTP/1.1" 200 84
Cloning a VM:
Code:
127.0.0.1 - root@pam [03/07/2019:23:08:01 +1000] "POST /api2/extjs/nodes/syd1/qemu/104/clone HTTP/1.1" 200 81
I had a look in
/var/log/pve/tasks as well - it seems this is more detailed info, which is what I need. For example:
Code:
root@syd1:/var/log/pve/tasks/3# cat "UPID:syd1:0013547F:0201D71B:5D147AA3:qmclone:105:kyosan@example.com:"
create linked clone of drive efidisk0 (vm-storage:base-105-disk-1)
clone base-105-disk-1: base-105-disk-1 snapname __base__ to vm-135-disk-0
create linked clone of drive sata0 (vm-storage:base-105-disk-0)
clone base-105-disk-0: base-105-disk-0 snapname __base__ to vm-135-disk-1
TASK OK
I had a look in
/var/log/pve/tasks/index - however, I’m not sure how this file works.
2. How do you map a particular task to a subdirectory under /var/log/pve/tasks?
3. How long are tasks preserved here, before they are rotated out?
4. The friendly name for the clone doesn’t appear to be printed anywhere? Can you get this somewhere else?
5. Likewise, in the task log for qmclone - it mentions the disk (e.g. base-105-disk-0) - but how do you get the friendly name for VM 105?
I also looked at the
pvenode task list command:
Code:
root@syd1:/var/log/pve/tasks/3# pvenode task list --type qmcreate
┌─────────────────────────────────────────────────────────────┬──────────┬─────┬──────────┬────────────┬────────────┬────────┐
│ UPID │ Type │ ID │ User │ Starttime │ Endtime │ Status │
├─────────────────────────────────────────────────────────────┼──────────┼─────┼──────────┼────────────┼────────────┼────────┤
│ UPID:syd1:000B4ACF:012C738E:5D0F5189:qmcreate:131:root@pam: │ qmcreate │ 131 │ root@pam │ 1561285001 │ 1561285001 │ OK │
└─────────────────────────────────────────────────────────────┴──────────┴─────┴──────────┴────────────┴────────────┴────────┘
root@syd1:/var/log/pve/tasks/3# pvenode task list --type qmclone
┌───────────────────────────────────────────────────────────────────────┬─────────┬─────┬─────────────────────┬────────────┬────────────┬────────┐
│ UPID │ Type │ ID │ User │ Starttime │ Endtime │ Status │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:000229D3:0037CCD3:5D0FE60D:qmclone:105:naandi@example.com: │ qmclone │ 105 │ naandi@example.com │ 1561323021 │ 1561323022 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:0008B98C:00E770FD:5D11A7B2:qmclone:104:root@pam: │ qmclone │ 104 │ root@pam │ 1561438130 │ 1561438130 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:000A506E:0112ACD6:5D1CA8B1:qmclone:104:root@pam: │ qmclone │ 104 │ root@pam │ 1562159281 │ 1562159281 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:000AC746:011F0FF5:5D1CC867:qmclone:105:rupais@example.com: │ qmclone │ 105 │ rupais@example.com │ 1562167399 │ 1562167399 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:001316E6:01FC7BEB:5D146CEC:qmclone:105:kyosan@example.com: │ qmclone │ 105 │ kyosan@example.com │ 1561619692 │ 1561619693 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:00131985:01FCAE8A:5D146D6E:qmclone:105:kyosan@example.com: │ qmclone │ 105 │ kyosan@example.com │ 1561619822 │ 1561619823 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:00132079:01FD3FAA:5D146EE2:qmclone:102:kyosan@example.com: │ qmclone │ 102 │ kyosan@example.com │ 1561620194 │ 1561620194 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:00134B36:020141CA:5D147924:qmclone:105:root@pam: │ qmclone │ 105 │ root@pam │ 1561622820 │ 1561622821 │ OK │
├───────────────────────────────────────────────────────────────────────┼─────────┼─────┼─────────────────────┼────────────┼────────────┼────────┤
│ UPID:syd1:0013547F:0201D71B:5D147AA3:qmclone:105:kyosan@example.com: │ qmclone │ 105 │ kyosan@example.com │ 1561623203 │ 1561623203 │ OK │
└───────────────────────────────────────────────────────────────────────┴─────────┴─────┴─────────────────────┴────────────┴────────────┴────────┘
It seems like an alternative way to get the data versus
/var/log/pve/tasks
What are the pros/cons of this command, versus watching the log files? (I assume I’d have to setup a filesystem watch process to watch for new files in /var/log/pve/tasks, versus just running
pvenode task list every 1 minute etc.)
Does it make sense for Proxmox to store this data in a database somewhere?
My other thought was using the new hookscript functionality - but not sure how easy it’d be to get all of these fields at VM creation time?
What do you think?