Blog Viewer

Scripting How-To: Control execution of an event policy (dampening logic)

By Erdem posted 08-09-2015 21:10

  

Overview

Controlled event policy execution.

 

Resolution

 

In some cases, you might want to control the execution of an event policy. For example, if you don't want to execute the configured policy for an event more than once in 60 seconds, you can write a policy to ignore that event if it occurs again within 60 seconds. The policy configuration will be as follows:

 

01	[edit]
02	user@host# show event-options
03	policy <policy-name> {
04	    events TEST;
05	    within 60 events TEST;
06	    then {
07	        ignore;
08	    }
09	}
10	policy <policy-name> {
11	    events TEST;
12	    then {
13	        execute-commands {
14	            commands {
15	                "show version";
16	            }
17	            output-filename cmd_output;
18	            destination test_dest;
19	        }
20	    }
21	}
22	destinations {
23	    test_dest {
24	        archive-sites {
25	            /var/tmp;
26	        }
27	    }
28	}
29	 
30	[edit]
31	user@host#

As per the above configuration, if event 'TEST' occurs the first time, then the second policy will get executed, and if 'TEST' occurs again within 60 seconds, then it will be ignored as per the first policy.


#How-To
#eventpolicy
#ScriptingHow-To
#dampeninglogic

Permalink