test sysvsar_diskload extends single_value {
    static set name "diskload";
    static set features local unix sysv;
	static set default_command "sar -A %d 1";
	static set domain sysvsar;
	set variable %busy.0;
	set variable_name "%busy";
	set variable_text "% Disk Busy";
	set export_domain "disk";

	static set description "Monitor the disk load";
	static set arguments
		"warn:int:The test goes yellow if the disk load in percent goes above this level (default: 80"
		"fail:int:The test goes red if the disk load goes above this level (default: 95)"
		"sarcommand:string:sar command to be used (defaults to ${default_command})"
		"item:string:column name we should report the results under (default: cpu)"
		"perf:int:time in minutes between sending performance data (0 for no performance data)";

	pernode precheck {
		set test_available domain_available( sysvsar );
    }

	init {
		pernode set command ${default_command};
		pernode import sarcommand command;
    }

    init {
		instance set upper_yellow_limit 80;
		instance set upper_red_limit 95;
		instance import warn lower_yellow_limit;
		instance import fail lower_red_limit;
    }
}


test sysvsar_cpuload extends CPUperf_load {
    static set name "load";
    static set features local unix sysv;
	static set domain sysvsar;
    static set idlevar sysvsar.%idle.0;
	static set default_command "sar -A %d 1";

	static set arguments ${arguments} "sarcommand:string:sar command to be used (defaults to ${default_command})";

	pernode precheck {
		set test_available domain_available( ${domain} );
    }

	init {
		pernode set command ${default_command};
		pernode import sarcommand command;
    }

    monitor {
        get ${domain}.%sys.0 ${domain}.%usr.0 ${domain}.%wio.0;
		instance set system ${${domain}.%sys.0};
		instance set user ${${domain}.%usr.0};
		instance set wio ${${domain}.%wio.0};
    }

    perf {
        export always cpu.%system, ${system};
		export always cpu.%user, ${user};
		export always cpu.%wio, ${wio};
    }
}

#
# Free page memory using sar
test sysvsar_virtualmemory extends storage {
    static set name "memory";
    static set features unix local sysv;
    pernode set report_item "cpu";
    static set storageid "memory.swap";
    static set description "Monitor virtual memory usage using sar";

	static set arguments ${arguments} "sarcommand:string:sar command to be used (defaults to ${default_command})";

	init {
		pernode set command ${default_command};
		pernode import sarcommand command;
    }

	pernode precheck {
		set test_available domain_available( "sysvsar" );
    }

    overrides pernode discover {
		set allocunits 1024;
		set storage.size "N/A";
		set storage.device "N/A";
    }

    # select the entities this instance will monitor
    overrides discover {
		set monitored remove( ${monitored}, ${thismonitor} );
		set storage.description "Swap Space";
		select thismonitor storage.description true;
		set monitored ${monitored} ${thismonitor};
    };

    overrides monitor {
        get sysvsar.freeswap[0];
		set storage.free.size ${sysvsar.freeswap[0]};
		set storage.free.percent;
		set storage.used.size "N/A" ;
		set storage.used.percent "N/A";
    }
}



#
# True64
test true64_diskload extends sysvsar_diskload {
    static set features unix local sysv true64;
	static set default_command "sar -udqbcayvmpgr %d 1";
}


test true64_cpuload extends sysvsar_cpuload {
    static set features unix local sysv true64;
	static set default_command "sar -udqbcayvmpgr %d 1";
}

test true64_virtualmemory extends sysvsar_virtualmemory {
    static set features unix local sysv true64;
	static set default_command "sar -udqbcayvmpgr %d 1";
}
