The command prints the monitor activation threshold.
A sample usage is shown below:
$ tipc link monitor get threshold
32

$ tipc link monitor get -h
Usage: tipc monitor get PPROPERTY

PROPERTIES
 threshold      - Get monitor activation threshold

Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com>
---
 include/linux/tipc_netlink.h |  1 +
 tipc/link.c                  | 56 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/include/linux/tipc_netlink.h b/include/linux/tipc_netlink.h
index d387b65a0d97..d07c6ec76062 100644
--- a/include/linux/tipc_netlink.h
+++ b/include/linux/tipc_netlink.h
@@ -57,6 +57,7 @@ enum {
        TIPC_NL_NET_SET,
        TIPC_NL_NAME_TABLE_GET,
        TIPC_NL_MON_SET,
+       TIPC_NL_MON_GET,
 
        __TIPC_NL_CMD_MAX,
        TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
diff --git a/tipc/link.c b/tipc/link.c
index 6ee14c3c8a4c..a09444912515 100644
--- a/tipc/link.c
+++ b/tipc/link.c
@@ -534,12 +534,65 @@ static int cmd_link_mon_set(struct nlmsghdr *nlh, const 
struct cmd *cmd,
        return run_cmd(nlh, cmd, cmds, cmdl, NULL);
 }
 
+static void cmd_link_mon_get_help(struct cmdl *cmdl)
+{
+       fprintf(stderr, "Usage: %s monitor get PPROPERTY \n\n"
+               "PROPERTIES\n"
+               " threshold     - Get monitor activation threshold\n",
+               cmdl->argv[0]);
+}
+
+static int link_mon_get_cb(const struct nlmsghdr *nlh, void *data)
+{
+       struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+       struct nlattr *info[TIPC_NLA_MAX + 1] = {};
+       struct nlattr *attrs[TIPC_NLA_MON_MAX + 1] = {};
+
+       mnl_attr_parse(nlh, sizeof(*genl), parse_attrs, info);
+       if (!info[TIPC_NLA_MON])
+               return MNL_CB_ERROR;
+
+       mnl_attr_parse_nested(info[TIPC_NLA_MON], parse_attrs, attrs);
+       if (!attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD])
+               return MNL_CB_ERROR;
+
+       printf("%u\n",
+              mnl_attr_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]));
+
+       return MNL_CB_OK;
+}
+
+static int cmd_link_mon_get_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
+                            struct cmdl *cmdl, void *data)
+{
+       char buf[MNL_SOCKET_BUFFER_SIZE];
+
+       if (!(nlh = msg_init(buf, TIPC_NL_MON_GET))) {
+               fprintf(stderr, "error, message initialisation failed\n");
+               return -1;
+       }
+
+       return msg_doit(nlh,    link_mon_get_cb,        NULL);
+}
+
+static int cmd_link_mon_get(struct nlmsghdr *nlh, const struct cmd *cmd,
+                       struct cmdl *cmdl, void *data)
+{
+       const struct cmd cmds[] = {
+               { "threshold",  cmd_link_mon_get_prop,  NULL},
+               { NULL }
+       };
+
+       return run_cmd(nlh, cmd, cmds, cmdl, NULL);
+}
+
 static void cmd_link_mon_help(struct cmdl *cmdl)
 {
        fprintf(stderr,
                "Usage: %s montior COMMAND [ARGS] ...\n\n"
                "COMMANDS\n"
-               " set                  - Set monitor properties\n",
+               " set                   - Set monitor properties\n"
+               " get                   - Get monitor properties\n",
                cmdl->argv[0]);
 }
 
@@ -548,6 +601,7 @@ static int cmd_link_mon(struct nlmsghdr *nlh, const struct 
cmd *cmd, struct cmdl
 {
        const struct cmd cmds[] = {
                { "set",        cmd_link_mon_set,       cmd_link_mon_set_help },
+               { "get",        cmd_link_mon_get,       cmd_link_mon_get_help },
                { NULL }
        };
 
-- 
2.1.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to