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 56
56
exit 1;
57
57
}
58
58
59
- my $script_version =" 1.0.0 " ;
59
+ my $script_version =" 1.0.1 " ;
60
60
my $script_name =" postgresqltuner.pl" ;
61
61
my $min_s =60;
62
62
my $hour_s =60*$min_s ;
@@ -297,23 +297,30 @@ sub usage {
297
297
# Hardware
298
298
my $hypervisor =undef ;
299
299
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
+ }
317
324
}
318
325
}
319
326
}
You can’t perform that action at this time.
0 commit comments