From 4ffd3753a29bb1fceee8628273136a356b93f355 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 12 May 2017 21:45:56 -0700 Subject: [PATCH] Handle FreeBSD vmstat output https://github.com/webmin/webmin/issues/498 --- system-status/system-status-lib.pl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/system-status/system-status-lib.pl b/system-status/system-status-lib.pl index c80225ba2..0646ce860 100755 --- a/system-status/system-status-lib.pl +++ b/system-status/system-status-lib.pl @@ -73,18 +73,26 @@ my @drive = &get_current_drive_temps(); $info->{'drivetemps'} = \@drive if (@drive); # IO input and output -if ($gconfig{'os_type'} =~ /-linux$/) { +if ($gconfig{'os_type'} =~ /-linux$/ || $gconfig{'os_type'} eq 'freebsd') { my $out = &backquote_command("vmstat 1 2 2>/dev/null"); if (!$?) { my @lines = split(/\r?\n/, $out); my @w = split(/\s+/, $lines[$#lines]); shift(@w) if ($w[0] eq ''); - if ($w[8] =~ /^\d+$/ && $w[9] =~ /^\d+$/) { - # Blocks in and out - $info->{'io'} = [ $w[8], $w[9] ]; + if ($gconfig{'os_type'} =~ /-linux$/) { + # Linux format + if ($w[8] =~ /^\d+$/ && $w[9] =~ /^\d+$/) { + # Blocks in and out + $info->{'io'} = [ $w[8], $w[9] ]; - # CPU user, kernel, idle, io, vm - $info->{'cpu'} = [ @w[12..16] ]; + # CPU user, kernel, idle, io, vm + $info->{'cpu'} = [ @w[12..16] ]; + } + } + else { + # BSD format + # CPU user, kernel, idle + $info->{'cpu'} = [ $w[16], $w[17], $w[18], 0, 0 ]; } } }