날짜: 09-11-2023 03:45 PM
Timer Type |
Description |
absolute |
Specifies that an event is triggered when the specified absolute time of day occurs.event timer absolute time 13:22:24 |
countdown |
Specifies that an event is triggered when the specified time counts down to zero. The timer does not reset. In seconds.event timer countdown time 600 |
watchdog |
Specifies that an event is triggered when the specified time counts down to zero. The timer automatically resets to the initial value and continues to count down. In seconds.event timer watchdog time 60 |
cron |
Cron is not specific to IOS, it's a generic Linux time-based job scheduler. Cron uses the system clock to schedule one time, and repeating jobs based off of the time, days of the week, days of the month, or the calendar. If your having problems developing a specific cron string try looking it up on Google.A cron time is written using a set of 5 numbers, dashes, forward slash, and asterisk (*) that look like this:event timer cron cron-entry "1 * * * *"The position of the character denotes its function. From left to right:1. Minute (0-59): What minute of the hour the script will run on.2. Hour (0-23): What hour the script will run on, and is specified in the 24 hour clock.3. Day of the month (1-31): What day of the month the script will run on.4. Month (1-12): What month the script will run on.5. Day of Week (0-7): Day of the week. 0 to 6 are Sunday to Saturday, 7 is also SundayAn asterisk is a wildcard, or 'dont care'. A dash (-) denotes a range. The above example can be read "On the first minute of every hour, on every day of the month, on every month, on every day of the week". Or simply put run the script on the first minute of every hour.Here are a few more examples:17 8 * * * --run daily at 8:17 am17 20 * * * --run daily at 8:17 pm00 4 * * 0 --run at 4 am every Sunday42 4 1 * * --run 4:42 am every 1st of the month01 * 19 07 * --run hourly on the 19th of July59 11 * * 1-5 --run at 11:59 Monday, Tuesday, Wednesday, Thursday and FridayYou can also use a forward slash (/) to step field. Meaning that it would be ran like a watchdog. For example:*/1 * * * * --Run every minute* */2 * * * -- Run every two hours |
Event Type |
Description |
event snmp oid |
Look for the data of a specific SNMP OID. The data in these come in many data types, strings, ints, and booleans. A logical operator will be needed to trigger the event. For example:event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.3.1 get-type exact entry-op ge entry-val 50 poll-interval1! NOTE - Cat9k may require oid 1.3.6.1.4.1.9.2.1.56 get-type next due to CPU differencesThis oid is the current CPU utilization on a 6800 platform. This will look every second to see if the CPU is higher than 50%, if so the event will trigger. |
event syslog |
Look for a specific string in the syslog:event syslog pattern "UDLD_PORT_DISABLED"Look for the string "UDLD_PORT_DISABLED" anywhere in any new syslog message. |
Action |
Description |
action 1.0 cli command "<command>" |
Runs the specified CLI command. Just about anything you can manually run on the switch can be done here. Make sure to be in the right priviege mode.Example:action 1.0 cli command "show clock | appendbootdisk:thetime.txt"Run the 'show clock' command and print it to the bootdisk:thetime.txt file. |
action 1.0 wait <seconds> |
Do nothing for X seconds, then continue executing the EEM script |
action 1.0 syslog msg "<txt>" |
Prints the specified text to the system log |
action 1.0 if <var1> <operator> <var2>.....action 1.3 end |
An if statement. The if statement supports variable and is mostly used with them.
action 10 cli command "en"action 11 cli command "show ip arp | in b4e9.xxxx.6a41"action 12 regexp ".*(ARPA).*" $_cli_resultaction 13 if $_regexp_result eq 1action 14 syslog msg $_cli_resultaction 15 elseaction 16 syslog msg "Mac not found!"action 17 endRun the show arp command limited to the specified mac.Check to see if the there are any entries in the results of the show command. If there are print the line to the syslog else report that nothing was found. |
action 1.0 info type snmp <OID> get-type exact and "goto" operator |
Action gets a value and defines it to an internal value for SNMP results. In the example below, we trigger based on a syslog pattern, and then poll the CPU of the switch. Depending on the CPU utilization on that time determined which part of the script we perform actions on.event manager applet CPU_Monitor event syslog pattern "Neighbor Down: BFD node down"action 1.01 info type snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.3.1 get-type exact! NOTE - Cat9k may require "...oid 1.3.6.1.4.1.9.2.1.56 get-type next" due to CPU differencesaction 1.02 if $_info_snmp_value ge "85" goto 1.04action 1.03 if $_info_snmp_value lt "85" goto 1.12action 1.04 syslog priority critical msg " BFD Failure Detected - CPU: $_info_snmp_value Percent - Statistics Logged"action 1.11 cli command "end"action 1.12 syslog priority errors msg " BFD Failure Detected - CPU: $_info_snmp_value Percent - Statistics Logged"action 1.20 cli command "end" |
EEM Action |
Variable Name |
Description |
action add |
$_result |
Stores the sum of the previous addition operation |
action cli |
$_cli_result |
Contains the output from thelast CLI command executed. It will be overwritten each time "action cli" is invoked |
action regexp |
$_regexp_result |
A boolean value that indicates whether the regular expression matched. It the match was successful, the value will be '1', else it will be '0'. |
action info type snmp oid |
$_info_snmp_oid, $_info_snmp_value |
The OID and the value of the result of an SNMP GET, GETNEXT, or SET operation. |
안녕하세요.
아래 조건의 eem 가능할까요?
event manager applet GigabitEthernet2_1
event interface name GigabitEthernet2/1 parameter input_errors_crc entry-op ge entry-val 100 entry-type increment poll-interval 5
action 1.0 syslog priority critical msg "CRC is increasing with $_interface_value"
action 2.0 cli command "enable"
action 3.0 cli command "config t"
action 4.0 cli command "interface Gi2/1"
action 5.0 cli command "shutdown"
action 6.0 cli command "end"
위 문법은 5초에 한번씩 2/1 인터페이스 체크 후 CRC 100개와 같거나 이상이면 gi2/1 shutdown 으로 이해합니다.
이 문법에서 추가로 if 문을 넣어
10초 이내 crc개 100개 이상이 3회 연속 발생시 gi2/1 다운되도록 eem 가능할까요?
감사합니다.
안녕하세요.
확인 결과, 말씀주신 부분은 특정 이미지 버전에서 테스트 해봐야 되는 항목이므로 TAC 에 케이스 오픈해주시는 것을 추천드립니다.
감사합니다.
상단의 검색창에 키워드, 문구, 또는 질문을 입력하여 궁금한 내용을 찾아보세요.
이곳에서의 여러분의 여정이 훌륭하기를 바랍니다! 시스코 커뮤니티에 빠르게 익숙해지는 데 도움이 되는 몇 가지 링크를 준비했습니다.