Find out if the OS is running in a virtual environment
Linux adds the hypervisor
flag to /proc/cpuinfo
if the kernel detects running on some sort of a hypervisor.
On Linux you can use the command virt-what
[root@myhost]# virt-what
vmware
Example Output for a linux on Windows HyperV
[root@linuxvm11~] # virt-what
hyperv
This worked better for me as it gives me specific information about the manufacturer and the product name.
dmidecode -t system|grep 'Manufacturer\|Product'
Output on Dell server:
Manufacturer: Dell Inc.
Product Name: PowerEdge C5220
Output on Virtualbox VM:
Manufacturer: innotek GmbH
Product Name: VirtualBox
Output on KVM/QEMU:
Manufacturer: QEMU
Product Name: Standard PC (i440FX + PIIX, 1996)
This is great for scripts that can parse these out for better identification of servers... but if you use Chef in your infrastructure, you can check the node attribute Virtualization -> system
in the chef server .