To compare two unequal strings when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringcomparecommand in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
nocase
(Optional) Specifies case insensitive comparison.
length
(Optional) Limits the comparison to the first integer character.
integer
(Optional) Valid values for the length argument range from 1 to 4294967295.
string1
Sequence of characters.
string2
Sequence of characters.
Command Default
Unequal strings are not compared.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
String comparisons are performed on a byte-by-byte basis from left to right. If the strings are of unequal length, the longer string is compared greater than the shorter string. The
actionstringcompare command forces a comparison between two unequal strings, which is followed by an integer comparison of the result of the string comparison.
When two equal strings are compared, the result is 0 and when one string sorts before the other, the result is -1. For all other comparisons the result is 1. If the strings being compared are converted to integers, the comparison is performed between the results using the
strcmp command.
The table below shows the built-in variable in which the results of the
actionstringcompare command are stored.
Table 1 EEM Built-in Variables for action string compare Command
Built-in Variable
Description
$_string_result
The result of the
actionstringcompare command is stored in this variable.
Examples
The following example shows how to compare two unequal strings:
Registers an event applet with the EEM and enters applet configuration mode.
action string equal
To verify whether or not two strings are equal when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringequalcommand in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
nocase
(Optional) Specifies case insensitive comparison.
length
(Optional) Specifies the length of the value to limit the comparison.
integer
(Optional) Valid values for the length argument range from 1 to 4294967295.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
Strings are not verified as equal.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
The
actionstringequal command compares two strings and returns 1 if the strings are equal. Use
nocase for case insensitive comparison.
The table below shows the built-in variable in which the results of the
actionstringequal command are stored.
Table 2 EEM Built-in Variables for action string equal Command
Built-in Variable
Description
$_string_result
The result of the
actionstringequal command is stored in this variable.
Examples
The following example shows how to verify whether or not two strings are equal:
Registers an event applet with the EEM and enters applet configuration mode.
action string first
To return the index on the first occurrence of
string1 within
string2 when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringfirst command in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
index-value
(Optional) The index value to start the first test. Number in the range from 0 to 4294967295.
Command Default
The index is not returned on the first occurrence of
string1 within
string2.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
On the first occurrence of
string1, the index is placed in
string2. If
string1 is not found, it returns -1.
The table below shows the built-in variable in which the results of the
actionstringfirst command are stored.
Table 3 EEM Built-in Variables for action string first Command
Built-in Variable
Description
$_string_result
The result of the
actionstringfirst command is stored in this variable.
Examples
The following example shows how to return the index on the first occurrence of
string1 within
string2:
Router(config-applet)# event manager applet first
Router(config-applet)# event none
Router(config-applet)# action 1 set str "this contains some data"
Router(config-applet)# action 2 string first "contains" "$str"
Router(config-applet)# action 3 puts "$_string_result"
Router# event manager run first
5
Router#
Related Commands
Command
Description
actionstringlast
Returns the index on the last occurrence of
string1 within
string2.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string index
To return the characters specified at a given index value when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringindexcommand in applet configuration mode. To disable this function, use the
no form of the command.
actionlabelstringindexstring
[ value | end ]
noactionlabelstringindex
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
value
(Optional) The index value. Number in the range from 0 to 4294967295. The count starts from 0.
end
(Optional) Last character of the string.
Command Default
The characters specified at a given index value are not returned.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
The index count starts from zero. Use the
end argument for the last character of the string.
The table below shows the built-in variable in which the
actionstringindex command stores the characters.
Table 4 EEM Built-in Variables for action string index Command
Built-in Variable
Description
$_string_result
The
actionstringindex command stores the characters in this variable.
Examples
The following example shows how to return the character specified at a given index value:
Router(config-applet)# event manager applet index
Router(config-applet)# event none
Router(config-applet)# action 1 set str "this is text"
Router(config-applet)# action 2 string index "$str" 8
Router(config-applet)# action 3 puts "$_string_result"
Router# event manager run index
t
Router#
Related Commands
Command
Description
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string last
To return the index on the last occurrence of
string1 within
string 2 when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringlastcommand in applet configuration mode. To disable this function, use the
no form of this command.
actionlabelstringlaststring1string2 [index-value]
noactionlabelstringlast
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
index-value
(Optional) The index value to start the last test. Number in the range from 0 to 4294967295.
Command Default
The index is not returned on the last occurrence of
string1 within
string2.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
On the first occurrence of
string1, the index is placed in
string2. If
string1 is not found, it returns -1.
The table below shows the built-in variable in which the results of the
actionstringlast command are stored.
Table 5 EEM Built-in Variables for action string last Command
Built-in Variable
Description
$_string_result
The result of the
actionstringlast command is stored in this variable.
Examples
The following example shows how to return the index on the last occurrence of
string1 within
string2:
Router(config-applet)# event manager applet last
Router(config-applet)# event none
Router(config-applet)# action 1 set str "this contains some data"
Router(config-applet)# action 2 string last "contains" "$str"
Router(config-applet)# action 3 puts "$_string_result"
Router# event manager run last
5
Router#
Related Commands
Command
Description
actionstringfirst
Returns the index on the first occurrence of
string1 within
string2.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string length
To return the number of characters in a string when the Embedded Event Manager (EEM) applet is triggered, use the
actionstringlengthcommand in applet configuration mode. To disable this function, use the
no form of this command.
actionlabelstringlengthstring
noactionlabelstringlength
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
The number of characters in a string are not returned.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringlength command to specify the action of returning the number of characters in a string when an EEM applet is triggered.
The table below shows the built-in variable in which the results of the
actionstringlength command are stored.
Table 6 EEM Built-in Variables for action string length Command
Built-in Variable
Description
$_string_result
The result of the
actionstringlength command is stored in this variable.
Examples
The following example shows how to return the number of characters in a string:
Registers an event applet with the EEM and enters applet configuration mode.
action string match
To return 1 to the $_string_result, if the string matches the pattern when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringmatch command in applet configuration mode. To disable this action, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
nocase
(Optional) Specifies case insensitive comparison.
string-pattern
The pattern for case insensitive comparison.
string
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
Results of the pattern matching of strings are not returned to the $_string_result.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
When the string matches the specified pattern, the result is 1; when the pattern does not match, the result is 0.
The table below shows the built-in variable in which the results of the
actionstringmatchcommand is stored.
Table 7 EEM Built-in Variables for action string match Command
Built-in Variable
Description
$_string_result
The result of theactionstringmatch command is stored in this variable.
Examples
The following example shows how to return 1 to the $_string_result if the string matches the pattern:
Router(config-applet)# event manager applet match
Router(config-applet)# event none
Router(config-applet)# action 1 set str “this is some text”
Router(config-applet)# action 2 string match “$str” “this is”
Router(config-applet)# action 3 puts “$_string_result”
Router# event manager run match
1
Router#
Related Commands
Command
Description
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string range
To store a range of characters in a string when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringrange command in a pplet configuration mode . To disable this function, use the
no form of this command.
actionlabelstringrangestringstart-indexend-index
noactionlabelstringrange
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
Sequence of characters which can be up to 4294967295. If the string contains embedded blanks, enclose it in double quotation marks.
start-index
The starting index string value. The range is from 0 to 4294967295.
end-index
The ending index string value. The range is from 0 to 4294967295.
Command Default
A string is not stored.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringrange command to specify the action of storing a range of characters in a string when an EEM applet is triggered. The
start-index and
end-indexarguments specify the range of the string on which to operate.
The table below shows the built-in variable in which the result of the
actionstringrange command is stored.
Table 8 EEM Built-in Variables for action string range Command
Built-in Variable
Description
$_string_result
The result of the
actionstringrange command is stored in this variable.
Examples
The following example shows how to store a range of characters in a specified string:
Router(config)# event manager applet store
Router(config-applet)#action 1.0 set string “This is some text”
Router(config-applet)# action 2.0 string range “$string” 0 6
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run store
this is
Router#
Related Commands
Command
Description
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string replace
To store a new string by replacing the range of characters in the specified string when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringreplacecommand in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
Sequence of characters, which can be up to 4294967295. If the string contains embedded blanks, enclose it in double quotation marks.
start-index
The starting index string value. The range is from 0 to 4294967295.
end-index
The ending index string value. The range is from 0 to 4294967295.
new-string
(Optional) The sequence of characters that will replace the range of characters in the string.
Command Default
A string is not stored.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringreplace command to get a new string by replacing specific characters in a particular string. If the value for
new-string argument is not specified, the characters are replaced with white space.
The table below shows the built-in variable in which the result of the
actionstringreplace command is stored.
Table 9 EEM Built-in Variables for action string replace Command
Built-in Variable
Description
$_string_result
The result of the
actionstringreplace command is stored in this variable.
Examples
The following example shows how to store the new string made by replacing the specific characters in a string:
Router(config)# event manager applet replace
Router(config-applet)# event none
Router(config-applet)# action 1.0 set string “This is some text”
Router(config-applet)# action 2.0 string replace “$string” 0 6 “that was”
Router(config-applet)# action 3.0 puts “$_string_result”
Router (config-applet)# end
Router# event manager run replace
that was some text
Router#
Related Commands
Command
Description
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string tolower
To store a specific range of characters of a string in lowercase when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringtolowercommand in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
The sequence of characters that needs to be replaced. If the string contains embedded blanks, enclose it in double quotation marks.
start-index
(Optional) The starting index string value. The range is from 0 to 4294967295.
end-index
(Optional) The ending index string value. The range is from 0 to 4294967295.
Command Default
A string is not stored.
Command Modes
Applet configuration (applet-config)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringtolower command to store a specific range of characters of a string in lowercase. The
start-index and
end-index arguments specify the range of the string on which to operate.
The table below shows the built-in variable in which the result of the
actionstringtolower command is stored.
Table 10 EEM Built-in Variables for action string tolower Command
Built-in Variable
Description
$_string_result
The result of the
actionstringtolower command is stored in this variable.
Examples
The following example shows how to store a range of characters in a specific string in lowercase:
Router(config)# event manager applet lowercase
Router(config-applet)# action 1.0 set string “This is a STRING”
Router(config-applet)# action 2.0 string tolower “$string” 11 16
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run lowercase
string
Router#
Related Commands
Command
Description
actionstringtoupper
Stores a specific range of characters of a string in uppercase.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string toupper
To store a specific range of characters of a string in uppercase when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringtouppercommand in applet configuration mode. To disable this function, use the
no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string
Specifies the sequence of characters, that needs to be replaced. If the string contains embedded blanks, enclose it in double quotation marks.
start-index
(Optional) The starting index string value. The range is from 0 to 4294967295.
end-index
(Optional) The ending index string value. The range is from 0 to 4294967295.
Command Default
A string is not stored.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringtoupper command to store a specific range of characters of a string in uppercase. The
start-index and
end-index arguments specify the range of the string on which to operate.
The table below shows the built-in variable in which the result of the
actionstringtoupper command is stored.
Table 11 EEM Built-in Variables for action string toupper Command
Built-in Variable
Description
$_string_result
The result of the
actionstringtoupper command is stored in this variable.
Examples
The following example shows how to store a range of characters in a specific string in uppercase:
Router(config)# event manager applet uppercase
Router(config-applet)# action 1.0 set string “This is a string”
Router(config-applet)# action 2.0 string toupper “$string” 11 16
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run uppercase
STRING
Router#
Related Commands
Command
Description
actionstringtolower
Stores a specific range of characters of a string in lowercase.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string trim
To trim a string when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringtrim command in applet configuration mode. To disable this function, use the
no form of this command.
actionlabelstringtrimstring1 [string2]
noactionlabelstringtrim
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
(Optional) Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
By default, there is no action to trim a string.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringtrim command to trim the characters in a string. This command trims the characters in
string2 from both ends of
string1. By default,
string2 corresponds to white space.
The table below shows the built-in variable in which the result of the
actionstringtrim command is stored.
Table 12 EEM Built-in Variables for action string trim Command
Built-in Variable
Description
$_string_result
The result of the
actionstringtrim command is stored in this variable.
Examples
The following example shows how to trim a string:
Router(config)# event manager applet trim
Router(config-applet)# action 1.0 set string “Hello How are you?Hello”
Router(config-applet)# action 2.0 string trim “$string” “Hello ”
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run trim
How are you?
Router#
Related Commands
Command
Description
actionstringtrimleft
Trims the characters by one string from the left end of another string.
actionstringtrimright
Trims the characters by one string from the right end of another string.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string trimleft
To trim the characters of one string from the left end of another string when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringtrimleftcommand in applet configuration mode. To disable this function, use the
no form of this command.
actionlabelstringtrimleftstring1 [string2]
noactionlabelstringtrimleft
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
(Optional) Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
By default, there is no action to trim a string.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringtrimleft command to trim a string from the left end of another string. This command trims the characters specified by
string2 from the left end of
string1. By default,
string2 corresponds to white space.
The table below shows the built-in variable in which the result of the
actionstringtrimleft command is stored.
Table 13 EEM Built-in Variables for action string trimleft Command
Built-in Variable
Description
$_string_result
The result of the
actionstringtrimleft command is stored in this variable.
Examples
The following example shows how to trim a string from the left side of another string:
Router(config)# event manager applet trimleft
Router(config-applet)# action 1.0 set string “Hello How are you?”
Router(config-applet)# action 2.0 string trimleft “$string” “Hello ”
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run trimleft
How are you?
Router#
Related Commands
Command
Description
actionstringtrim
Trims a string.
actionstringtrimright
Trims the characters by one string from the right end of another string.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action string trimright
To trim the characters one string from the right end of another string when an Embedded Event Manager (EEM) applet is triggered, use the
actionstringtrimrightcommand in applet configuration mode. To disable this function, use the
no form of this command.
actionlabelstringtrimrightstring1 [string2]
noactionlabelstringtrimright
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string1
Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
string2
(Optional) Sequence of characters. If the string contains embedded blanks, enclose it in double quotation marks.
Command Default
By default, there is no action to trim a string.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the
actionstringtrimright command to trim a string from the right end of another string. This command trims the characters specified by
string2 from the right end of
string1. By default,
string2 corresponds to white space.
The table below shows the built-in variable in which the result of the
actionstringtrimright command is stored.
Table 14 EEM Built-in Variables for action string trimright Command
Built-in Variable
Description
$_string_result
The result of the
actionstringtrimright command is stored in this variable.
Examples
The following example shows how to trim a string from the right side of another string:
Router(config)# event manager applet trimright
Router(config-applet)# action 1.0 set string “How are you? Hello”
Router(config-applet)# action 2.0 string trim “$string” “ Hello”
Router(config-applet)# action 3.0 puts “$_string_result”
Router(config-applet)# end
Router# event manager run trimright
How are you?
Router#
Related Commands
Command
Description
actionstringtrim
Trims a string.
actionstringtrimleft
Trims the characters by one string from the left end of another string.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
action subtract
To specify the action of subtracting the value of a variable from another value, when an Embedded Event Manager (EEM) applet is triggered, use the actionsubtractcommand in applet configuration mode. To undo the subtract action, use the no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
subtract
Subtracts the value of a variable from the value of another variable.
variable-name
String value to be placed as the variable name.
long-integer
Long integer value by which another value gets subtracted.
Command Default
By default, there is no change in the value of variables configured within an EEM applet.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
You can use this action to subtract the value of a variable from the value of another variable. The result is stored in the variable named $_result. The value of the variable must be a long integer, else the action will fail.
Examples
The following example shows how to configure an EEM applet to subtract the value of a variable from another value:
Router(config)#event manager applet one
Router(config-applet)#action 1.0 set $var1 20
Router(config-applet)#action 1.0 set $var2 10
Router(config-applet)#action 1.0 subtract $var1 $var2
Router(config-applet)#
Related Commands
Command
Description
eventmanagerapplet
Registers an event applet with the Embedded Event Manager and enters applet configuration mode.
action syslog
To specify the action of writing a message to syslog when an Embedded Event Manager (EEM) applet is triggered, use the actionsyslogcommand in applet configuration mode. To remove the syslog message event criteria, use the no form of this command.
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
priority
(Optional) Specifies the priority level of the syslog messages. If this keyword is selected, the priority-level argument must be defined. If this keyword is not selected, all syslog messages are set at the informational priority level.
priority-level
(Optional) Number or name of the desired priority level at which syslog messages are set. Priority levels are as follows (enter the number or the keyword):
{0 | emergencies}--System is unusable.
{1 | alerts}--Immediate action is needed.
{2 | critical}--Critical conditions.
{3 | errors}--Error conditions.
{4 | warnings}--Warning conditions.
{5 | notifications}--Normal but significant conditions.
{6 | informational}--Informational messages. This is the default.
{7 | debugging}--Debugging messages.
msg
Specifies the message to be logged.
msg-text
Character text, an environment variable, or a combination of the two. If the string contains embedded blanks, enclose it in double quotation marks.
Note
Messages written to syslog from an EEM applet are not screened for EEM syslog events, which may lead to recursive EEM syslog events. Messages sent from an EEM applet include the applet name for identification.
facilitystring
Specifies the facility.
Command Default
No messages are written to syslog.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.0(26)S
This command was introduced.
12.3(4)T
This command was integrated into Cisco IOS Release 12.3(4)T.
12.2(25)S
This command was integrated into Cisco IOS Release 12.2(25)S.
12.2(28)SB
This command was integrated into Cisco IOS Release 12.2(28)SB.
12.2(18)SXF4
This command was integrated into Cisco IOS Release 12.2(18)SXF4 to support Software Modularity images only.
12.2(33)SRA
This command was integrated into Cisco IOS Release 12.2(33)SRA.
12.2(18)SXF5
This command was integrated into Cisco IOS Release 12.2(18)SXF5.
15.0(1)M
This command was modified. Thefacilitykeyword and the string argument were added.
Examples
The following example shows how to specify a message to be sent to syslog when the memory-fail applet is triggered:
Router(config)# event manager applet memory-fail
Router(config-applet)# event snmp oid 1.3.6.1.4.1.9.9.48.1.1.1.6.1 get-type exact entry-op lt entry-val 5120000 poll-interval 10
Router(config-applet)# action 4.0 syslog msg "Memory exhausted; current available memory is $_snmp_oid_val bytes"
The following example shows how to generate a syslog message when it detects a syslog message pattern "console", using priority level 3 (errors) and facility EEM-FAC:
Registers an event applet with the EEM and enters applet configuration mode.
action track read
To specify the action of reading the state of a tracked object when an Embedded Event Manager (EEM) applet is triggered, use the actiontrackreadcommand in applet configuration mode. To remove the actiontrackread command from the configuration, use the no form of this command.
actionlabeltrackreadobject-number
noactionlabeltrackreadobject-number
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
object-number
Tracked object number in the range from 1 to 500, inclusive. The number is defined using the trackstub command.
Command Default
The state of a tracked object is not read.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(2)T
This command was introduced.
12.2(31)SB3
This command was integrated into Cisco IOS Release 12.2(31)SB3.
12.2(33)SRB
This command was integrated into Cisco IOS Release 12.2(33)SRB.
12.2(33)SXI
This command was integrated into Cisco IOS Release 12.2(33)SXI.
Usage Guidelines
This command generates the following result variable:
_track_state--State of the specified tracked object. The text string returned is either up or down. If the state is up, it means that the object exists and is in an up state. If the state is down, it means that the object either does not exist or is in a down state.
This command is used to help track objects using EEM. Each tracked object is identified by a unique number that is specified on the tracking command-line interface (CLI). Client processes such as EEM use this number to track a specific object. The tracking process periodically polls the tracked objects and notes any change of value. The changes in the tracked object are communicated to interested client processes, either immediately or after a specified delay. The object values are reported as either up or down. The enhanced object tracking event detector publishes an EEM event when the tracked object changes.
Examples
The following example shows how to specify event criteria based on a tracked object:
event manager applet track-ten
event track 10 state any
action 1.0 track set 10 state up
action 2.0 track read 10
Related Commands
Command
Description
actiontrackset
Specifies the action of setting the state of a tracked object when an EEM applet is triggered.
eventmanagerapplet
Registers an event applet with the Embedded Event Manager and enters applet configuration mode.
showtrack
Displays tracking information.
trackstub
Creates a stub object to be tracked.
action track set
To specify the action of setting the state of a tracked object when an Embedded Event Manager (EEM) applet is triggered, use the actiontracksetcommand in applet configuration mode. To remove the actiontrackset command from the configuration, use the no form of this command.
actionlabeltracksetobject-numberstate
{ up | down }
noactionlabeltracksetobject-numberstate
{ up | down }
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
object-number
Tracked object number in the range from 1 to 500, inclusive. The number is defined using the trackstub command.
state
Specifies the state to which the tracked object will be set.
up
Specifies that the state of the tracked object will be set to up.
down
Specifies that the state of the tracked object will be set to down.
Command Default
The state of a tracked object is not set.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(2)T
This command was introduced.
12.2(31)SB3
This command was integrated into Cisco IOS Release 12.2(31)SB3.
12.2(33)SRB
This command was integrated into Cisco IOS Release 12.2(33)SRB.
12.2(33)SXI
This command was integrated into Cisco IOS Release 12.2(33)SXI.
Usage Guidelines
This command generates the following result variable:
_track_state--State of the specified tracked object. The text string returned is either up or down. If the state is up, it means that the object exists and is in an up state. If the state is down, it means that the object either does not exist or is in a down state.
This command is used to help track objects using EEM. Each tracked object is identified by a unique number that is specified on the tracking command-line interface (CLI). Client processes such as EEM use this number to track a specific object. The tracking process periodically polls the tracked objects and notes any change of value. The changes in the tracked object are communicated to interested client processes, either immediately or after a specified delay. The object values are reported as either up or down. The enhanced object tracking event detector publishes an EEM event when the tracked object changes.
Examples
The following example shows how to specify event criteria based on a tracked object:
event manager applet track-ten
event track 10 state any
action 1.0 track set 10 state up
action 2.0 track read 10
Related Commands
Command
Description
actiontrackread
Specifies the action of reading the state of a tracked object when an EEM applet is triggered.
eventmanagerapplet
Registers an event applet with the Embedded Event Manager and enters applet configuration mode.
showtrack
Displays tracking information.
trackstub
Creates a stub object to be tracked.
action while
To identify the beginning of a loop of a conditional block when an Embedded Event Manager (EEM) applet is triggered, use the actionwhilecommand in a
pplet configuration mode
. To disable this function, use the no form of this command.
actionlabelwhilestring-op1operatorstring-op2
noactionlabelwhile
Syntax Description
label
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks.
string-op1
Specifies the first operand.
operator
Value used with the string-op1 and string-op2 operands that determines how the current counter value is compared to the entry value or the exit value. Valid values are:
gt--Greater than.
ge--Greater than or equal to.
eq--Equal to.
ne--Not equal to.
lt--Less than.
le--Less than or equal to.
string-op2
The second operand.
Command Default
No conditional block is specified.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
12.4(22)T
This command was introduced.
12.2(33)SRE
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
Use the actionwhile command to identify the beginning of a loop conditional block. If $_variable is found within a string, it will be substituted before the expression is tested.
Examples
The following example shows how to identify the beginning of a loop of a conditional block when an EEM applet is triggered:
Router(config-applet)# action 1 set _i 2
Router(config-applet)# action 2 while $_i lt 10
Router(config-applet)# action 3 action syslog msg "i is $_i"
Router(config-applet)# action 4 end
Related Commands
Command
Description
actionelse
Identifies the beginning of an else block in the if/else conditional block.
actionelseif
Identifies the beginning of the if/else conditional block.
actionif
Identifies the beginning of an if conditional block.
eventmanagerapplet
Registers an event applet with the EEM and enters applet configuration mode.
attribute (EEM)
To specify a complex event for an Embedded Event Manager (EEM) applet, use the attributecommand in trigger applet configuration mode. To remove the attributes, use the no form of this command.
attributetagevent-tag
[ occursoccurs-value ]
noattributetagevent-tag
[ occursoccurs-value ]
Syntax Description
tag
Specifies a tag using the event-tag argument that can be used with the attribute command to associate an event.
event-tag
String that identifies the tag.
occurs
(Optional) Specifies the number of occurrences before an EEM event is triggered. If not specified, an EEM event is triggered on the first occurrence.
occurs-value
(Optional) Number in the range from 1 to 4294967295.
Command Default
No complex events are specified for an EEM applet.
This command was integrated into Cisco IOS Release 12.2(33)SRE.
Usage Guidelines
In the trigger applet configuration mode, up to eight attribute statements can be specified to build a complex event. If no attribute statements are specified, the options in the trigger statement apply to the first event defined in the applet.
Examples
The following example shows how to use the attribute command to specify a complex events for an EEM applet. In this example, the applet is run when the showbgpall command and any syslog message that contains the string “COUNT” occurs within a period of 60 seconds.
Enters trigger applet configuration mode and specifies the multiple event configuration statements for an EEM applet.
description (EEM)
To describe what an Embedded Event Manager (EEM) applet does, use the description (EEM) command in applet configuration mode. To remove the description of an applet, use the no form of this command.
descriptionline
nodescription
Syntax Description
line
A brief description of a policy, upto 240 characters.
Command Default
By default, no description is specified for an applet.
Command Modes
Applet configuration (config-applet)
Command History
Release
Modification
15.0(1)M
This command was introduced.
Usage Guidelines
Use this command to describe what an EEM applet does. It is valid to have applets without a description. The Description of an applet can be added in any order, before or after any other applet configuration. Configuring a new description for an applet that already has a description, overwrites the current description.
Examples
The following example shows how to add or modify the description for an EEM:
Router(config)# event manager applet one
Router(config-applet)# description "This applet looks for the word count in syslog messages"
Router(config-applet)# event syslog pattern "count"
Router(config-applet)# action 1 syslog msg hi
Related Commands
Command
Description
showeventmanagerpolicyactive
Displays EEM policies that are executed.
showeventmanagerpolicyavailable
Displays EEM policies that are available to be registered.