이 문서에서는 프로토콜이 플랩할 때 OSPF, EIGRP 및 IS-IS 로그를 수집하도록 Python 스크립트를 구성하는 방법에 대해 설명합니다.
Cisco에서는 다음과 같은 항목에 대해 잘 알고 있는 것이 좋습니다.
이 문서의 정보는 Cisco IOS XE 소프트웨어 버전 17을 기반으로 합니다.
이 문서의 정보는 특정 랩 환경의 디바이스를 토대로 작성되었습니다. 이 문서에 사용된 모든 디바이스는 초기화된(기본) 컨피그레이션으로 시작되었습니다. 현재 네트워크가 작동 중인 경우 모든 명령의 잠재적인 영향을 미리 숙지하시기 바랍니다.
참고: 이 문서에서는 첨부 파일 세부 사항을 자세히 다루지 않습니다. 추가 정보는 참조된 링크에서 찾을 수 있습니다.
TAC 케이스를 열 때는 시간을 절약하기 위해 관련 정보를 수집하는 것이 매우 중요합니다. 때로는 장치에서 수집할 수 있는 몇 가지 기본 출력 내에 장애에 대한 단서가 있을 수 있습니다. 이 문서에서는 Python 스크립트를 활용하여 이 데이터를 가져오는 방법에 대한 예를 보여 줍니다. OSPF, EIGRP, IS-IS의 세 가지 프로토콜이 고려됩니다.
1단계. 가장 먼저 해야 할 일은 guestshell을 구성하고 활성화하는 것입니다.
Router(config)#iox
Router(config)#interface VirtualPortGroup 0
Router(config-if)#ip address 192.0.2.1 255.255.255.252
Router(config-if)#exit
Router(config)#
Router(config)#app-hosting appid guestshell
Router(config-app-hosting)#app-vnic gateway0 virtualportgroup 0 guest-interface 0
Router(config-app-hosting-gateway0)#guest-ipaddress 192.0.2.2 netmask 255.255.255.252
Router(config-app-hosting)#app-default-gateway 192.0.2.1 guest-interface 0
Router(config)#end
이 컨피그레이션에는 세 가지 중요한 단계가 있습니다.
1. IOX 서비스를 활성화합니다. 이는 guestshell을 활성화하는 데 필요합니다.
2. guestshell 기본 게이트웨이의 기본 게이트웨이 역할을 하는 VirtualPortGroup을 구성합니다.
3. guestshell에 대한 앱 호스팅을 구성합니다. 컨피그레이션에서 VirtualPortGroup이 실행되는 위치를 확인할 수 있습니다.
2단계. 그런 다음 권한 모드에서 guestshell을 활성화해야 합니다.
Router#guestshell enable
Interface will be selected if configured in app-hosting
Please wait for completion
guestshell installed successfully
Current state is: DEPLOYED
guestshell activated successfully
Current state is: ACTIVATED
guestshell started successfully
Current state is: RUNNING
Guestshell enabled successfully
Router#
*Jun 15 21:31:31.499: %IM-6-IOX_INST_INFO: R0/0: ioxman: IOX SERVICE guestshell LOG: Guestshell is up at 05/15/2026 21:31:31
모든 것이 올바르게 구성된 경우 앞의 예에서 로그를 확인해야 합니다.
3단계. 이제 python 스크립트를 구성할 준비가 되었습니다. 권한 모드에서 guestshell 명령을 실행합니다. 다음 예제와 같은 프롬프트가 표시됩니다.
Router#guestshell
[guestshell@guestshell ~]$
4단계. vi 편집기로 파일을 만들고 활성화한 프로토콜에 따라 스크립트를 구성합니다.
[guestshell@guestshell ~]$ vi ospf.py
이 창이 나타납니다.
~
~
~
~
~
~
~
"ospf.py" 0L, 0C
5단계. 텍스트를 삽입하려면 "i"를 누릅니다. 스크립트를 붙여넣은 다음 "esc"를 누른 다음 문자를 입력합니다.
~
from cli import cli
from time import sleep
cli("enable")
cli("debug ip ospf hello")
cli("debug ip ospf adj")
cli("show ip ospf interface | append bootflash:Router-ospf-logs.txt")
cli("show ip ospf neighbor | append bootflash:Router-ospf-logs.txt")
cli("show interfaces | append bootflash:Router-ospf-logs.txt")
cli("show logging | append bootflash:Router-ospf-logs.txt")
cli("show tech | append bootflash:Router-showtech.txt")
sleep(30)
cli("undebug all")
~
~
~
~
"ospf.py" [New] 14L, 458C written
[guestshell@guestshell ~]$
exit 명령을 사용하여 guestshell을 종료합니다.
스크립트 테스트. exit 명령을 사용하여 guestshell을 종료합니다. 그런 다음 guestshell run python3 ospf.py를 실행합니다.
F340.20.09-8500-1#guestshell run python3 ospf.py
세 가지 프로토콜 모두의 스크립트입니다. OSPF, EIGRP 및 IS-IS.
OSPF
from cli import cli
from time import sleep
cli("enable")
cli("debug ip ospf hello")
cli("debug ip ospf adj")
cli("show ip ospf interface | append bootflash:Router-ospf-logs.txt")
cli("show ip ospf neighbor | append bootflash:Router-ospf-logs.txt")
cli("show interfaces | append bootflash:Router-ospf-logs.txt")
cli("show logging | append bootflash:Router-ospf-logs.txt")
cli("show tech | append bootflash:Router-showtech.txt")
sleep(30)
cli("undebug all")
EIGRP
from cli import cli
from time import sleep
cli("enable")
cli("debug eigrp packet")
cli("show ip eigrp neighbor | append bootflash:Router-eigrp-logs.txt")
cli("show ip eigrp interface | append bootflash:Router-eigrp-logs.txt")
cli("show interfaces | append bootflash:Router-eigrp-logs.txt")
cli("show logging | append bootflash:Router-eigrp-logs.txt")
cli("show tech | append bootflash:Router-showtech.txt")
sleep(30)
cli("undebug all")
IS-IS
from cli import cli
from time import sleep
cli("enable")
cli("debug isis adj-packet")
cli("show isis neighbor detail | append bootflash:Router-isis-logs.txt")
cli("show clns neighbor detail | append bootflash:Router-isis-logs.txt")
cli("show clns interface | append bootflash:Router-isis-logs.txt")
cli("show interfaces | append bootflash:Router-isis-logs.txt")
cli("show logging | append bootflash:Router-isis-logs.txt")
cli("show tech | append bootflash:Router-showtech.txt")
sleep(30)
cli("undebug all")
syslog 패턴이 관찰된 후 Python 스크립트를 실행하는 EEM 스크립트를 사용하여 로그 수집을 자동화할 수 있습니다. 다음 섹션에서는 이 작업을 수행하기 위해 python 스크립트와 함께 구성할 수 있는 EEM 스크립트가 있습니다.
OSPF
event manager applet ospf-flap authorization bypass
event syslog pattern "%OSPF-5-ADJCHG:.*from FULL to DOWN" maxrun 120 ratelimit 120
action 010 cli command "enable"
action 020 cli command "guestshell run python3 ospf.py"
action 030 exit
EIGRP
event manager applet eirgp-flap authorization bypass
event syslog pattern "%DUAL-5-NBRCHANGE: EIGRP.*Neighbor.*is down" maxrun 120 ratelimit 120
action 010 cli command "enable"
action 020 cli command "guestshell run python3 eigrp.py"
action 030 exit
IS-IS
event manager applet isis-flap authorization bypass
event syslog pattern "%CLNS-5-ADJCHANGE: ISIS: Adjacency to.*Down" maxrun 120 ratelimit 120
action 010 cli command "enable"
action 020 cli command "guestshell run python3 isis.py"
action 030 exit
참고: 이 스크립트에서 수집된 명령은 기본적인 초기 정보를 제공합니다. TAC 케이스를 열 때 필요한 경우 TAC 엔지니어가 추가 조사를 요청하여 추가 정보를 요청할 수 있습니다.
| 개정 | 게시 날짜 | 의견 |
|---|---|---|
1.0 |
01-Jul-2026
|
최초 릴리스 |