Cloud computing uses Xen virtualization, and sometimes we have to roughly determine if the host is a virtual machine.
Windows host, direct Explorer to view hardware devices.
And Linux hosts can be monitored with Python scripts
Judging Openvz/xen pv/uml
Judge Openvz/xen Pv/uml is the easiest, directly check the/PROC under the relevant directories and files can be known, such as OpenVZ VPS will have/proc/vz this file, Xen PV virtual machine will have/proc/xen/this directory, and the directory has Some things; printing/proc/cpuinfo on UML will find UML flags. Wrote a simple Python script to detect:
#!/usr/bin/python# check if a linux system running on a virtual machine (OPENVZ/XEN PV/UML) Import sys, osdef main (): if os.getuid () != 0: print "Must be run as root " sys.exit (0) # check openvz/virtuozzo if os.path.exists ("/proc/vz"): if not os.path.exists ("/PROC/BC"): print "Openvz container" else: print "Openvz node" # check Xen if Os.path.exists ("/proc/xen/capabilities"): if (Os.path.getsize ("/proc/xen/capabilities") > 0): print "xen dom0" else: print "Xen domu" # check user mode linux (UML) f = open ("/proc/cpuinfo", "R"); t = f.read (); f.close () if (T.find ("UML") > 0): print "UML" if __name__== "__main__": main ()
Python determines if the Linux host on Xen virtualization is a virtual machine