(plugin) os::windows::wsman - mode cpu fixes (#4300)
This commit is contained in:
parent
31f96269c4
commit
40b92d6381
|
@ -38,13 +38,22 @@ sub custom_cpu_avg_calc {
|
||||||
$skipped = 0;
|
$skipped = 0;
|
||||||
next if (!defined($options{old_datas}->{$_}));
|
next if (!defined($options{old_datas}->{$_}));
|
||||||
$buffer = 0;
|
$buffer = 0;
|
||||||
|
if($options{old_datas}->{$prefix . '_PercentProcessorTime'} > $options{new_datas}->{$prefix . '_PercentProcessorTime'}) {
|
||||||
|
$options{old_datas}->{$prefix . '_PercentProcessorTime'} = 0;
|
||||||
|
}
|
||||||
|
if($options{old_datas}->{$prefix . '_Timestamp_Sys100NS'} > $options{new_datas}->{$prefix . '_Timestamp_Sys100NS'}) {
|
||||||
|
$options{old_datas}->{$prefix . '_Timestamp_Sys100NS'} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
#Cal Method ref: http://technet.microsoft.com/en-us/library/cc757283%28WS.10%29.aspx
|
#Cal Method ref: http://technet.microsoft.com/en-us/library/cc757283%28WS.10%29.aspx
|
||||||
#
|
#
|
||||||
$total_cpu += (1 - ( $options{new_datas}->{$prefix . '_PercentProcessorTime'} - $options{old_datas}->{$prefix . '_PercentProcessorTime'} ) /
|
my $cpu_core = (1 - ( $options{new_datas}->{$prefix . '_PercentProcessorTime'} - $options{old_datas}->{$prefix . '_PercentProcessorTime'} ) /
|
||||||
( $options{new_datas}->{$prefix . '_Timestamp_Sys100NS'} - $options{old_datas}->{$prefix . '_Timestamp_Sys100NS'} ) ) * 100;
|
( $options{new_datas}->{$prefix . '_Timestamp_Sys100NS'} - $options{old_datas}->{$prefix . '_Timestamp_Sys100NS'} ) ) * 100;
|
||||||
$count++;
|
if ($cpu_core > 0) {
|
||||||
|
$total_cpu += $cpu_core;
|
||||||
|
}
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +77,12 @@ sub custom_cpu_core_calc {
|
||||||
my $core_usage = (1 - ( $options{new_datas}->{$self->{instance} . '_PercentProcessorTime'} - $options{old_datas}->{$self->{instance} . '_PercentProcessorTime'} ) /
|
my $core_usage = (1 - ( $options{new_datas}->{$self->{instance} . '_PercentProcessorTime'} - $options{old_datas}->{$self->{instance} . '_PercentProcessorTime'} ) /
|
||||||
( $options{new_datas}->{$self->{instance} . '_Timestamp_Sys100NS'} - $options{old_datas}->{$self->{instance} . '_Timestamp_Sys100NS'} ) ) * 100;
|
( $options{new_datas}->{$self->{instance} . '_Timestamp_Sys100NS'} - $options{old_datas}->{$self->{instance} . '_Timestamp_Sys100NS'} ) ) * 100;
|
||||||
$self->{result_values}->{prct_used} = $core_usage;
|
$self->{result_values}->{prct_used} = $core_usage;
|
||||||
|
|
||||||
|
if ($core_usage < 0) {
|
||||||
|
$self->{result_values}->{prct_used} = 0;
|
||||||
|
} else {
|
||||||
|
$self->{result_values}->{prct_used} = $core_usage;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue