13 1 月, 2015
Requirement:
1. Capture interface tunnel port each 5 minutes, if traffics > X, will capture other information.
2. Store those information to disk0/harddisk.
In fact, the requirement is very easy by Python + CRT, but customer couldn’t find a PC to continue to run python script, so only use EEM + TCL on ASR9k. And in TCL script, I use two function: foreach and scan.
Follow CLI need config before do script, if you change any variable or script, you need re-config “event manager policy tac_te.tcl username cisco”:
aaa authorization eventmanager default local
event manager environment _cron_entry1 */5 * * * *
event manager directory user policy disk0:
event manager policy tac_te.tcl username cisco persist-time 3600 type user
完整阅读
13 1 月, 2015
If customer want to focus a alarm on their NMS by SNMP Trap, they can config “snmp-server traps syslog”. But if customer no filter feature on NMS, they couldn’t find special alarm in all syslog, now we can use EEM + TCL to match customer requirement.
Follow TCL Script:
::cisco::eem::event_register_syslog pattern $_error_log occurs $_number period $_times maxrun 300
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
set alarm "***OOB_ERROR Happened!***"
sys_reqinfo_snmp_trapvar var temp oid 1.1.1.1.1.1.1.1 string $alarm
sys_reqinfo_snmp_trap enterprise_oid 1.3.6.1 generic_trapnum 6 specific_trapnum 2 trap_oid 1.1.1.1.1.1.1.1.1.1.1.1.1 trap_var temp
完整阅读
1 12 月, 2014
Python的课程终于结束了,真的很费时间,虽然拿到的分不高,但总算是从头到尾学了一遍,收获还是有的,下面是最终成绩:
Grade Achieved: 91.5% with Distinction
很期待用学到的知识去优化我之前写的CRT+python的脚本~
下面是课程备份,这些程序可能或多或少都存在一些问题,仅供自己以后复习:
Mini-project # 0 – “We want… a shrubbery!”
http://www.codeskulptor.org/#user37_anyV44QTvc_0.py
Mini-project # 2 – “Guess the number” game”
http://www.codeskulptor.org/#user38_bvOh0huwfS_8.py
完整阅读
18 11 月, 2014
下面是老师提到的方法,感觉不错就拿到这来了:
rock_group=set(["A", "B", "C", "D"])
#里面有4个陨石
def get_rid_of(rock_group, rock_del):
remove_set = set([])
#把要remove的陨石放到这个空集合中
for i in rock_group:
#遍历rock_group集合,每次i被集合中的元素赋值,一次一个,直到遍历全部
if i == rock_del:
remove_set.add(i)
#如果是碰撞的陨石,加到remove集合中
rock_group.difference_update(remove_set)
#打印rock_group和remove两个集合不同的元素
get_rid_of(rock_group,"D")
print rock_group
9 11 月, 2014
1. 引用相关的module
import simplegui
import math
import random
2. 全局参量
WIDTH = 800 # 画布的宽
HEIGHT = 600 # 画布的高
score = 0 # 初始分数0
lives = 3 # 3条命
time = 0.5 # 时间为0.5
FRICTION = 0.95 #摩擦系数
完整阅读