Sys::Detect::Virtualization - Detect if a UNIX system is running as a virtual machine
Version 0.107
use Sys::Detect::Virtualization; my $detector = eval { Sys::Detect::Virtualization->new() }; if( $@ ) { print "Detector may not be supported for your platform. Error was: $@\n"; } my @found = $detector->detect(); if( @found ) { print "Possible virtualized system. May be running under:\n"; print "\t$_\n" for @found; }
This module attempts to detect whether or not a system is running as a guest under virtualization, using various heuristics.
Construct a new detector object. On success, returns the object. On failure, dies.
This constructor will fail if the system is not running a supported OS. Currently, only Linux is supported.
$args is an optional hash reference containing additional arguments for the constructor. Currently supported are:
Set to 1 if we should output verbose debugging, 0 otherwise. Defaults to 0.
Set to 1 if we should report no virtualization if a virtualization host (as opposed to guest) is detected. Defaults to 1.
Runs detection heuristics. Returns a list of possible virtualization systems, or an empty list if none were detected.
Possible hits are returned in order of most likely to least likely.
Note that the failure to detect does NOT mean the system is not virtualized -- it simply means we couldn't detect it.
Runs detection heuristics and returns a single answer based on the "best guess" available.
Currently, this is defined as the virt platform with the most heuristic hits.
You probably shouldn't ever need to call these
Returns a list of all detector subroutines for the given instance.
Returns full path to given command by searching $ENV{PATH}. If not present in the path variable, the directories /usr/sbin, /usr/bin, /sbin, and /bin are appended.
Check, linewise, the data from $fh against the patterns in $patterns.
$patterns is a listref read pairwise. The first item of each pair is the pattern, and the second item of each pair is a list of names of virt solutions detected by the pattern.
Check, linewise, the output of $command against the patterns in $patterns.
$patterns is a listref read pairwise. The first item of each pair is the pattern, and the second item of each pair is the name of the virt solution detected by the pattern.
Check, linewise, the content of each filename in $fileglob against the patterns in $patterns.
$fileglob is a glob that returns zero or more filenames.
Checks for the existence of each path in $paths.
$paths is a listref read pairwise. The first item of each pair is the path name, and the second item of each pair is the name of the virt solution detected by the existence of that $path.
Dave O'Neill, <dmo@dmo.ca>
Known issues:
No support for non-Linux platforms. Feel free to contribute an appropriate Sys::Detect::Virtualization::foo class for your platform.
No weighting of tests so that high-confidence checks can be done first. Patches welcome.
Please report any bugs or feature requests to bug-sys-detect-virtualization at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sys-Detect-Virtualization. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-sys-detect-virtualization at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Sys::Detect::Virtualization
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Detect-Virtualization
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Sys-Detect-Virtualization
CPAN Ratings
http://cpanratings.perl.org/d/Sys-Detect-Virtualization
Search CPAN
http://search.cpan.org/dist/Sys-Detect-Virtualization/
The author's blog
http://www.dmo.ca/blog/
Copyright (C) 2009 Roaring Penguin Software Inc.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Sys::Detect::Virtualization, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Detect::Virtualization
CPAN shell
perl -MCPAN -e shell install Sys::Detect::Virtualization
For more information on module installation, please visit the detailed CPAN module installation guide.