diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index f53ed9a5..eb7152b7 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -1423,10 +1423,12 @@ from_client_stats(clixon_handle h,
char *str;
int modules = 0;
yang_stmt *yspec;
- yang_stmt *ymodext;
+ yang_stmt *ymounts;
+ yang_stmt *ydomain;
cxobj *xt = NULL;
- int ret;
+ char *name;
int inext;
+ int inext2;
if ((str = xml_find_body(xe, "modules")) != NULL)
modules = strcmp(str, "true") == 0;
@@ -1449,46 +1451,29 @@ from_client_stats(clixon_handle h,
if (clixon_stats_datastore_get(h, "startup", cbret) < 0)
goto done;
cprintf(cbret, "");
- /* per module-set, first configuration, then main dbspec, then mountpoints */
+ if ((ymounts = clixon_yang_mounts_get(h)) == NULL){
+ clixon_err(OE_YANG, ENOENT, "Top-level yang mounts not found");
+ goto done;
+ }
cprintf(cbret, "", CLIXON_LIB_NS);
- cprintf(cbret, "clixon-config");
- yspec = clicon_config_yang(h); /* Note switch yspec to config (not data) */
- if (clixon_stats_module_get(h, yspec, cbret) < 0)
- goto done;
- if (modules){
- inext = 0;
- while ((ym = yn_iter(yspec, &inext)) != NULL) {
- cprintf(cbret, "%s", yang_argument_get(ym));
- if (clixon_stats_module_get(h, ym, cbret) < 0)
- goto done;
- cprintf(cbret, "");
- }
- }
- cprintf(cbret, "");
- cprintf(cbret, "main");
- yspec = clicon_dbspec_yang(h);
- if (clixon_stats_module_get(h, yspec, cbret) < 0)
- goto done;
- if (modules){
- inext = 0;
- while ((ym = yn_iter(yspec, &inext)) != NULL) {
- cprintf(cbret, "%s", yang_argument_get(ym));
- if (clixon_stats_module_get(h, ym, cbret) < 0)
- goto done;
- cprintf(cbret, "");
- }
- }
- cprintf(cbret, "");
- /* Mountpoints */
- if ((ymodext = yang_find(yspec, Y_MODULE, "ietf-yang-schema-mount")) != NULL){
- if ((ret = xmldb_get0(h, "running", YB_MODULE, NULL, "/", 1, 0, &xt, NULL, NULL)) < 0)
- goto done;
- if (ret == 0){
- clixon_err(OE_DB, 0, "Error when reading from running, unknown error");
+ inext = 0;
+ while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
+ name = yang_argument_get(ydomain);
+ /* per module-set, first configuration, then main dbspec, then mountpoints */
+ cprintf(cbret, "");
+ cprintf(cbret, "%s", name);
+ if (clixon_stats_module_get(h, ydomain, cbret) < 0)
goto done;
+ if (modules){
+ inext2 = 0;
+ while ((ym = yn_iter(ydomain, &inext2)) != NULL) {
+ cprintf(cbret, "%s", yang_argument_get(ym));
+ if (clixon_stats_module_get(h, ym, cbret) < 0)
+ goto done;
+ cprintf(cbret, "");
+ }
}
- if (xt && yang_schema_mount_statistics(h, xt, modules, cbret) < 0)
- goto done;
+ cprintf(cbret, "");
}
cprintf(cbret, "");
cprintf(cbret, "");
diff --git a/apps/cli/cli_generate.c b/apps/cli/cli_generate.c
index be9d445e..e6a5da09 100644
--- a/apps/cli/cli_generate.c
+++ b/apps/cli/cli_generate.c
@@ -90,7 +90,6 @@ You can see which CLISPEC it generates via clixon_cli -D 2:
#include
#include
#include
-#include // XXX
#include
/* cligen */
diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c
index ba70629e..e7797438 100644
--- a/apps/cli/cli_show.c
+++ b/apps/cli/cli_show.c
@@ -1887,23 +1887,21 @@ cli_show_statistics(clixon_handle h,
size_t sz;
size_t tsz0;
size_t tsz;
- yang_stmt *yspec;
- cvec *cvv1 = NULL;
+ yang_stmt *ymounts;
+ yang_stmt *ydomain;
cg_var *cv;
cxobj *xp;
char *name;
cxobj *x;
uint64_t u64;
char *unit;
- yang_stmt *ymounts;
int inext;
- int i;
if (argv == NULL || (cvec_len(argv) < 1 || cvec_len(argv) > 2)){
clixon_err(OE_PLUGIN, EINVAL, "Expected arguments: [(cli|backend|all) [detail]]");
goto done;
}
- yspec = clicon_dbspec_yang(h);
+ ydomain = clicon_dbspec_yang(h);
cv = cvec_i(argv, 0);
what = cv_string_get(cv);
if (strcmp(what, "cli") == 0)
@@ -1931,67 +1929,29 @@ cli_show_statistics(clixon_handle h,
clixon_err(OE_PLUGIN, errno, "cbuf_new");
goto done;
}
+ if ((ymounts = clixon_yang_mounts_get(h)) == NULL){
+ clixon_err(OE_YANG, ENOENT, "Top-level yang mounts not found");
+ goto done;
+ }
if (cli) {
if (!detail) {
cligen_output(stdout, "%-25s %-10s\n", "YANG", "Mem");
}
- nr = 0; sz = 0;
- if (yang_stats(yspec, 0, &nr, &sz) < 0)
- goto done;
- tnr = nr;
- tsz = sz;
- if (detail) {
- cligen_output(stdout, "YANG-top-level-size: %" PRIu64 "\n", sz);
- cligen_output(stdout, "YANG-top-level-nr: %" PRIu64 "\n", nr);
- }
- else{
- translatenumber(sz, &u64, &unit);
- cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", "Top-level", u64, unit);
- }
- if (clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT")) {
- if ((ymounts = clixon_yang_mounts_get(h)) == NULL){
- clixon_err(OE_YANG, ENOENT, "Top-level yang mounts not found");
+ inext = 0;
+ while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
+ name = yang_argument_get(ydomain);
+ nr = 0; sz = 0;
+ if (yang_stats(ydomain, 0, &nr, &sz) < 0)
goto done;
+ tnr = nr;
+ tsz = sz;
+ if (detail) {
+ cligen_output(stdout, "YANG-%s-size: %" PRIu64 "\n", name, sz);
+ cligen_output(stdout, "YANG-%s-nr: %" PRIu64 "\n", name, nr);
}
- inext = 0;
- while ((yspec = yn_iter(ymounts, &inext)) != NULL) {
- cvv1 = NULL;
- if (yang_keyword_get(yspec) == Y_SPEC &&
- yang_flag_get(yspec, YANG_FLAG_SPEC_MOUNT) != 0x0 &&
- (cvv1 = yang_cvec_get(yspec)) != NULL){
- nr = 0; sz = 0;
- if (yang_stats(yspec, 0, &nr, &sz) < 0)
- goto done;
- tnr += nr;
- tsz += sz;
- i = 0;
- cv = NULL;
- while ((cv = cvec_each(cvv1, cv)) != NULL) {
- if (detail){
- if (i == cvec_len(cvv1)-1) {
- cligen_output(stdout, "YANG-mount-point-%s-size: %" PRIu64 "\n", cv_name_get(cv), sz);
- cligen_output(stdout, "YANG-mount-point-%s-nr: %" PRIu64 "\n", cv_name_get(cv), nr);
- }
- else {
- cligen_output(stdout, "YANG-mount-point-%s-size: shared\n", cv_name_get(cv));
- cligen_output(stdout, "YANG-mount-point-%s-nr: shared\n", cv_name_get(cv));
- }
- }
- else {
- if (i == cvec_len(cvv1)-1) {
- if (strlen(cv_name_get(cv)) > 25)
- cligen_output(stdout, "%s \n %-25s", cv_name_get(cv), "");
- else
- cligen_output(stdout, "%-25s", cv_name_get(cv));
- translatenumber(sz, &u64, &unit);
- cligen_output(stdout, "%" PRIu64 "%-10s\n", u64, unit);
- }
- else
- cligen_output(stdout, "%s\n", cv_name_get(cv));
- }
- i++;
- }
- }
+ else{
+ translatenumber(sz, &u64, &unit);
+ cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", yang_argument_get(ydomain), u64, unit);
}
}
if (detail){
@@ -2002,6 +1962,9 @@ cli_show_statistics(clixon_handle h,
translatenumber(tsz, &u64, &unit);
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", "YANG Total", u64, unit);
}
+ if (!detail) {
+ cligen_output(stdout, "%-25s\n", "CLIspec");
+ }
tnr0 = tnr;
tsz0 = tsz;
tnr = 0;
@@ -2031,6 +1994,7 @@ cli_show_statistics(clixon_handle h,
translatenumber(tsz0+tsz, &u64, &unit);
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", "Mem Total", u64, unit);
}
+
}
if (backend) {
cprintf(cb, " 25){
cligen_output(stdout, "%s\n", name);
diff --git a/lib/clixon/clixon_yang_schema_mount.h b/lib/clixon/clixon_yang_schema_mount.h
index 3809fe92..8e592ef4 100644
--- a/lib/clixon/clixon_yang_schema_mount.h
+++ b/lib/clixon/clixon_yang_schema_mount.h
@@ -64,7 +64,6 @@ int xml_yang_mount_set(clixon_handle h, cxobj *x, yang_stmt *yspec);
int yang_mount_xtop2xmnt(cxobj *xtop, cvec **cvvp);
int yang_mount_yspec2ymnt(yang_stmt *yspec, cvec **cvvp);
int yang_schema_mount_statedata(clixon_handle h, yang_stmt *yspec, char *xpath, cvec *nsc, cxobj **xret, cxobj **xerr);
-int yang_schema_mount_statistics(clixon_handle h, cxobj *xt, int modules, cbuf *cb);
int yang_schema_yanglib_parse_mount(clixon_handle h, cxobj *xt);
int yang_schema_get_child(clixon_handle h, cxobj *x1, cxobj *x1c, yang_stmt **yc);
int yang_schema_yspec_rm(clixon_handle h, cxobj *xmnt);
diff --git a/lib/src/clixon_yang_schema_mount.c b/lib/src/clixon_yang_schema_mount.c
index e82c8b45..b16d539d 100644
--- a/lib/src/clixon_yang_schema_mount.c
+++ b/lib/src/clixon_yang_schema_mount.c
@@ -695,100 +695,6 @@ yang_schema_mount_statedata(clixon_handle h,
goto done;
}
-/*! Statistics about mountpoints
- *
- * @param[in] h Clixon handle
- * @param[in] xtop Top XML node
- * @param[in] modules
- * @param[in] cb
- * @retval 0 OK
- * @retval -1 Error
- * @see yang_schema_mount_statedata
- */
-int
-yang_schema_mount_statistics(clixon_handle h,
- cxobj *xtop,
- int modules,
- cbuf *cb)
-{
- int retval = -1;
- cvec *cvv = NULL;
- cg_var *cv;
- cxobj *xmnt;
- yang_stmt *yspec;
- yang_stmt *ym;
- int ret;
- char *xpath = NULL;
- uint64_t nr;
- size_t sz;
- cg_var *cv1;
- yang_stmt *yspec1;
- int inext;
-
- if (yang_mount_xtop2xmnt(xtop, &cvv) < 0)
- goto done;
- cv = NULL;
- while ((cv = cvec_each(cvv, cv)) != NULL) {
- if ((xmnt = cv_void_get(cv)) == NULL)
- continue;
- if ((ret = xml_yang_mount_get(h, xmnt, NULL, &xpath, &yspec)) < 0)
- goto done;
- if (ret == 0)
- continue;
- cprintf(cb, "mountpoint: ");
- xml_chardata_cbuf_append(cb, 0, xpath);
- cprintf(cb, "");
- nr = 0; sz = 0;
- cv1 = NULL; /* For detecting shared YANGs */
- if (yspec) {
- cv1 = cv;
- while ((cv1 = cvec_each(cvv, cv1)) != NULL) {
- if (cv == cv1)
- continue;
- if ((ret = xml_yang_mount_get(h, cv_void_get(cv1), NULL, NULL, &yspec1)) < 0)
- goto done;
- if (yspec1 && yspec == yspec1)
- break;
- }
- }
- if (cv1 != NULL || yspec == NULL){
- cprintf(cb, "%" PRIu64 "%zu", nr, sz);
- cprintf(cb, "");
- if (xpath){
- free(xpath);
- xpath = NULL;
- }
- continue;
- }
- if (yang_stats(yspec, 0, &nr, &sz) < 0)
- goto done;
- cprintf(cb, "%" PRIu64 "%zu", nr, sz);
- if (modules){
- inext = 0;
- while ((ym = yn_iter(yspec, &inext)) != NULL) {
- cprintf(cb, "%s", yang_argument_get(ym));
- nr = 0; sz = 0;
- if (yang_stats(ym, 0, &nr, &sz) < 0)
- goto done;
- cprintf(cb, "%" PRIu64 "%zu", nr, sz);
- cprintf(cb, "");
- }
- }
- cprintf(cb, "");
- if (xpath){
- free(xpath);
- xpath = NULL;
- }
- }
- retval = 0;
- done:
- if (xpath)
- free(xpath);
- if (cvv)
- cvec_free(cvv);
- return retval;
-}
-
/*! Get yanglib from user plugin callback, parse it and mount it
*
* Optionally check for shared yspec
diff --git a/yang/clixon/clixon-lib@2024-08-01.yang b/yang/clixon/clixon-lib@2024-08-01.yang
index 59e7db91..b614aebb 100644
--- a/yang/clixon/clixon-lib@2024-08-01.yang
+++ b/yang/clixon/clixon-lib@2024-08-01.yang
@@ -423,10 +423,10 @@ module clixon-lib {
}
container module-sets{
list module-set{
- description "Statistics per group of module, eg top-level and mount-points";
+ description "Statistics per domain, eg top-level and mount-points";
key "name";
leaf name{
- description "Name of YANG module.";
+ description "Name of YANG domain.";
type string;
}
leaf nr{