
synopsis:

	Inactive system in spacewalk

description:

	List of all inactive systems in spacewalk

columns:

	system_id	System id
	system_name	System name
	organization_id	Id of organization system belongs to
	last_checkin	Last check of the system

sql:

	select * from (
	select rhnServer.id as system_id,
		rhnServer.name as system_name,
		rhnServer.org_id as organization_id,
		rhnServerInfo.checkin as last_checkin
	from rhnServer
		join rhnServerInfo on rhnServer.id=rhnServerInfo.server_id,
		(
			select cast(coalesce(value, default_value) as integer) as thresh from rhnConfiguration
			where key = 'system_checkin_threshold'
		) C
	where rhnServerInfo.checkin < current_timestamp - numtodsinterval(
	C.thresh * 86400, 'second')
	) X
	-- where placeholder
	order by system_id, organization_id

