|
Guides All Guides and HOWTO's. |
|
Thread Tools | Display Modes |
|
|||
Logging OpenBSD virtual machine console output
A shell script to start an OpenBSD VM and log the console input/output to an unique log file
The name of the logs start with the VM name followed by DDMM_HHMMSS.log Code:
18259 Aug 1 04:15 vmlogs/alix_new0731_221336.log 11549 Aug 9 04:39 vmlogs/alix_new0809_043239.log Code:
LOGFILE="${LOGDIR}/${VMNAME}$(date -j "+%m%d_%H%M%S").log" Some alternatives shown on the shell command line: Code:
$ date -j "+%m%d_%H:%M:%S" 0809_05:37:05 $ date -j "+%m%d_%H_%M_%S" 0809_05_37_56 $ date -j "+%b%d_%H_%M_%S" Aug09_05_43_59 Code:
# if variable VMNAME is not defined you will be prompted to select a VM # USAGE options: # 1) $ env VMNAME=alix_new ./dovm.sh # 2) $ export VMNAME=alix_new ; ./dovm.sh # 3) Define the shell variable VMNAME in the script # 4) Just run './dovm.sh' and select a stopped VM from a menu # 5) If you place it in your $HOMEDIR/bin directory: $ dovm.sh Code:
$ dovm.sh ID PID VCPUS MAXMEM CURMEM TTY OWNER STATE NAME 1 - 1 1.0G - - adriaan:wheel stopped df-us 2 - 1 1.0G - - adriaan:wheel stopped siralas-clone 3 - 1 1.0G - - adriaan:wheel stopped hetzner 4 - 1 500M - - adriaan:wheel stopped alix_new Select 'ID' number of VM to start : 3 Script started on Tue Aug 9 05:56:44 2022 Connected to /dev/ttypb (speed 115200) Using drive 0, partition 3. Loading...... probing: pc0 com0 mem[638K 1022 a20=on] disk: hd0+ >> OpenBSD/amd64 BOOT 3.53 com0: 115200 baud switching console to com0 >> OpenBSD/amd64 BOOT 3.53 [snip] root@df-us[~]shutdown -hp now Shutdown NOW! shutdown: [pid 33853] *** FINAL System shutdown message from root@df-us.utp.xnet *** System going down IMMEDIATELY root@df-us[~] System shutdown time has arrived root@df-us[~]syncing disks... done vmmci0: powerdown The operating system has halted. Please press any key to reboot. Code:
[EOT] Script done, output file is /home/adriaan/vmlogs/hetzner0809_055644.log Code:
------------------------------------------------------------------------------ HINT: You can use col(1) to filter out backspaces on messy lines like this: ------------------------------------------------------------------------------ [snip] ^MGet/Verify SHA256.sig 0% | | 0 --:-- ETA^MGet/Verify SHA256.sig 100% |**************************| 2144 00:00 Signature Verified ^MGet/Verify bsd 0% | | 0 --:-- ETA^MGet/Verify bsd 8% |** | 1792 KB 00:11 ETA^MGet/Verify bsd 17% |**** [snip] For example: $ col -b <df-us0724_023205.log | less [snip] Get/Verify SHA256.sig 100% |**************************| 2144 00:00 ETA Signature Verified Get/Verify bsd 100% |**************************| 22339 KB 00:11 ETA Get/Verify bsd.rd 100% |**************************| 4498 KB 00:02 ETA [snip] Neat huh? Code:
#SHOW_COL_HINT=0 SHOW_COL_HINT=1
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 9th August 2022 at 04:32 AM. |
Tags |
virtual machine, virtualization, vmctl, vmm |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Virtual Machine | J65nko | OpenBSD General | 8 | 9th May 2019 12:21 AM |
Running Virtual Machine Manager on OpenBSD Host! | mbzadegan | OpenBSD Packages and Ports | 1 | 22nd May 2017 10:01 AM |
Create OpenBSD guest for Linux KVM (Kernel-based Virtual Machine) with 'virt-install' | J65nko | Guides | 4 | 11th December 2014 04:30 AM |
can't login on virtual console | spermwhale_warrior | OpenBSD General | 3 | 19th July 2014 05:05 PM |
Network failure and output dumping onto console | JMJ_coder | NetBSD General | 17 | 17th May 2008 02:27 AM |