if( Platforms::iswin32() ) {
    my $inst;
    my( $filesys );

    $args{"_eval"} = "cpu";
    do "_evaluator";
    $args{"object"} = "Processor";
    do "_perflib";
    my $perflib = $memory{"perflib_$args{host}_$args{frequency}"};
    $perflib->check( "Processor" );
    my @cpus = @{$uxmon::monitor_variables{$args{"alias"}}->{"perflib.Processor.Instances"}};

    my $idle=$args{"idle"}?$args{"idle"}:15;
    $args{"_evaluator"}->add_check( ($args{"check"}?$args{"check"}:"cpu"), sub {
	my( $vars ) = @_;
	my $text .= "%idle ";
	my $inst;

	my $avg = 0;
	my $cpus = 0;
	my $total;
	foreach $inst (@cpus) {
	    if( defined $vars->{"perflib.Processor.$inst.%_Processor_Time"} ){
		my $name = $vars->{"perflib.Processor.$inst.InstanceName"};
		if( $name eq "_Total" ) {
		    $total = $vars->{"perflib.Processor.$inst.%_Processor_Time"};
		    $cpus = $#cpus;
		    last;
		}
		$avg += $vars->{"perflib.Processor.$inst.%_Processor_Time"};
		$cpus++;
	    }
	}
	return( 2, "(no cpu data available)" ) unless( $cpus );
	$text .= "($cpus CPUs) ";
	$avg = (defined $total)?(100-$total):(int(100-($avg/$cpus)+0.5));
	if( $avg <= $idle ) {
	    return( 1, $text."(<) $avg" );
	}
	return( 3, $text."= $avg" );
      } );
}
else {
    my $sar;

    unless( $sar = $memory{"sar_$args{frequency}"} ) {
	&uxmon::load_module( "sar" );
	&uxmon::checker(
		$memory{"sar_$args{frequency}"} = $sar = Monitor::sar->new 
	);
	$sar->sched_frequency( $args{"frequency"} );
    }

    my $item = $args{"alias"}.".".($args{"check"}?$args{"check"}:"cpu");
    $sar->add_check( "%idle", $item, undef, $args{"idle"}?$args{"idle"}:15 );
    $sar->add_check( "%wio", $item, undef, undef, $args{"wio"}?$args{"wio"}:50 );
    $sar->add_check( "freeswap", $item, $args{"freeswap_red"}?$args{"freeswap_red"}:20000, $args{"freeswap_yellow"}?$args{"freeswap_yellow"}:60000 );
}

1;
