Need a query to get a listing of current alarm policies in the database.
Guidance
--BASIC QUERY TO GET A LIST OF POLICIES, THRESHOLDS
select * from policy p
join PolicyCondition pc on pc.policy_id = p.id
join PolicyMetric pm on pm.id = pc.policyMetric_id
join PolicyTarget pt on pt.id = pm.id
join policythreshold pot on pot.condition_id = pm.id
--GET A LISTING OF CURRENT POLICIES where TYPE = DEVICE
select
p.name as policyname,
pm.name as QOS,
pm.probename as probe,
pm.description,
pm.shortunit as unit,
pt.name as device_group,
pt.type,
pot.operator,
pot.value as threshold,
pot.severity,
pot.type
from policy p
join PolicyCondition pc on pc.policy_id = p.id
join PolicyMetric pm on pm.id = pc.policyMetric_id
join PolicyTarget pt on pt.id = pm.id
join policythreshold pot on pot.condition_id = pm.id
where pt.type = 'DEVICE'
--GET A LISTING OF CURRENT POLICIES where TYPE = GROUP
select
ccs.name as devicename,
p.name as policyname,
pm.name as QOS,
pm.probename as probe,
pm.description,
pm.shortunit as unit,
pt.name as device_group,
pt.type,
pot.operator,
pot.value as threshold,
pot.severity,
pot.type
from policy p
join PolicyCondition pc on pc.policy_id = p.id
join PolicyMetric pm on pm.id = pc.policyMetric_id
join PolicyTarget pt on pt.id = pm.id
join policythreshold pot on pot.condition_id = pm.id
join cm_group cg on cg.name = pt.name
join cm_group_member cgm on cgm.grp_id = cg.grp_id
join cm_computer_system ccs on ccs.cs_id = cgm.cs_id
where pt.type = 'GROUP' order by ccs.name asc