Skip to content

Commit

Permalink
add new option main_exclude_top5_hostgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Aug 2, 2024
1 parent 087f487 commit 770c8b3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ This file documents the revision history for the Monitoring Webinterface Thruk.

next:
- add optional oauth 2.1 pkce workflow
- add new option main_exclude_top5_hostgroups
- Config Tool:
- fix validating service parents (#1376)
- enable list wizard for host/service depenencies (#1358)
Expand Down
10 changes: 10 additions & 0 deletions docs/documentation/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,16 @@ ex.:
default_main_filter = contact = $REMOTE_USER$


=== main_exclude_top5_hostgroups

Exclude some hostgroups from the top 5 list on the "Home" page. The values
can be regular expressions.

ex.:

main_exclude_top5_hostgroups = all_hosts, regex.*filter


== Paging Settings


Expand Down
17 changes: 17 additions & 0 deletions lib/Thruk/Controller/main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ sub index {
############################################################################
# top 5 hostgroups
my $hostgroups = _get_top5_hostgroups($c, $hostfilter);
# exclude some hostgroups
if($c->config->{'main_exclude_top5_hostgroups'}) {
my $excludes = Thruk::Base::comma_separated_list($c->config->{'main_exclude_top5_hostgroups'});
for my $ex (@{$excludes}) {
if(Thruk::Base::looks_like_regex($ex)) {
for my $key (sort keys %{$hostgroups}) {
## no critic
if($key =~ /$ex/) {
delete $hostgroups->{$key};
}
## use critic
}
} else {
delete $hostgroups->{$ex};
}
}
}
my $top5_hg = [];
my @hashkeys_hg = sort { $hostgroups->{$b} <=> $hostgroups->{$a} || $a cmp $b } keys %{$hostgroups};
splice(@hashkeys_hg, 5) if scalar(@hashkeys_hg) > 5;
Expand Down
3 changes: 3 additions & 0 deletions thruk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ ssl_verify_hostnames=1
# default main filter
#default_main_filter = contact = $REMOTE_USER$

# exclude some hostgroups from the top 5 list on the "Home" page
# main_exclude_top5_hostgroups =

######################################
# maximum number of allowed search boxes
#maximum_search_boxes = 9
Expand Down

0 comments on commit 770c8b3

Please sign in to comment.