[sr-dev] git:master:01e8e339: kex: added pkg.info rpc command

Daniel-Constantin Mierla miconda at gmail.com
Wed Sep 16 08:58:37 CEST 2020


Module: kamailio
Branch: master
Commit: 01e8e339149ce1554747929cb63b843866c53aba
URL: https://github.com/kamailio/kamailio/commit/01e8e339149ce1554747929cb63b843866c53aba

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-09-16T07:22:09+02:00

kex: added pkg.info rpc command

- get details about pkg manager

---

Modified: src/modules/kex/pkg_stats.c

---

Diff:  https://github.com/kamailio/kamailio/commit/01e8e339149ce1554747929cb63b843866c53aba.diff
Patch: https://github.com/kamailio/kamailio/commit/01e8e339149ce1554747929cb63b843866c53aba.patch

---

diff --git a/src/modules/kex/pkg_stats.c b/src/modules/kex/pkg_stats.c
index 9a2f4a2d37..ee6c637ace 100644
--- a/src/modules/kex/pkg_stats.c
+++ b/src/modules/kex/pkg_stats.c
@@ -259,11 +259,39 @@ static void rpc_pkg_stats(rpc_t* rpc, void* ctx)
 	}
 }
 
+/**
+ *
+ */
+static const char* rpc_pkg_info_doc[2] = {
+	"Private memory manager details",
+	0
+};
+
+/**
+ *
+ */
+static void rpc_pkg_info(rpc_t* rpc, void* ctx)
+{
+	void* th;
+
+	if (rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error creating rpc");
+		return;
+	}
+	if(rpc->struct_add(th, "su",
+			"name", (_pkg_root.mname)?_pkg_root.mname:"unknown",
+			"size", (unsigned int)pkg_mem_size) <0) {
+		rpc->fault(ctx, 500, "Internal error adding fields");
+		return;
+	}
+}
+
 /**
  *
  */
 rpc_export_t kex_pkg_rpc[] = {
 	{"pkg.stats", rpc_pkg_stats,  rpc_pkg_stats_doc,       RET_ARRAY},
+	{"pkg.info",  rpc_pkg_info,   rpc_pkg_info_doc,        0},
 	{0, 0, 0, 0}
 };
 




More information about the sr-dev mailing list