يصف هذا وثيقة كيف أن يشكل Python برمجية أن يجمع OSPF، EIGRP و IS-IS سجل عندما البروتوكولات يرفرف.
توصي Cisco بأن تكون على دراية بالمواضيع المدرجة:
تستند المعلومات الواردة في هذا المستند إلى برنامج Cisco IOS XE الإصدار 17.
تم إنشاء المعلومات الواردة في هذا المستند من الأجهزة الموجودة في بيئة معملية خاصة. بدأت جميع الأجهزة المُستخدمة في هذا المستند بتكوين ممسوح (افتراضي). إذا كانت شبكتك قيد التشغيل، فتأكد من فهمك للتأثير المحتمل لأي أمر.
ملاحظة: لا يغطس هذا المستند في تفاصيل اللصق. يمكن العثور على مزيد من المعلومات في الارتباطات المشار إليها.
عند فتح حالة مركز المساعدة الفنية، من المهم للغاية تجميع المعلومات ذات الصلة لتوفير الوقت. في بعض الأحيان، تكون فكرة الفشل ضمن بعض المخرجات الأساسية التي يمكنك جمعها من الجهاز. في هذا المستند، لديك أمثلة لكيفية الاستفادة من نصوص 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. قم بتكوين VirtualPortGroup التي تعمل كبوابة افتراضية للعبارة الافتراضية guestshell.
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. الآن، أنت جاهز لتكوين نصوص بيثون التفاعلية. قم بتشغيل الأمر guestshell في وضع الامتياز. يمكنك ملاحظة المطالبة كما هو الحال في المثال التالي:
Router#guestshell
[guestshell@guestshell ~]$
الخطوة 4. قم بإنشاء ملف باستخدام محرر VI وقم بتكوين البرامج النصية استنادا إلى البروتوكولات التي قمت بتمكينها.
[guestshell@guestshell ~]$ vi ospf.py
يظهر هذا الإطار
~
~
~
~
~
~
~
"ospf.py" 0L, 0C
الخطوة 5. اضغط على "i" لإدراج نص. الصق النص التنفيذي ثم اضغط "esc"، ثم أدخل الحروف :wq
~
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 ~]$
قم بالخروج من Guestshell باستخدام الأمر exit.
اختبر البرنامج النصي. خروج من Guestshell باستخدام الأمر exit. ثم قم بتشغيل Guestshell، ثم قم بتشغيل 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")
يمكنك أتمتة مجموعة السجلات باستخدام نصوص فورية تقوم بتشغيل نصوص Python بعد ملاحظة أنماط syslog. في القسم التالي، لديك نصوص IM التي يمكنك تكوينها مع برامج Python النصية لإنجاز هذه المهمة.
بروتوكول أقصر مسار أولاً (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 طلب مزيد من المعلومات للتحقيق بشكل إضافي إذا لزم الأمر.
| المراجعة | تاريخ النشر | التعليقات |
|---|---|---|
1.0 |
01-Jul-2026
|
الإصدار الأولي |