亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2116 | 回復: 9
打印 上一主題 下一主題

[函數(shù)] 【re】 erlang解析cisco config [復制鏈接]

論壇徽章:
30
水瓶座
日期:2014-08-22 21:06:3415-16賽季CBA聯(lián)賽之新疆
日期:2015-12-19 19:05:48IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:3315-16賽季CBA聯(lián)賽之上海
日期:2016-04-15 19:51:31程序設計版塊每日發(fā)帖之星
日期:2016-04-17 06:23:29程序設計版塊每日發(fā)帖之星
日期:2016-04-23 06:20:00程序設計版塊每日發(fā)帖之星
日期:2016-05-26 06:20:00每日論壇發(fā)貼之星
日期:2016-05-26 06:20:0015-16賽季CBA聯(lián)賽之遼寧
日期:2017-02-16 23:59:4715-16賽季CBA聯(lián)賽之天津
日期:2019-01-11 01:11:44
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2014-07-03 11:42 |只看該作者 |倒序瀏覽
本帖最后由 shijiang1130 于 2015-02-03 23:13 編輯
  1. parse(X,H)->
  2.         R=binary:split(X,<<"!\r\n">>,[global]), [list(B,H) || B <- R].

  3. list(X,H) ->
  4.         case size(X) > 9 of
  5.                 true ->
  6.                         <<A:9/binary,_/binary>> = X,
  7.                       case A == <<"interface">> of
  8.                               false -> ok;
  9.                               true ->
  10.                                       X1 =binary:split(X,<<"\r\n">>,[]),
  11.                                         Interface=binary:replace(lists:nth(1,X1),<<"interface ">>,<<>>),
  12.                                       case re:run(X,<<"description (.*)\r">>,[{capture,[1],list}]) of
  13.                                               {match,[Desc]} -> ok;
  14.                                               nomatch        -> Desc = 0
  15.                                       end,
  16.                                       case re:run(X,<<"no cdp">>,[]) of
  17.                                               {match,_} -> Cdp = 1;
  18.                                               nomatch   -> Cdp = 0
  19.                                       end,
  20.                                       case re:run(X,<<"speed (.*)\r">>,[{capture,[1],list}]) of
  21.                                               {match,[Speed]} -> ok;
  22.                                               nomatch         -> Speed = 0
  23.                                       end,                                                                           
  24.                         case re:run(X,<<"switchport mode (\\w+)">>,[{capture,[1],list}]) of
  25.                                 {match,[Mode]}  -> ok;
  26.                                 _               -> Mode = 0
  27.                         end,
  28.                         case re:run(X,<<"spanning-tree portfast">>,[]) of
  29.                                 {match,_}       ->        Portfast=1;
  30.                                 _               ->        Portfast=0
  31.                         end,
  32.                         case re:run(X,<<"spanning-tree bpduguard enable">>,[]) of
  33.                                 {match,_}       ->        Bpdu=1;
  34.                                 _               ->  Bpdu=0
  35.                         end,
  36.                         Interface1 = binary_to_list(Interface),
  37.                         Id = H++"-"++ Interface1,                                           
  38.                                       F=fun()->  
  39.                                               Row = #running_config{id=Id,interface=Interface1,hostname=H,
  40.                                               desc=Desc,speed=Speed,switchport=Mode,cdp=Cdp,portfast=Portfast,
  41.                                               bpdu=Bpdu,score=binary_to_list(lists:nth(2,X1))},
  42.                                               mnesia:write(Row)  
  43.                                       end,
  44.                                     mnesia:transaction(F)
  45.                         end;
  46.                 false ->
  47.                            ok
  48.         end.       
復制代碼

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
2 [報告]
發(fā)表于 2014-07-03 13:06 |只看該作者
哪種config ?

show config 出來的那個配置文件?

論壇徽章:
30
水瓶座
日期:2014-08-22 21:06:3415-16賽季CBA聯(lián)賽之新疆
日期:2015-12-19 19:05:48IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:3315-16賽季CBA聯(lián)賽之上海
日期:2016-04-15 19:51:31程序設計版塊每日發(fā)帖之星
日期:2016-04-17 06:23:29程序設計版塊每日發(fā)帖之星
日期:2016-04-23 06:20:00程序設計版塊每日發(fā)帖之星
日期:2016-05-26 06:20:00每日論壇發(fā)貼之星
日期:2016-05-26 06:20:0015-16賽季CBA聯(lián)賽之遼寧
日期:2017-02-16 23:59:4715-16賽季CBA聯(lián)賽之天津
日期:2019-01-11 01:11:44
3 [報告]
發(fā)表于 2014-07-03 13:37 |只看該作者
q1208c 發(fā)表于 2014-07-03 13:06
哪種config ?

show config 出來的那個配置文件?
是的,show runn config 要能抽出interface,對比interface.

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
4 [報告]
發(fā)表于 2014-07-03 15:58 |只看該作者
回復 3# shijiang1130


給個測試文件      

