Merge pull request #25 from Chocobo1/bits
Fix wrong unit displayed when using "--use-bit" option
This commit is contained in:
commit
2ccea2c56e
@ -44,7 +44,7 @@ text mode. See OUTPUT MODULES for more details.
|
|||||||
.PP
|
.PP
|
||||||
\fB \-U\fR, \fB\-\-use\-si\fR
|
\fB \-U\fR, \fB\-\-use\-si\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Use SI unit system instead of 1KB = 1'024 bytes.
|
Use SI unit system (1KB = 1'000 bytes) instead of 1KB = 1'024 bytes.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB \-f\fR, \fB\-\-configfile=\fRFILE
|
\fB \-f\fR, \fB\-\-configfile=\fRFILE
|
||||||
|
@ -774,6 +774,17 @@ static void netlink_shutdown(void)
|
|||||||
nl_socket_free(sock);
|
nl_socket_free(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void netlink_use_bit(struct attr_map *map, const int size)
|
||||||
|
{
|
||||||
|
if(cfg_getbool(cfg, "use_bit")) {
|
||||||
|
for(int i = 0; i < size; ++i) {
|
||||||
|
if(!strcmp(map[i].description, "Bytes")) {
|
||||||
|
map[i].description = "Bits";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int netlink_do_init(void)
|
static int netlink_do_init(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -798,6 +809,8 @@ static int netlink_do_init(void)
|
|||||||
goto disable;
|
goto disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
netlink_use_bit(link_attrs, ARRAY_SIZE(link_attrs));
|
||||||
|
netlink_use_bit(tc_attrs, ARRAY_SIZE(tc_attrs));
|
||||||
if (attr_map_load(link_attrs, ARRAY_SIZE(link_attrs)) ||
|
if (attr_map_load(link_attrs, ARRAY_SIZE(link_attrs)) ||
|
||||||
attr_map_load(tc_attrs, ARRAY_SIZE(tc_attrs)))
|
attr_map_load(tc_attrs, ARRAY_SIZE(tc_attrs)))
|
||||||
BUG();
|
BUG();
|
||||||
|
@ -328,9 +328,9 @@ static void print_help(void)
|
|||||||
" \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \
|
" \"$(element:name) $(attr:rxrate:packets) $(attr:txrate:packets)\\n\"\n" \
|
||||||
" eth0 33 5\n" \
|
" eth0 33 5\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
" \"Element: $(element:name)\\nBytes Rate: \" \\\n" \
|
" \"Item: $(element:name)\\n\" \\\n" \
|
||||||
" \"$(attr:rxrate:bytes)/$(attr:txrate:bytes)\\nPackets Rate: \" \\\n" \
|
" \"Bytes Rate: $(attr:rxrate:bytes)/$(attr:txrate:bytes)\\n\" \\\n" \
|
||||||
" \"$(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \
|
" \"Packets Rate: $(attr:rxrate:packets)/$(attr:txrate:packets)\\n\"\n" \
|
||||||
" Item: eth0\n" \
|
" Item: eth0\n" \
|
||||||
" Bytes Rate: 49130/2119\n" \
|
" Bytes Rate: 49130/2119\n" \
|
||||||
" Packets Rate: 40/11\n" \
|
" Packets Rate: 40/11\n" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user