Debugging hook scripts (snippets)

danielb

Renowned Member
Jun 1, 2018
230
62
68
38
Bordeaux (france)
Hi.

I'm trying to use hook script for a VM. I've enabled the local storage to handle snippets, I put my script in /var/lib/vz/snippets/, with exec permissions, I've configured a test VM to use with

Code:
qm set 150 -hookscript local:snippets/vm_hook.pl

But it looks like it's not executed. The script is working if I execute it manually (with args 150 pre-start for example). To be sure everything is OK, I replaced my script with the sample hook found in /usr/share/pve-docs/examples/guest-example-hookscript.pl (and checkd it has exec permissions). And still, nothing in system's log (journalctl -f). So my question is : is stdout/stderr of hook scripts captured and sent to the log ? If not, what's the best way to debug ?
 
MMmmmhhh, in fact, stdout is captured, and can be seen in qmeventd logs (journalctl -fu qmeventd). But, only post-stop hook is fired. No trace of pre-start, post-start, pre-stop. I've simplified my script to be only

Code:
#!/usr/bin/perl -w
use strict;
use warnings;
print "GUEST HOOK: " . join(' ', @ARGV). "\n";

And, during a full start/stop of the guest, all I have is

Code:
May 15 16:16:45 pve1 qmeventd[1970]: Starting cleanup for 150
May 15 16:16:45 pve1 qmeventd[1970]: trying to acquire lock...
May 15 16:16:46 pve1 qmeventd[1970]:  OK
May 15 16:16:46 pve1 qmeventd[1970]: GUEST HOOK: 150 post-stop
May 15 16:16:46 pve1 qmeventd[1970]: Finished cleanup for 150

I'm running the latest updates from no-subscription
Code:
root@pve1:~# pveversion -v
proxmox-ve: 5.4-1 (running kernel: 4.15.18-14-pve)
pve-manager: 5.4-5 (running version: 5.4-5/c6fdb264)
pve-kernel-4.15: 5.4-2
pve-kernel-4.15.18-14-pve: 4.15.18-38
pve-kernel-4.15.18-12-pve: 4.15.18-36
pve-kernel-4.15.18-11-pve: 4.15.18-34
pve-kernel-4.15.18-10-pve: 4.15.18-32
pve-kernel-4.15.18-9-pve: 4.15.18-30
pve-kernel-4.15.18-8-pve: 4.15.18-28
pve-kernel-4.15.18-7-pve: 4.15.18-27
pve-kernel-4.15.18-5-pve: 4.15.18-24
pve-kernel-4.15.18-4-pve: 4.15.18-23
pve-kernel-4.15.18-2-pve: 4.15.18-21
pve-kernel-4.15.18-1-pve: 4.15.18-19
pve-kernel-4.15.17-3-pve: 4.15.17-14
pve-kernel-4.15.17-2-pve: 4.15.17-10
pve-kernel-4.15.17-1-pve: 4.15.17-9
pve-kernel-4.13.13-2-pve: 4.13.13-33
corosync: 2.4.4-pve1
criu: 2.11.1-1~bpo90
glusterfs-client: 3.8.8-1
ksm-control-daemon: 1.2-2
libjs-extjs: 6.0.1-2
libpve-access-control: 5.1-9
libpve-apiclient-perl: 2.0-5
libpve-common-perl: 5.0-51
libpve-guest-common-perl: 2.0-20
libpve-http-server-perl: 2.0-13
libpve-storage-perl: 5.0-42
libqb0: 1.0.3-1~bpo9
lvm2: 2.02.168-pve6
lxc-pve: 3.1.0-3
lxcfs: 3.0.3-pve1
novnc-pve: 1.0.0-3
openvswitch-switch: 2.7.0-3
proxmox-widget-toolkit: 1.0-26
pve-cluster: 5.0-37
pve-container: 2.0-37
pve-docs: 5.4-2
pve-edk2-firmware: 1.20190312-1
pve-firewall: 3.0-20
pve-firmware: 2.0-6
pve-ha-manager: 2.0-9
pve-i18n: 1.1-4
pve-libspice-server1: 0.14.1-2
pve-qemu-kvm: 3.0.1-2
pve-xtermjs: 3.12.0-1
qemu-server: 5.0-51
smartmontools: 6.5+svn4324-1
spiceterm: 3.0-5
vncterm: 1.5-3
zfsutils-linux: 0.7.13-pve1~bpo2

Any idea ?
 
the output of the pre/post-start hooks are captured in the task log of the start, not in the journal, same with the pre-stop hook
 
Indeed, I was only working from the cmdline and didn't even think about checking tasks logs. I'll use Sys::Syslog to have the message I'm intereted in in syslog. Thanks !
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!