Conditions
Conditions in a policy are events that can trigger actions. Use the policy command with condition add to define the conditions in a policy. For example:
(config) # policy alias MapMonitor condition add PortDown param portId 2/3/q2
For example, refer to the template for the PortDown condition as follows:
The link of port <$portId$> is down for a period of [$period$] second(s).
In the example, the mandatory PortId keyword has been specified with a value of 2/3/q2.
There is also an optional period keyword that can be specified in the condition. For example:
(config) # policy alias MapMonitor condition add PortDown param portId 2/3/q2 param period 120
These examples define a port down condition for port 2/3/q2. When used in a policy, the condition in the first example will be met when the port is down. In the second example, the condition will be met when the port is down for a period of 120 seconds.
How to Specify Keywords in Conditions
The syntax for specifying keywords in conditions is described in the following sections:
The mandatory keyword, gsGroup, specifies a GigaSMART group created.
For Example:
To detect the High CPU utilization for a GigaSMART group, create a policy as follows:
(config) # policy alias GSPolicies condition add GsCpuUtilHigh param gsGroup testgroup param threshPct 90 param period 120
The mandatory keyword, inlineToolAlias, specifies an inline tool configured, for example:
(config) # policy alias p1 condition add InlineToolReady param inlineToolAlias testinlinetool
The mandatory keyword, inlineToolGrpAlias, specifies an inline tool group configured, for example:
(config) # policy alias p1 condition add InlineToolGrpDn param inlineToolGrpAlias itg1
The optional keyword, period, specifies a time in seconds, for example:
(config) # policy alias MapMonitor condition add PortDown param portId 2/3/q2 param period 120
Refer to the template for the PortDown condition as follows:
The link of port <$portId$> is down for a period of [$period$] second(s).
Period means wait for the number of seconds specified. During that waiting period, the condition might be met, for example, if the port stays down for 120 seconds. But if the condition is not met (for example, the port comes back up before 120 seconds have passed), then the condition will not be met. If the port goes down again, the 120 seconds waiting period will start again.
When a period is specified, it provides a dampening or soaking period. For example, you might not want to execute an action unless a threshold has been exceeded for a certain amount of time.
If you are monitoring ports, they might flap. It is recommended that you always specify a period when using PortUp and PortDown conditions.
The mandatory keyword, thresh, specifies a threshold value, for example:
(config) # policy alias PortPolicy condition add PortRxDiscardsHigh param portId 2/3/x1 param thresh 100
Refer to the template for the PortRxDiscardsHigh condition as follows:
The port <$portId$> Rx discards is greater than <$thresh$> for a period of [$period$] second(s).
Use high and low thresholds to define a range of values.
Note: For any discard, drop, or error condition, the values can only go up because they are counters that start at zero and are then incremented. Note that the counters for any discard, drop, or error condition can be cleared.
To clear counters, use the following command:
(config) # clear port stats
The mandatory keyword, threshPct, specifies a threshold percentage, for example:
(config) # policy alias OverloadedToolPort condition add PortTxUtilHigh param portId 1/1/x1 param threshPct 80
In this example, the utilization needs to be higher than the threshold percentage of 80 for the condition to be met.
Refer to the template for the PortTxUtilHigh condition as follows:
The port <$portId$> Tx utilization is greater than <$threshPct$> for a period of [$period$] second(s).
The optional keyword, period, can be added to the condition as follows:
(config) # policy alias OverloadedToolPort condition add PortTxUtilHigh param portId 1/1/x1 param threshPct 80 param period 120
In this example, the utilization needs to be higher than the threshold percentage of 80 for a period of 120 seconds. The condition will be met if the threshold is above 80 for 120 seconds. However, during the 120 seconds, if the threshold drops below 80, the condition will not be met. If the threshold goes over 80 again, a new 120 seconds waiting period will start.
The mandatory keyword, timeStr, specifies a time string, for example:
(config) # policy alias SaveMemory condition add TimeOfDay param timeStr "( 45 10 * * * * )"
Refer to the template for the TimeOfDay condition as follows:
Time of day is <$timeStr$>
The format of the timeStr keyword is a Cron format, which has the form: "( a b c d e f )".
Table 1: Cron Format lists the six fields in the Cron format.
Key |
Description |
Range |
Notes |
a |
minute |
0-59 |
|
b |
hour |
0-23 |
|
c |
day of the month |
1-31 |
|
d |
month of the year |
1-12 |
or Jan, Feb...Dec |
e |
day of the week |
1-7 |
where 1 = Monday, or Mon, Tue...Sun |
f |
year |
1900-3000 |
|
In addition to the numbers listed in the Range column, each field supports a wildcard (*) character.
After a wildcard or a range of values, you can use the slash (/) to specify values that are repeated over and over, with an interval in between.
Only the Cron formats listed above are supported.
Note: When a time string is specified, such as for one minute or for one hour, it means that the condition will be matched every minute or every hour. This can result in a condition that triggers an action again, even if it was already triggered.
Time-based conditions are evaluated at the point at which the time changes. For example, if the condition is TimeWednesday, it is evaluated when Tuesday changes to Wednesday, which occurs just after midnight, in the first minute of Wednesday.
The mandatory keyword, portId, specifies a port identifier. There are several ways to specify ports. Whether or not a condition is met depends on how the ports are specified.
The formats for portId are as follows:
single port—a/b/c |
multiple ports, separated by commas—a1/b1/c1,a2/b2/c2 |
range of ports—a/b/c..d |
any port—any(a/b/c..d), which includes the keyword, any. |
The following is an example of a single port. When the port matches, the condition is met.
(config) # policy alias SingleUpPort condition add PortUp param portId 1/1/x1
Refer to the template for the PortUp condition as follows:
The link of port <$portId$> is up for a period of [$period$] second(s).
The following is an example of a range of ports. When all ports match, the condition is met. In this case, all ports means x1, x2, and x3.
(config) # policy alias RangeUpPort condition add PortUp param portId 1/1/x1..x3
The following is an example of any ports. When any port matches, the condition is met. In this case, any port means x1, x2, or x3.
(config) # policy alias AnyUpPort condition add PortUp param portId any(1/1/x1..x3)
The optional keyword, period, can be added to the condition as follows:
(config) # policy alias TwoUpPorts condition add PortUp param portId 1/1/x1..x2 param period 120
In this example assume that x1 comes up and then x2 comes up. When both ports are up, wait 120 seconds. At this point, the condition is met and the trigger action starts.
If the condition was specified as follows using the keyword any, the condition will be met after either port or both ports come up and stay up for 120 seconds:
(config) # policy alias TwoUpPorts condition add PortUp param portId any(1/1/x1..x2) param period 120