File tree Expand file tree Collapse file tree 1 file changed +25
-18
lines changed
Expand file tree Collapse file tree 1 file changed +25
-18
lines changed Original file line number Diff line number Diff line change 5656 exit 1;
5757}
5858
59- my $script_version =" 1.0.0 " ;
59+ my $script_version =" 1.0.1 " ;
6060my $script_name =" postgresqltuner.pl" ;
6161my $min_s =60;
6262my $hour_s =60*$min_s ;
@@ -297,23 +297,30 @@ sub usage {
297297 # Hardware
298298 my $hypervisor =undef ;
299299 if ($os -> {name } ne ' darwin' ) {
300- my @dmesg =os_cmd(" dmesg" );
301- foreach my $line (@dmesg ) {
302- if ($line =~ / vmware/i ) {
303- $hypervisor =' VMware' ;
304- last ;
305- } elsif ($line =~ / kvm/i ) {
306- $hypervisor =' KVM' ;
307- last ;
308- } elsif ($line =~ / xen/i ) {
309- $hypervisor =' XEN' ;
310- last ;
311- } elsif ($line =~ / vbox/i ) {
312- $hypervisor =' VirtualBox' ;
313- last ;
314- } elsif ($line =~ / hyper-v/i ) {
315- $hypervisor =' Hyper-V' ;
316- last ;
300+ my $systemd = os_cmd(' systemd-detect-virt --vm' );
301+ if (defined ($systemd )) {
302+ if ($systemd =~ m / (\S +)/ ) {
303+ $hypervisor = $1 if ($1 ne ' none' );
304+ }
305+ } else {
306+ my @dmesg =os_cmd(" dmesg" );
307+ foreach my $line (@dmesg ) {
308+ if ($line =~ / vmware/i ) {
309+ $hypervisor =' VMware' ;
310+ last ;
311+ } elsif ($line =~ / kvm/i ) {
312+ $hypervisor =' KVM' ;
313+ last ;
314+ } elsif ($line =~ / xen/i ) {
315+ $hypervisor =' XEN' ;
316+ last ;
317+ } elsif ($line =~ / vbox/i ) {
318+ $hypervisor =' VirtualBox' ;
319+ last ;
320+ } elsif ($line =~ / hyper-v/i ) {
321+ $hypervisor =' Hyper-V' ;
322+ last ;
323+ }
317324 }
318325 }
319326 }
You can’t perform that action at this time.
0 commit comments