# Do not know how to run the 5-stats example under examples.confd

**URL:** <https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140>\
**Category:** General\
**Created:** [July 13, 2022, 7:30am UTC](https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140 "2022-07-13T07:30:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fourwillings](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fourwillings](https://dmap-community.ductus.global/u/fourwillings)\
**Post date:** [July 13, 2022, 7:30am UTC](https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140/1 "2022-07-13T07:30:52Z")

</div>

Hi all,

I am wondering how to run the **5-stats** example (Example #5: Read-only Instrumentation) under confd-7.8.2/examples.confd/intro/python/5-stats. I followed the instruction in the README file, and below is what I got:

**First I built necessary files and started confD**

```auto
[user@machine 5-stats]$ make all start
/home/user/confd-7.8.2/bin/confdc --fail-on-warnings -c -o arpe.fxs arpe.yang
/home/user/confd-7.8.2/bin/confdc --emit-python arpe_ns.py arpe.fxs
mkdir -p ./confd-cdb
cp /home/user/confd-7.8.2/var/confd/cdb/aaa_init.xml ./confd-cdb
ln -s /home/user/confd-7.8.2/etc/confd/ssh ssh-keydir
Build complete
### Killing any confd daemon and ARP confd agents
/home/user/confd-7.8.2/bin/confd --stop || true
killall `pgrep -f "python3 ./arpstat.py"` || true
84412: no process found
84413: no process found
/home/user/confd-7.8.2/bin/confd -c confd.conf --addloadpath /home/user/confd-7.8.2/etc/confd
### * In one terminal window, run: tail -f ./confd.log
### * In another terminal window, run queries
### (try 'make query' for an example)
### * In this window, the arpstat confd daemon now starts:
### (hit Ctrl-c to exit)
python3 ./arpstat.py 
_confd.TRACE 2
TRACE Connected (maapi) to ConfD
TRACE Connected (dp) to ConfD
TRACE Received daemon id 0
TRACE Connected (dp) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_MNS_MAPS
TRACE MAAPI_LOAD_HASH_DB
TRACE Picked up old user session: 12 for user:system ctx:system
TRACE Picked up old user session: 11 for user:system ctx:system
TRACE Picked up old user session: 5 for user:system ctx:system
TRACE Picked up old user session: 1 for user:system ctx:system

```

**Then I started JunOS-style CLI in another terminal, and typed _show status arpentries_, but got an error**

```auto
[user@rtxdoclp121 5-stats]$ make cli
/home/user/confd-7.8.2/bin/confd_cli --user=admin --groups=admin \
        --interactive || echo Exit

admin connected from 168.127.214.38 using ssh on rtxdoclp121

admin@rtxdoclp121> show status arpentries
Error: application protocol error
[error][2022-07-13 02:30:44]
admin@rtxdoclp121> 
System message at 2022-07-13 02:30:44...
    Subsystem stopped: arpe_daemon

```

And below is the error message I saw in the terminal I started confD

```auto
TRACE New user session: 14 for user:admin ctx:cli --> CONFD_OK
TRACE CALL trans init(thandle=12,mode="r",db=running)Traceback (most recent call last):
  File "./arpstat.py", line 117, in cb_init
    arp.collect_arp_data() # get self.arpdata
  File "./arpstat.py", line 69, in collect_arp_data
    iface = arp_line[i+1].strip()
IndexError: list index out of range
 --> CONFD_OK
DEBUG No descriptor set for trans
Traceback (most recent call last):
  File "./arpstat.py", line 259, in <module>
    run()
  File "./arpstat.py", line 241, in run
    raise e
  File "./arpstat.py", line 238, in run
    dp.fd_ready(ctx, ctlsock) # 
_confd.error.Error: Bad protocol usage or unexpected retval (21): No descriptor set for trans
make: *** [start] Error 1

```

Does anyone know how to resolve this?

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [July 13, 2022, 8:41am UTC](https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140/2 "2022-07-13T08:41:23Z")

</div>

It looks like the example’s Python code does not correctly handle the output of `arp` command on your system for whatever reason → could be missing arp command, different than assumed textual output etc.

As you refer to Python example that is part of ConfD Premium, my guess is most straightforward & effective way will be to open a ticket via your support channel…

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [July 13, 2022, 3:07pm UTC](https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140/3 "2022-07-13T15:07:22Z")

</div>

> [@fourwillings](#):
>
> Does anyone know how to resolve this?

As you can see in the `arpstat.py` example, it uses the arp command to get the existing arp entries:

```python
self.fp = subprocess.Popen(["arp", "-an"], stdout=subprocess.PIPE,
                                   universal_newlines=True)

```

What output do you get if you run

```plaintext
$ arp -an

```

…on your system?  
And what OS, distribution, and version are you using?

---

<div class="post-metadata">

**Author:** ![fourwillings](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fourwillings](https://dmap-community.ductus.global/u/fourwillings)\
**Post date:** [July 14, 2022, 1:46pm UTC](https://dmap-community.ductus.global/t/do-not-know-how-to-run-the-5-stats-example-under-examples-confd/4140/4 "2022-07-14T13:46:48Z")

</div>

Hi,

I think it is solved now. Need to change

```auto
            if arp_line[1] == "incomplete":
                for elem in arp_line[1:]:
                    i += 1
                    if elem == "on":
                        break

```

to

```auto
            if arp_line[1] == "incomplete":
                for elem in arp_line[1:]:
                    if elem == "on":
                        break
                    i += 1

```
