Here is an example of a derivation rule using the <sql> tag. The sge_queue table has a composed primary key comprising q_qname and q_hostname. For a rule specified for the queue object_type, a query will be made for each entry in the sge_queue table, the placeholders __key_0__ will be replaced by the queue name,ilwill be replaced by the hostname.
<!--
average queue utilization per hour
-->
<derive object="queue" interval="hour" variable="h_utilized">
<sql>
SELECT DATE_TRUNC( 'hour', qv_time_start)
AS time_start,
DATE_TRUNC( 'hour', qv_time_start) + INTERVAL '1 hour'
AS time_end,
AVG(qv_dvalue * 100 / qv_dconfig)
AS value
FROM sge_queue_values
WHERE qv_variable = 'slots' AND
qv_parent = (SELECT q_id FROM sge_queue
WHERE q_qname = __key_0__
AND q_hostname = __key_1__)
AND qv_time_start <= '__time_end__' AND
qv_time_end > '__time_start__'
GROUP BY time_start
</sql>
</derive>
Here is an example of a derivation rule using the <auto> tag.
<!-- average load per hour -->
<derive object="host" interval="hour" variable="h_load">
<auto function="AVG" variable="np_load_avg" />
</derive>