The example program in $CONFD_DIR/examples.confd/misc/notifications
implemented by confd_notifications.c
can also serve as a nice tool and be used standalone in a development environment to monitor ConfD events.
Quick demo:
In terminal 1 we subscribe to all events except heartbeat using the confd_notifications program:
$ pwd
/Users/conny/tailf/confd-basic-5.4/examples.confd/misc/notifications
$ ./confd_notifications
./confd_notifications usage:
-d (daemon log messages)
-D (developer log messages)
-a (audit log messages)
-N (NETCONF log messages)
-S (SNMP log messages)
-t (takeover mode for syslog)
-u (user session messages)
-c (commit simple messages)
-i (iterate over commit diff)
-f (commit failed messages)
-C (confirmed-commit messages)
-P (commit progress messages)
-h (ha information messages)
-s (subagent messages)
-F (forward information messages)
-U (upgrade event messages)
-A (all of the above)
-H (heartbeat messages)
-e (health check messages)
-n 'name' (notification stream event messages for stream 'name')
-y (make audit log synchronous)
-Y (make ha info synchronous)
-r (request confirmation before sync reply)
-T 'interval' (interval for heartbeat / health check in seconds)
-B 'time' (start time for notification stream - yang:date-and-time form)
-E 'time' (stop time for notification stream - yang:date-and-time form)
-x 'filter' (XPath filter for notification stream)
-z 'usid' (User session id for AAA restriction on notification stream)
-p 'port' (connect to ConfD at 'port')
$ make start START_FLAGS=-A
/Users/conny/tailf/confd-basic-5.4/bin/confd -c ./confd.conf --addloadpath /Users/conny/tailf//confd-basic-5.4/etc/confd
./confd_notifications -A
Waiting for event notifications...
syslog: sym=29/STARTED prio=6 msg=ConfD started vsn: 5.4
In terminal 2 we commit a transaction over NETCONF:
$ netconf-console -i
* Enter a NETCONF operation, end with an empty line
<edit-config>
<target>
<running/>
</target>
<config xmlns="http://tail-f.com/ns/config/1.0">
<root xmlns="http://tail-f.com/ns/example/noti">
<bar>3210</bar>
</root>
</config>
</edit-config>
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<ok/>
</rpc-reply>
In terminal 1 we now received event notifications triggered by the NETCONF edit-config transaction:
audit: sym=107/SSH_LOGIN, user=admin usid=0 msg=logged in over ssh from 127.0.0.1 with authmeth:password
syslog: sym=86/NETCONF prio=1 msg=id=11 new ssh session for user "admin" from 127.0.0.1
audit: sym=104/GROUP_ASSIGN, user=admin usid=11 msg=assigned to groups: admin
user session: type=1, user=admin usid=11 db=0
syslog: sym=86/NETCONF prio=2 msg=id=11 got rpc: {urn:ietf:params:xml:ns:netconf:base:1.0}edit-config attrs: message-id="2"
user session: type=5, user=admin usid=11 db=2
syslog: sym=86/NETCONF prio=2 msg=id=11 edit-config target=running attrs: message-id="2"
Commit progress on db 2 usid 11 thandle 6:
entering validate phase for running...
Commit progress on db 2 usid 11 thandle 6:
validate: grabbing transaction lock...
Commit progress on db 2 usid 11 thandle 6:
ok
Commit progress on db 2 usid 11 thandle 6:
validate: creating rollback file...
Commit progress on db 2 usid 11 thandle 6:
ok
Commit progress on db 2 usid 11 thandle 6:
validate: run transforms and transaction hooks...
Commit progress on db 2 usid 11 thandle 6:
ok
Commit progress on db 2 usid 11 thandle 6:
validate: pre validate...
Commit progress on db 2 usid 11 thandle 6:
ok
Commit progress on db 2 usid 11 thandle 6:
validate: run validation over the change set...
Commit progress on db 2 usid 11 thandle 6:
validate: validation over the change set done
Commit progress on db 2 usid 11 thandle 6:
validate: run dependency-triggered validation...
Commit progress on db 2 usid 11 thandle 6:
validate: dependency-triggered validation done
user session: type=6, user=admin usid=11 db=2
syslog: sym=86/NETCONF prio=2 msg=id=11 sending rpc-reply, attrs: message-id="2"
In terminal 1 we now restart the confd_notifications program to listen only for commit events:
$ pwd
/Users/conny/tailf/confd-basic-5.4/examples.confd/misc/notifications
$ make start START_FLAGS=-c
...
/Users/conny/tailf/confd-basic-5.4/bin/confd -c ./confd.conf --addloadpath /Users/conny/tailf/confd-basic-5.4/etc/confd
./confd_notifications -c
Waiting for event notifications...
In terminal 2:
$ netconf-console -i
Enter a NETCONF operation, end with an empty line
<edit-config>
<target>
<running/>
</target>
<config xmlns="http://tail-f.com/ns/config/1.0">
<root xmlns="http://tail-f.com/ns/example/noti">
<bar>0123</bar>
</root>
</config>
</edit-config>
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<ok/>
</rpc-reply>
In terminal 1 we now see that our application received the CONFD_NOTIF_COMMIT_SIMPLE notification event:
Waiting for event notifications...
commit on db 2 from user admin usid 11