Managing Rules
The OCS Rule engine allows automatic actions on objects when they match a certain criteria.
Triggers
The server uses a predefined set of triggers that determine when the rules are evaluated and the scope of the data considered:
Base inventory received: triggers when a base inventory is created or updated. The scope is limited to the fields defined in the base inventory. See Base inventory for more details.
User login: triggers when a user logs in through any authentication method. The scope is limited to user-related fields.
Network device inventory received: similar to the Base inventory received trigger, but applied to IPDiscover devices.
Default Rules
Out of the box, OCS provides six predefined rules, evaluated against the OS Name or Agent field of the base inventory and used to assign Templates automatically:
Field evaluated
OS Name
OS Name
OS Name
OS Name
Agent
OS Name
Value(s) expected
Windows
Ubuntu, Debian
Redhat, Centos, Alma, Rocky
Mac
OCS-NG
SNMP
Template
Windows
Debian based
RHEL based
macOS
Legacy
Generic SNMP

Rule evaluation order
Rules are evaluated per trigger, by execution priority order. Actions inside a rule are also evaluated by priority. Rules have a break on first match option: if enabled and the rule matches, its actions are executed first, then evaluation stops for remaining rules of that trigger.
If multiple executed rules/actions write the same field, the last executed write wins which is why priority order and break on first match are important.
To change the execution order:
Navigate to Configuration → Inventory → Rules.
Locate the handle.
Find the drag-and-drop handle on the left side of the Actions table for each entry.
Reposition the row.
Drag the handle to move the row to your desired order.
The table will automatically update to reflect the new order.
Creating a rule
Navigate to Configuration → Inventory → Rules.
Click the Add a rule button (top right of the table).
Complete the form.
Name
Enabled switch
Break on first match switch
Click Add.
The new rule will appear in the list.
Locate the newly created rule, then click the gear icon in the Actions column.
By default, you’ll be directed to the Criteria tab, where you can define the conditions a device or user must match.
Define a criteria and click Save.
Switch to the Actions tab.
Specify the actions to be performed on matching objects, then click Save.
Navigate to Configuration → Inventory → Rules.
Click the Add a rule button (top right of the table).
Complete the form.
Name
Enabled switch
Click Add.
The new rule will appear in the list.
Locate the newly created rule, then click the gear icon in the Actions column.
By default, you’ll be directed to the Criteria tab, where you can define the conditions a device or user must match.
Define a criteria and click Save.
Switch to the Actions tab.
Specify the actions to be performed on matching objects, then click Save.
Authentication rules can assign users to groups when they log in.
These rules can evaluate:
The authentication method used by the user
The authentication configuration used during login
Authentication metadata returned by the identity provider
Navigate to Configuration → Inventory → Rules.
Click the Add a rule button (top right of the table).
Complete the form.
Name
Choose User login as the Triggers
Enable the rule
Click Add.
The new rule will appear in the list.
Locate the newly created rule, then click the gear icon in the Actions column.
By default, you’ll be directed to the Criteria tab, where you can define the conditions a user must match.
For this example, assign users authenticated with OIDC based on the custom_group attribute.
We check that claims.custom_group contains asset-management.

Switch to the Actions tab.
Specify the actions to be performed on matching objects, then click Save.
Updating a rule
Navigate to Configuration → Inventory → Rules.
Locate the rule you want to modify and click the gear icon in the Actions column.
Click Save.
Updating a rule immediately affects all future inventory or login events matching its criteria.
Enabling or disabling a rule
Navigate to Configuration → Inventory → Rules.
Locate the rule you want to modify and click the pencil icon in the Actions column.
Use the switch to enable or disable the rule.
Click Save.
Last updated

