Read netconf-state statistics from CDB

Hi,

I would like to read the netconf-state statistics from CDB.
Currently I am using external DB but I understood that I can use both.

In my application I have 2 processes: CFGD, RCPD, CONFD.
Till now for configuration CFGD worked with CONFD process and it was OK.
Now I need to read the statistics fom CONFD using the RCPD process.
The question is what about all the initialization for CONFD connection between CFGD & CONFD.? It should be suplicate to RCPD as well?
Currently in CFGD we do: cond_init(), confd_init_daemon(), confd_set_daemon_flags(), create control & worker sockets, confd_load_schemas(), confd_connect() for the sockets.

So now when I want to connect CONFD from RCPD I need to do all these initializations from RCPD as well?
As example, in user guide section 6.6, I need to do again all the init in the main() in my RCPD proccess as well, or what I did in CFGD is good enough.

Thanks,

Yes and no.

Yes, you must initialize the library and connect to ConfD in RCPD too but the initialization is a bit different when you use CDB.

See the examples.confd/cdb_oper directory for examples of how to store state data in CDB.

Hi,

I did cdb_start_session & cdb_set_namespace, it looks ok.
But how I can read now the data? for example, /netconf-state/statistics/in-bad-hellos
In the example you mentioned they write to cdb oper. but how to read?
I tried few APIs but all of them returned fail or exception.
I tried:
CONFD_SET_XMLTAG(&Counter, ncm_in_bad_hellos, ncm__ns);
NetconfStatisticsShow.InBadHellos = CONFD_GET_INT32(&Counter);
or:
cdb_get_int32(ReadSocket, &NetconfStatisticsShow.InBadHellos, “/netconf-state/statistics/in-bad-hellos”)

thanks,

You read operational data from CDB the same way you read configuration data, the only difference is that if you want to subscribe for changes to operational data you must use cdb_oper_subscribe() or cdb_subscribe2() rather than cdb_subscribe().

Before you can read any data from CDB your application have to create and connect a data socket to ConfD.

if ((rsock = socket(PF_INET, SOCK_STREAM, 0)) < 0 )
    confd_fatal("Failed to open socket\n");

if (cdb_connect(rsock, CDB_DATA_SOCKET, (struct sockaddr*)&addr,
                  sizeof (struct sockaddr_in)) < 0)
    return CONFD_ERR;

if (cdb_start_session(rsock, CDB_OPERATIONAL) != CONFD_OK)
    return CONFD_ERR;

cdb_set_namespace(rsock, dhcpd__ns);

read data using cdb_get_xxx() calls here

There are many examples that show how to subscribe for configuration data stored in CDB, see for example /examples.confd/intro/1-2-3-start-query-model and everything under examples.confd/cdb_subscribe.

You can also refer to chapter 5 in the User Guide.

Hi,

I succeeded to read the configuration from Conf-d using Confd 6.2.

But after doing upgrade to Confd 6.4 I don’t see it count the info.

Even from confd_cli when I am executiong the show command I see all zeros although NETCONF client is connected and sent RPCs:
root@npt1800:~# cd /run/package/
root@npt1800:/run/package# ./Confd/bin/confd_cli
Welcome to ConfD Basic

The CLI may only be used during product development.
Commercial use of the CLI is prohibited.
You must disable the CLI in confd.conf for production.
For more information, visit http://www.tail-f.com.
root connected from 10.64.121.68 using ssh on npt1800
npt1800# show netconf-state s
Possible completions:
schemas sessions statistics
npt1800# show netconf-state statistics
netconf-state statistics in-bad-hellos 0
netconf-state statistics in-sessions 0
netconf-state statistics dropped-sessions 0
netconf-state statistics in-rpcs 0
netconf-state statistics in-bad-rpcs 0
netconf-state statistics out-rpc-errors 0
netconf-state statistics out-notifications 0

The differences in confd.conf are:

  1. namespace added in 6.4
  2. audit log was enabled in 6.4
  3. notification enabled in 6.4
  4. interleave enabled in 6.4

Please assist.

Thanks,

Check again if you NETCONF client actually did send RPC messages, or if you sent notifications, that there actually was a client listening to them.

An easy way to check (and to have in-sessions and in-rpcs increment) is to just do something like:

$ netconf-console --get -x /netconf-state/statistics
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
      <statistics>
        <netconf-start-time>2016-06-01T06:21:43+02:00</netconf-start-time>
        <in-bad-hellos>0</in-bad-hellos>
        <in-sessions>1</in-sessions>
        <dropped-sessions>0</dropped-sessions>
        <in-rpcs>1</in-rpcs>
        <in-bad-rpcs>0</in-bad-rpcs>
        <out-rpc-errors>0</out-rpc-errors>
        <out-notifications>0</out-notifications>
      </statistics>
    </netconf-state>
  </data>
</rpc-reply>

Hi,

I ran it on my Ubuntu machine (Confd for x86_64) and I saw statisitics.
But on my NE (PPC) I am connected to NSO and I did sync-from & configured some configuration but I can’t see anything in statistics even from confd_cli.
You can see below that confd_cli recognized that something was configured from NETCONF but no record in statistics
root@npt1800:/run/package# ./Confd/bin/confd_cli
Welcome to ConfD Basic

The CLI may only be used during product development.
Commercial use of the CLI is prohibited.
You must disable the CLI in confd.conf for production.
For more information, visit http://www.tail-f.com.
root connected from 10.64.121.68 using ssh on npt1800
npt1800# show netconf-state s
Possible completions:
schemas sessions statistics
npt1800# show netconf-state statistics
netconf-state statistics in-bad-hellos 0
netconf-state statistics in-sessions 0
netconf-state statistics dropped-sessions 0
netconf-state statistics in-rpcs 0
netconf-state statistics in-bad-rpcs 0
netconf-state statistics out-rpc-errors 0
netconf-state statistics out-notifications 0
npt1800#
System message at 2017-05-08 02:25:42…
Commit performed by admin via ssh using netconf.
npt1800# show netconf-state statistics
netconf-state statistics in-bad-hellos 0
netconf-state statistics in-sessions 0
netconf-state statistics dropped-sessions 0
netconf-state statistics in-rpcs 0
netconf-state statistics in-bad-rpcs 0
netconf-state statistics out-rpc-errors 0
netconf-state statistics out-notifications 0
npt1800#

Regards,

That works on PPC with ConfD Basic 6.4 too.
Based on how you described your use case in the past, perhaps you put a callpoint in the $CONFD_DIR/src/confd/yang/ietf-netconf-monitoring.yang that you are not handling correctly?

Hi,

I didn’t do any change to the YANG model.
I even compared it and it is the same in confd_6.2 & confd_6.4.

Hi,

From some reson the .fxs file that was created as result of my compilation and the .fxs which include in your confd_6.4 package is different.
I took the ietf-netconf-monitoring.fxs from the formal confd_6.4 package and it is working now.

Thanks,

I don’t see any reason to recompile this module, but it you do it in $CONFD_DIR/src/confd/yang, the Makefile there will automatically use the ietf-netconf-monitoring-ann.yang annotation module that adds internal callpoints to provide the data:

$ cd $CONFD_DIR/src/confd/yang
$ make ietf-netconf-monitoring.fxs
/tmp/confd-6.4/bin/confdc -c -o ietf-netconf-monitoring.fxs -a ietf-netconf-monitoring-ann.yang -- ietf-netconf-monitoring.yang

Hi,

Now after update the .fxs as I said I can read the statistics using confd_cli.
But now in my code when I am doing:
cdb_cd(ConfdReadSocket, “netconf-state/statistics”);
cdb_get_u_int32(ConfdReadSocket, &NetconfStatisticsShow.InBadHellos, “in-bad-hellos”);
it doesn’t work. before changing the .fxs it works !!!
when using the annotation yang module the path is changing?

please assist,

The statistics provided by this module are not stored in CDB (when the callpoint is annotated), but by a ConfD-internal data provider (i.e. it counts the packets etc and provides the counters when requested). You can read them programmatically via the MAAPI api (which of course works also for any data stored in CDB, whether config or state, and is the equivalent of how it is read from a NB interface).

If you compile the module without a callpoint annotated, the storage for config false data will indeed default to CDB-operational - but this doesn’t work, since there isn’t any code to update that data (unless you (reduntantly) write it, but I don’t where you would get the data from in that case).

Bottom line, many of the YANG modules provided as source in $CONFD_DIR/src/confd/yang must be compiled with the corresponding annotation modules in order to actually “work” - this just amounts to connecting the data model to the instrumentation, like you may do for your “own” modules - the difference is that the instrumentation is internal to ConfD in these cases.

Hi,

I succeeded to read the statistics from Confd.

Do you support clear for these statistics as well?
If no, can I clear these statistics manually by writing zeros using maapi APIs?

Thansk,

No and no. The module (which is part of RFC 6022) specifies the rules - for per-session counters (under /netconf-state/sessions/session):

  description
    "Per-session counters.  Zero based with following reset
     behaviour:
       - at start of a session
       - when max value is reached";

and for global counters (under /netconf-state/statistics):

    description
      "Global counters, accumulated from all sessions.
       Zero based with following reset behaviour:
         - re-initialization of NETCONF server
         - when max value is reached";

Any other behavior would not be compliant with the RFC.