論壇徽章:
30
水瓶座
日期:2014-08-22 21:06:3415-16賽季CBA聯(lián)賽之新疆
日期:2015-12-19 19:05:48IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:3315-16賽季CBA聯(lián)賽之上海
日期:2016-04-15 19:51:31程序設計版塊每日發(fā)帖之星
日期:2016-04-17 06:23:29程序設計版塊每日發(fā)帖之星
日期:2016-04-23 06:20:00程序設計版塊每日發(fā)帖之星
日期:2016-05-26 06:20:00每日論壇發(fā)貼之星
日期:2016-05-26 06:20:0015-16賽季CBA聯(lián)賽之遼寧
日期:2017-02-16 23:59:4715-16賽季CBA聯(lián)賽之天津
日期:2019-01-11 01:11:44
5 [報告]
發(fā)表于 2014-07-03 16:15 |只看該作者
q1208c 發(fā)表于 2014-07-03 15:58
回復 3# shijiang1130
  1. Building configuration...

  2. Current configuration : 1384 bytes
  3. !
  4. version 12.4
  5. service timestamps debug datetime msec
  6. service timestamps log datetime msec
  7. no service password-encryption
  8. !
  9. hostname R1
  10. !
  11. boot-start-marker
  12. boot-end-marker
  13. !
  14. !
  15. no aaa new-model
  16. memory-size iomem 5
  17. no ip icmp rate-limit unreachable
  18. ip cef
  19. !
  20. !
  21. !
  22. !
  23. no ip domain lookup
  24. ip domain name t.cn
  25. !
  26. !
  27. !
  28. !
  29. !
  30. !
  31. !
  32. !
  33. !
  34. !
  35. !
  36. !
  37. !
  38. !
  39. !
  40. !
  41. !
  42. username admin password 0 admin
  43. !
  44. !
  45. ip tcp synwait-time 5
  46. !
  47. !
  48. !
  49. !
  50. !
  51. interface FastEthernet0/0
  52. ip address 172.16.1.1 255.255.255.0
  53. duplex auto
  54. speed auto
  55. !
  56. interface FastEthernet0/1
  57. no ip address
  58. shutdown
  59. duplex auto
  60. speed auto
  61. !
  62. interface FastEthernet1/0
  63. !
  64. interface FastEthernet1/1
  65. !
  66. interface FastEthernet1/2
  67. !
  68. interface FastEthernet1/3
  69. !
  70. interface FastEthernet1/4
  71. !
  72. interface FastEthernet1/5
  73. description R1:f1/5:R2:f1/5
  74. !
  75. interface FastEthernet1/6
  76. !
  77. interface FastEthernet1/7
  78. !
  79. interface FastEthernet1/8
  80. !
  81. interface FastEthernet1/9
  82. !
  83. interface FastEthernet1/10
  84. !
  85. interface FastEthernet1/11
  86. !
  87. interface FastEthernet1/12
  88. !
  89. interface FastEthernet1/13
  90. !
  91. interface FastEthernet1/14
  92. !
  93. interface FastEthernet1/15
  94. !
  95. interface Vlan1
  96. no ip address
  97. !
  98. !
  99. !
  100. !
  101. no ip http server
  102. no ip http secure-server
  103. !
  104. !
  105. !
  106. !
  107. !
  108. control-plane
  109. !
  110. !
  111. !
  112. !
  113. !
  114. !
  115. !
  116. !
  117. !
  118. !
  119. line con 0
  120. exec-timeout 0 0
  121. privilege level 15
  122. logging synchronous
  123. line aux 0
  124. exec-timeout 0 0
  125. privilege level 15
  126. logging synchronous
  127. line vty 0 4
  128. login local
  129. line vty 5 10
  130. login local
  131. !
  132. !
  133. end
復制代碼

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
6 [報告]
發(fā)表于 2014-07-03 18:36 |只看該作者
kao, 你這配置也太簡單了, 只有一個 interface 有配置, 其它的全是空的.

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
7 [報告]
發(fā)表于 2014-07-11 09:59 |只看該作者
回復 3# shijiang1130

你要對比 interface 的 config 變化么?
   

論壇徽章:
30
水瓶座
日期:2014-08-22 21:06:3415-16賽季CBA聯(lián)賽之新疆
日期:2015-12-19 19:05:48IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:3315-16賽季CBA聯(lián)賽之上海
日期:2016-04-15 19:51:31程序設計版塊每日發(fā)帖之星
日期:2016-04-17 06:23:29程序設計版塊每日發(fā)帖之星
日期:2016-04-23 06:20:00程序設計版塊每日發(fā)帖之星
日期:2016-05-26 06:20:00每日論壇發(fā)貼之星
日期:2016-05-26 06:20:0015-16賽季CBA聯(lián)賽之遼寧
日期:2017-02-16 23:59:4715-16賽季CBA聯(lián)賽之天津
日期:2019-01-11 01:11:44
8 [報告]
發(fā)表于 2014-07-11 14:05 |只看該作者
q1208c 發(fā)表于 2014-07-11 09:59
回復 3# shijiang1130

你要對比 interface 的 config 變化么?
是的,就是哪個接口配置了,哪個是空的,配置了的,是不是都配置全了,有沒有配置vlan

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
9 [報告]
發(fā)表于 2014-07-11 14:33 |只看該作者
回復 8# shijiang1130

好的. 我試試.


這幾天在忙著學習中
   

論壇徽章:
30
水瓶座
日期:2014-08-22 21:06:3415-16賽季CBA聯(lián)賽之新疆
日期:2015-12-19 19:05:48IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:31IT運維版塊每日發(fā)帖之星
日期:2015-12-25 06:20:3315-16賽季CBA聯(lián)賽之上海
日期:2016-04-15 19:51:31程序設計版塊每日發(fā)帖之星
日期:2016-04-17 06:23:29程序設計版塊每日發(fā)帖之星
日期:2016-04-23 06:20:00程序設計版塊每日發(fā)帖之星
日期:2016-05-26 06:20:00每日論壇發(fā)貼之星
日期:2016-05-26 06:20:0015-16賽季CBA聯(lián)賽之遼寧
日期:2017-02-16 23:59:4715-16賽季CBA聯(lián)賽之天津
日期:2019-01-11 01:11:44
10 [報告]
發(fā)表于 2015-02-03 23:14 |只看該作者
整理一下
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP