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

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

[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

[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

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?

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…

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

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

What output do you get if you run

$ arp -an

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

Hi,

I think it is solved now. Need to change

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

to

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