8.11 Understanding Main Code

Main code is Perl code you can add to a rule if the filtering provided by the conditionals and comparisons is inadequate or needs augmenting to detect more complex patterns. Main code must contain a call to the subroutine _take_actions(). The code you write can be selective about the circumstances under which the subroutine is called. It is not necessary for the code to call _take_actions() every time it is evaluated. Rule that contain main code display the Code element in the rule.

8.11.1 Viewing and Editing Main Code

To view main code, expand the rule containing the main code you want to view, and then click Code.

The UNIX Agent Manager also allows you to edit existing main code. Before editing code that functions correctly, ensure you make a back up of the rule set. Complete the following procedure to edit your main code.

To edit existing main code:

  1. Expand the appropriate rule, and then right-click Code.

  2. Click Edit.

  3. On the Edit Code window, modify the Perl code.

  4. Click OK.

After editing main code, you can save the modified rule set on the UNIX Agent Manager computer and activate the modified rule set on remote agent computers. For more information, see Section 8.2.3, Activating Rule Sets.

8.11.2 Adding New Main Code

The UNIX Agent Manager allows you to add main code to a rule. Before adding main code, ensure you have a thorough knowledge of Perl and a complete understanding of what you want the code to accomplish. You can create one set of main code per rule.

To add main code:

  1. Right-click the rule to which you want to add main code, and then click Add Main Code.

  2. On the Edit Code window, add your Perl code.

  3. Click OK.

After adding new main code, you can save the modified rule set on the UNIX Agent Manager computer and activate the modified rule set on remote agent computers. For more information, see Section 8.2.3, Activating Rule Sets.

8.11.3 Deleting Main Code

Before deleting main code, ensure you no longer need the code to make the rule work. Complete the following procedure to delete main code.

To delete main code:

  1. Right-click the main code you want to delete, and then click Delete.

  2. On the Delete window, click Yes.