0% found this document useful (0 votes)
51 views

Event Policy - Slax Event Script Call Off

This document contains an event script configuration for a Juniper router. It defines an event policy that will trigger a script called "link-down.slax" if any of the specified interfaces experience a link down event within 30 seconds of each other 3 times. The event script connects to the router, retrieves the current interface configuration, and disables all interfaces except the one specified as the $interface parameter to isolate the issue.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Event Policy - Slax Event Script Call Off

This document contains an event script configuration for a Juniper router. It defines an event policy that will trigger a script called "link-down.slax" if any of the specified interfaces experience a link down event within 30 seconds of each other 3 times. The event script connects to the router, retrieves the current interface configuration, and disables all interfaces except the one specified as the $interface parameter to isolate the issue.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

new 5 Tuesday, August 21, 2018 5:18 PM

EVENT SCRIPTING FOR INTERFACE DOWN - WORKS WITH 17.1


======================================================
# show event-options
policy EVE-DIS {
events link-down;
within 30 {
trigger on 3;
}
then {
event-script link-down.slax;
}
}
event-script {
file link-down.slax;
}
redundancy-event link-down {
monitor {
link-down {
ge-0/0/0;
ge-0/0/1;
ge-0/0/2;
ge-0/0/3;
}
}
}
====================================================
link-down.slax - /var/db/scripts/event
----------------------------------------------------
/* Machine Crafted with Care (tm) by slaxWriter */
version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

var $arguments = {
<argument> {
<name> "interface";
<description> "Uplink Interface to be Tracked";
}
}

param $interface;

match / {
/*
* Open connection with mgd
*/
var $con = jcs:open();

if (not($con)) {
call emit-error($message = "Not able to connect to local mgd");
}

var $ge-rpc = {
<get-configuration> {
<configuration> {
<interfaces>;
}
}
}
var $getConfig = jcs:invoke($ge-rpc);

/* Generate the xml formated config delta */

-1-
new 5 Tuesday, August 21, 2018 5:18 PM
var $load-config-rpc = <load-configuration action = "merge" format = "xml"> {
<configuration> {
<interfaces> {
for-each ($getConfig/interfaces/interface[starts-with(name, "ge-")]) {
if (not(name == $interface)) {
<interface> {
<name> name;
<junos:comment> "/* Disabled by Event Script */";
<disable>;
}
}
}
}
}
}

expr jcs:output("Loading and Commiting the new configuration");


var $configChange = jcs:invoke($load-config-rpc);
var $commit = jcs:invoke("commit-configuration");
/*
* Close the mgd connection
*/
expr jcs:close($con);
}

-2-

You might also like