Manage VM in console
OpenVZ
Show all OpenVZ containers:
vzlist -a
Show all OVZ templates:
ls /vz/template/cache/
Stop container:
vzctl stop <vmID>
Srart container:
vzctl start <vmID>
Restart container:
vzctl restart <vmID>
Create container:
vzctl create <vmID>
More details about CT creation: http://openvz.org/Configuring_container_creation
ovz container creation example:
vzctl create 115 --ostemplate centos-6-x86
Remove container:
vzctl destroy
For extended description refer to man vzctl. Also we recommend to read Basic operations in OpenZV environment http://openvz.org/Basic_operations_in_OpenVZ_environment
get active vz containers count:
vzlist | wc -l
get containers disk usage in %
vzlist -a -H -o hostname,diskspace,diskspace.s,veid | awk '{ printf( "%2.f%\t%s\t%s\n"), $2*100/$3, $4, $1}' | sort -r
get 10 top CPU openvz containers
ps -e h -o pid --sort -pcpu | head -10 | vzpid -
show PID containerID owner, user, exe path:
ll /proc/<PID> #or ls -l /proc/<PID>
show all containers load average:
vzlist -o ctid,laverage
SHow all possibly abusive containers. also show containers with RAM utilization/problems:
dmesg|egrep -v '(SMTP-LOG|INPUT-DROP|LIMIT-PPS-DROP|FORWARD-DROP)' TTL=64 ID=0 PROTO=UDP SPT=68 DPT=67 LEN=556
Show 10 top memory intensive processes:
ps -auxf | sort -nr -k 4 | head -10
Show 10 top CT's based on number of processes:
/usr/sbin/vzlist -H -o ctid,numproc|sort -r -n -k2|head
Show 10 top CT's based on socket usage:
/usr/sbin/vzstat -t -s sock|awk 'NF==10{print $0}'
Sort containers on TCP send /receive buffer usage:
vzlist -H -o ctid,tcpsndbuf |sort -r -n -k2 vzlist -H -o ctid,tcprcvbuf |sort -r -n -k2
Sort CT's based on inbound/outbound NW traffic:
vznetstat -r |awk '$3 ~ /G/ {print $0}'|sort -r -nk3 vznetstat -r |awk '$5 ~ /G/ {print $0}'|sort -r -nk5
KVM
Show all Virtual Machines (logical volumes):
lvdisplay
Show state of Virtual Machines:
virsh list --all
Soft shutdown VM. This will sent shutdown command to VMs OS.
virsh shutdown kvm<ID> #for example kvm101
Increase a VM's disk space
qemu-img resize vmdisk.img +10G
Soft reboot VM
virsh reboot kvm<ID>
Hard power off. This will be equal to unplugging power cord from physical machine.
virsh destroy kvm<ID>
Hard power on
virsh start kvm<ID>
For extended description refer to man virsh.
""