Derive initial interface selection based on policy
So far, any output module with a selection capability defaulted to the first interface in the list as first pick. This uses the policy configuration instead and thus allows to select which interface to display first: Examples: bmon -p 'em1,*' bmon -p 'eth*,lo,*' The first rule that finds a matching interface is used and will trigger initial selection. Note that this is *ONLY* evaluated after the first read of the statistics so if a more preferred interface appears later, the selection will not be changed. Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
df271c43a4
commit
ddcd5e7d24
3
NEWS
3
NEWS
@ -1,3 +1,6 @@
|
||||
HEAD
|
||||
* Pick default selected interface based on policy
|
||||
|
||||
v3.9 - Jul 19, 2016
|
||||
* Color support
|
||||
* Add ability to reset statistics from curses UI
|
||||
|
@ -358,6 +358,26 @@ int element_set_usage_attr(struct element *e, const char *usage)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void element_pick_from_policy(struct element_group *g)
|
||||
{
|
||||
if (!list_empty(&allowed)) {
|
||||
struct policy *p;
|
||||
|
||||
list_for_each_entry(p, &allowed, p_list) {
|
||||
struct element *e;
|
||||
|
||||
list_for_each_entry(e, &g->g_elements, e_list) {
|
||||
if (match_mask(p, e->e_name)) {
|
||||
g->g_current = e;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
element_select_first();
|
||||
}
|
||||
|
||||
struct element *element_current(void)
|
||||
{
|
||||
struct element_group *g;
|
||||
@ -365,8 +385,12 @@ struct element *element_current(void)
|
||||
if (!(g = group_current()))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* If no element is picked yet, pick a default interface according to
|
||||
* the selection policy.
|
||||
*/
|
||||
if (!g->g_current)
|
||||
element_select_first();
|
||||
element_pick_from_policy(g);
|
||||
|
||||
return g->g_current;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user