11.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. Rules that contain main code display the Code element in the rule.

11.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.

UAM also allows you to edit the existing main code. Before editing code that functions correctly, ensure that you take a backup of the rule set. Perform the following procedure to edit your 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 UAM computer and activate the modified rule set on remote Agent computers. For more information about activating rule set see, Activating Rule Sets.

11.11.2 Adding New Main Code

UAM allows you to add main code to a rule. Before adding main code, ensure that 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 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 in the UAM computer and activate the modified rule set on remote Agent computers. For more information, see Activating Rule Sets.

11.11.3 Deleting Main Code

Before deleting main code, ensure that you no longer need the code to make the rule work. Perform the following procedure 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.