Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Multiple attributes-match for only one trigger event !

‎06-07-2020 08:01 PM

Hi, 

i try to setup the automation to disable the fpc when the event is trigger, but it require the within statement if i use multiple attributes-match. Because i just want to use only one event trigger so the within statement does not make sence. Is there anyway to do that ? 

Thank for any idea 😄 !

 

[edit event-options policy test_fpc]
lab@BNG-1-ACTIVE# show
Jun 08 09:43:37
events chassisd_snmp_trap10;
attributes-match {
chassisd_snmp_trap10.value5 matches "^FPC*";
##
## Warning: within clause must be configured
##
chassisd_snmp_trap10.argument8 equals jnxFruOfflineReason;
##
## Warning: within clause must be configured
##
chassisd_snmp_trap10.value8 equals 23;
}
then {
change-configuration {
commands {
"command to disable here";
}
commit-options {
log anh_vt_test;
}
}
}

 

 
2 REPLIES 2
Highlighted
Junos Automation (Scripting)
Solution
Accepted by topic author TuanAnhVu
‎06-07-2020 09:20 PM

Re: Multiple attributes-match for only one trigger event !

[ Edited ]
‎06-07-2020 09:05 PM

Hi TuanAnhVu,

 

Greetings,

 

As per my understanding you want to trigger a single policy when it matches the event which has multiple attributes.

 

As per our documentation, If the attributes-match statement includes the equals or starts-with options, or if it includes a matches option that includes a clause for an event that is not specified at the [edit event-options policy policy-name events] hierarchy level, you must include one or more within statements in the same policy configuration.

 

attributes-match {
chassisd_snmp_trap10.value5 matches "^FPC*"; 
chassisd_snmp_trap10.argument8 equals jnxFruOfflineReason; >> Has the equals option
chassisd_snmp_trap10.value8 equals 23; >> Has the equals option
}
For these equals options we need the within clause as per documentation.

 

 

Refer Link for more details: https://www.juniper.net/documentation/en_US/junos/topics/reference/configuration-statement/attribute...

 

 

Hope this helps. Smiley Happy

Please mark "Accept as solution" if this answers your query. 

 

Kudos are appreciated too! 

 

Regards, 

Sharat Ainapur

 

Highlighted
Junos Automation (Scripting)

Re: Multiple attributes-match for only one trigger event !

‎06-07-2020 09:28 PM

Hi, 

Thanks for your response. It work for me now, but i have another issue. The event and attributes-match are working now, but do you know anyway to put the slot of the fpc to the change-configuration commands. I tried with statement "set chassis fpc chassisd_snmp_trap10.value7 power off" but it did not work (chassisd_snmp_trap10.value7 is the slot of FPC, https://kb.juniper.net/InfoCenter/index?page=content&id=KB22868&cat=JUNOS_PLATFORM&actp=LIST). i tried with simple commands without variable for testing, it works.

 

lab@MX960-CCH-UPE-01_RE0# show event-options
Jun 08 11:21:03
policy test {
events chassisd_snmp_trap10;
attributes-match {
chassisd_snmp_trap10.trap matches "^Fru Offline$";
chassisd_snmp_trap10.value5 matches "^FPC*";
chassisd_snmp_trap10.argument8 matches "^jnxFruOfflineReason$";
chassisd_snmp_trap10.value8 matches "^7$";
}
then {
change-configuration {
commands {
"set chassis fpc chassisd_snmp_trap10.value7 power off";
}
commit-options {
log down_fpc_script;
}
}
}
}

 
Feedback