tipc: add link monitor summary
The monitor summary command prints the basic attributes
specific to the local node.
A sample usage is shown below:
$ tipc link monitor summary
bearer eth:data0
table_generation 15
cluster_size 8
algorithm overlapping-ring
bearer eth:data1
table_generation 15
cluster_size 8
algorithm overlapping-ring
$ tipc link monitor summary -h
Usage: tipc monitor summary
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Tested-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
This commit is contained in:
parent
7da7ef9bd8
commit
80e9807dff
47
tipc/link.c
47
tipc/link.c
|
|
@ -515,6 +515,49 @@ static int cmd_link_mon_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
|
||||||
return msg_doit(nlh, NULL, NULL);
|
return msg_doit(nlh, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int link_mon_summary_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);
|
||||||
|
|
||||||
|
printf("\nbearer %s\n",
|
||||||
|
mnl_attr_get_str(attrs[TIPC_NLA_MON_BEARER_NAME]));
|
||||||
|
|
||||||
|
printf(" table_generation %u\n",
|
||||||
|
mnl_attr_get_u32(attrs[TIPC_NLA_MON_LISTGEN]));
|
||||||
|
printf(" cluster_size %u\n",
|
||||||
|
mnl_attr_get_u32(attrs[TIPC_NLA_MON_PEERCNT]));
|
||||||
|
printf(" algorithm %s\n",
|
||||||
|
attrs[TIPC_NLA_MON_ACTIVE] ? "overlapping-ring" : "full-mesh");
|
||||||
|
|
||||||
|
return MNL_CB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmd_link_mon_summary(struct nlmsghdr *nlh, const struct cmd *cmd,
|
||||||
|
struct cmdl *cmdl, void *data)
|
||||||
|
{
|
||||||
|
char buf[MNL_SOCKET_BUFFER_SIZE];
|
||||||
|
|
||||||
|
if (help_flag) {
|
||||||
|
fprintf(stderr, "Usage: %s monitor summary\n", cmdl->argv[0]);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(nlh = msg_init(buf, TIPC_NL_MON_GET))) {
|
||||||
|
fprintf(stderr, "error, message initialisation failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg_dumpit(nlh, link_mon_summary_cb, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_link_mon_set_help(struct cmdl *cmdl)
|
static void cmd_link_mon_set_help(struct cmdl *cmdl)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s monitor set PPROPERTY\n\n"
|
fprintf(stderr, "Usage: %s monitor set PPROPERTY\n\n"
|
||||||
|
|
@ -592,7 +635,8 @@ static void cmd_link_mon_help(struct cmdl *cmdl)
|
||||||
"Usage: %s montior COMMAND [ARGS] ...\n\n"
|
"Usage: %s montior COMMAND [ARGS] ...\n\n"
|
||||||
"COMMANDS\n"
|
"COMMANDS\n"
|
||||||
" set - Set monitor properties\n"
|
" set - Set monitor properties\n"
|
||||||
" get - Get monitor properties\n",
|
" get - Get monitor properties\n"
|
||||||
|
" summary - Show local node monitor summary\n",
|
||||||
cmdl->argv[0]);
|
cmdl->argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -602,6 +646,7 @@ static int cmd_link_mon(struct nlmsghdr *nlh, const struct cmd *cmd, struct cmdl
|
||||||
const struct cmd cmds[] = {
|
const struct cmd cmds[] = {
|
||||||
{ "set", cmd_link_mon_set, cmd_link_mon_set_help },
|
{ "set", cmd_link_mon_set, cmd_link_mon_set_help },
|
||||||
{ "get", cmd_link_mon_get, cmd_link_mon_get_help },
|
{ "get", cmd_link_mon_get, cmd_link_mon_get_help },
|
||||||
|
{ "summary", cmd_link_mon_summary, NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue