# Need assistance to write script for verifying EIGRP neigbourship in routers

**URL:** <https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241>\
**Category:** Ansible Project\
**Created:** [May 27, 2021, 4:56pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241 "2021-05-27T16:56:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [May 27, 2021, 4:56pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/1 "2021-05-27T16:56:32Z")

</div>

I request assistance to write a script that needs to verify that EIGRP neighbourship shown in router before IOS upgrade is the same after IOS upgrade (and reload) as well. Below is a sample output of EIGRP neibourship that i need to verify after IOS upgrade. How can i write a script for that?

ROUTER#sh ip eigrp neighbor  
EIGRP-IPv4 Neighbors for AS(500)  
H Address Interface Hold Uptime SRTT RTO Q Seq  
(sec) (ms) Cnt Num  
0 10.1.250.250 Gi1/1/1.255 10 1w6d 1 144 0 4409  
2 10.1.250.252 Gi1/1/1.255 13 6w5d 1 144 0 13775  
1 10.1.250.253 Gi1/1/1.255 10 6w5d 1 144 0 20042  
EIGRP-IPv4 Neighbors for AS(600)  
H Address Interface Hold Uptime SRTT RTO Q Seq  
(sec) (ms) Cnt Num  
19 10.250.254.70 Tu10 14 00:27:07 536 3216 0 537976  
12 10.250.255.50 Tu10 14 01:11:41 555 3330 0 328857  
7 10.250.255.60 Tu10 13 11:47:09 246 1476 0 1188183  
17 10.250.255.40 Tu10 14 1d11h 117 702 0 254686  
5 10.250.255.50 Tu10 10 1d14h 51 306 0 19347

Thanks,  
Vikram

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 27, 2021, 5:13pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/2 "2021-05-27T17:13:21Z")

</div>

As this is a list for ansible, I assume you mean ‘playbook’ when you say ‘script’.  
Since your question has nothing else that is related to ansible?

Sounds like you just need to compare some output before and after the upgrade so you can tell if they’re equal.

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [May 27, 2021, 9:39pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/3 "2021-05-27T21:39:03Z")

</div>

Hi Dick,

Sorry i didn’t frame my question properly. What i want to check is the number of entries in the output matches with the entries after IOS upgrade & reload.  
I wrote the below script but i don’t think it would help this script compares the whole output and not just the no. of entgries. Since the timer in secs would keep chaging, this script will always show wrong result. Any other suggestion you have?

name: GATHER SHOW VERSION  
ios\_command:  
commands: “show cdp nei”

register: show\_cdp

- debug:  
msg: “{{ show\_cdp.stdout\_lines[0] | list }}”

Thanks,  
Vikram

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 27, 2021, 10:03pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/4 "2021-05-27T22:03:05Z")

</div>

If it is about the number of entries then you should compare that before and after

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [May 28, 2021, 8:08am UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/5 "2021-05-28T08:08:12Z")

</div>

Hi,

I am wondering what module/ filter to use for comparing number of entries?

Thanks,  
Vikram

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 28, 2021, 11:49am UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/6 "2021-05-28T11:49:24Z")

</div>

Count

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [May 28, 2021, 3:24pm UTC](https://forum.ansible.com/t/need-assistance-to-write-script-for-verifying-eigrp-neigbourship-in-routers/35241/7 "2021-05-28T15:24:15Z")

</div>

Hi,

You truly rock!!! count filter helped. Below script solves my issue.

tasks:

- name: GATHER SHOW VERSION  
ios\_command:  
commands: “show ip eigrp nei”

register: show\_eigrp

- debug:  
msg: “{{ show\_eigrp.stdout\_lines[0] | count }}”

I will compare the command within debug msg with the similar output extracted after IOS upgrade & reload.

However i noticed that this comamnd wrosk only when i give it as ‘{{ show\_eigrp.stdout\_lines[0] | count }}’. Ifg i were to give it as {{ show\_eigrp.stdout\_lines | count }}, it shown count as zero. Any idea why this difference happens?

Thanks,  
Vikram
