<def-group>
  <!-- Check that one logging service is active -->
  <definition class="compliance" id="{{{ rule_id }}}" version="1">
    {{{ oval_metadata("Ensure one logging service is in use", rule_title=rule_title) }}}
    <criteria>
        <criterion comment="one logging service is active"
            test_ref="test_{{{ rule_id }}}_single_active_logging_service"/>
    </criteria>
  </definition>

  <!-- Objects and states to identify active logging_service services -->
  <linux:systemdunitproperty_object id="obj_{{{ rule_id }}}_logging_services" version="1"
      comment="All active logging_service services">
    <linux:unit operation="pattern match">^(rsyslog|systemd-journald).service$</linux:unit>
    <linux:property>ActiveState</linux:property>
    <filter action="include">ste_{{{ rule_id }}}_logging_services</filter>
  </linux:systemdunitproperty_object>

  <linux:systemdunitproperty_state id="ste_{{{ rule_id }}}_logging_services" version="1">
    <linux:value>active</linux:value>
  </linux:systemdunitproperty_state>

  <!-- Count active logging_service services -->
  <local_variable id="var_{{{ rule_id }}}_logging_service_active_count" datatype="int" version="1"
                 comment="Number of currently active logging_service services">
   <count>
     <regex_capture pattern="^active$">
       <object_component item_field="value" object_ref="obj_{{{ rule_id }}}_logging_services"/>
     </regex_capture>
   </count>
  </local_variable>

  <!-- Test that count is at least one -->
  <ind:variable_test id="test_{{{ rule_id }}}_single_active_logging_service" version="1" check="all"
                     comment="Verify one logging_service service is active">
    <ind:object object_ref="obj_{{{ rule_id }}}_count"/>
    <ind:state state_ref="ste_{{{ rule_id }}}_count"/>
  </ind:variable_test>

  <ind:variable_object id="obj_{{{ rule_id }}}_count" version="1">
    <ind:var_ref>var_{{{ rule_id }}}_logging_service_active_count</ind:var_ref>
  </ind:variable_object>

  <ind:variable_state id="ste_{{{ rule_id }}}_count" version="1">
    <ind:value operation="greater than or equal" datatype="int">1</ind:value>
  </ind:variable_state>
</def-group>
