Module: check_mk
Branch: master
Commit: 6a069acf5b7e13e1bf677513f23621e26407b7f7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6a069acf5b7e13…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jul 2 15:56:10 2014 +0200
quicksearch: now able to search for multiple hosts at once
In the quicksearch snapin you can now enter the following syntax
C+:
h:firsthost h:otherhost h:testhost
C-:
The quicksearch dropdown will show the matches for the given names (case insensitive, no
exact match).
If you want an exact hostname match you need to finish the name with $.<br>
When you press enter a host search formular will show up with the hosts given in the
quicksearch field.<br>
The feature also works with host ip addresses<br>
In the quicksearch dropdown you can mix hostnames and ipaddresses - they will both show up
in the dropdown.
However, the search formular is only able to display either one or the other.
---
.werks/949 | 21 +++++++++++++++++++++
ChangeLog | 3 ++-
web/plugins/sidebar/search.py | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/.werks/949 b/.werks/949
new file mode 100644
index 0000000..9e0c832
--- /dev/null
+++ b/.werks/949
@@ -0,0 +1,21 @@
+Title: quicksearch: now able to search for multiple hosts at once
+Level: 1
+Component: multisite
+Version: 1.2.5i5
+Date: 1404308868
+Class: feature
+
+In the quicksearch snapin you can now enter the following syntax
+C+:
+h:firsthost h:otherhost h:testhost
+C-:
+
+The quicksearch dropdown will show the matches for the given names (case insensitive, no
exact match).
+If you want an exact hostname match you need to finish the name with $.<br>
+
+When you press enter a host search formular will show up with the hosts given in the
quicksearch field.<br>
+The feature also works with host ip addresses<br>
+
+In the quicksearch dropdown you can mix hostnames and ipaddresses - they will both show
up in the dropdown.
+However, the search formular is only able to display either one or the other.
+
diff --git a/ChangeLog b/ChangeLog
index 2dc1629..56a49f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,7 +15,7 @@
* 0172 zfsget: Check is now usable in cluster_mode...
* 1039 aix_diskiod: new check for disk IO on AIX
* 0997 New checks and an special agent for ALLNET IP Sensoric devices...
- * 0175 logwatch.groups: New logwatch subcheck who can be used to group logfiles
together.
+ * 0175 logwatch.groups: New logwatch subcheck who can be used to group logfiles
together....
* 0994 FIX: agent plugin smart: fixed syntax error
* 0989 FIX: logwatch.ec: Fix forwarding multiple messages via syslog/TCP...
* 0943 FIX: if.include: fixed incorrect traffic percentage values in the check output
of if checks...
@@ -30,6 +30,7 @@
Multisite:
* 1013 Sort host names naturally, e.g. foobar11 comes after foobar2...
* 1033 New Mutisite filter for the number of services a host has...
+ * 0949 quicksearch: now able to search for multiple hosts at once...
* 0945 FIX: Sidebar snapin "Problem hosts": Now excludes hosts and services
in downtime
* 1036 FIX: doc/treasures/downtime: fix --url option, better error output
diff --git a/web/plugins/sidebar/search.py b/web/plugins/sidebar/search.py
index c9ca971..5590f46 100644
--- a/web/plugins/sidebar/search.py
+++ b/web/plugins/sidebar/search.py
@@ -164,6 +164,19 @@ search_plugins.append({
'match_url_tmpl' :
'view.py?view_name=searchhost&hostalias=%(search)s&filled_in=filter'
})
+def search_hosts_filter(filters, host_is_ip = False):
+ lq_filter = ""
+ filter_template = host_is_ip and "Filter: host_address ~~ %s\n" or
"Filter: host_name ~~ %s\n"
+ for name, value in filters:
+ lq_filter += filter_template % value
+ if len(filters) > 1:
+ lq_filter += 'Or: %d\n' % len(filters)
+
+ return lq_filter
+
+def search_hosts_url_tmpl(used_filters, data, host_is_ip = False):
+ filter_field = host_is_ip and "host_address=(%s)" or "host=(%s)"
% "|".join(map(lambda x: x[1], used_filters))
+ return 'view.py?view_name=searchhost&filled_in=filter&' +
filter_field
def search_host_service_filter(filters, host_is_ip = False):
def get_filters(filter_type):
@@ -262,3 +275,25 @@ search_plugins.append({
"match_url_tmpl_func" : lambda x,y: match_host_service_url_tmpl(x, y,
host_is_ip = True),
"search_url_tmpl_func" : lambda x,y: search_host_service_url_tmpl(x, y,
host_is_ip = True),
})
+
+search_plugins.append({
+ "id" : "host_multi",
+ "qs_show" : "host_name",
+ "required_types" : ["hosts"],
+ "lq_table" : "hosts",
+ "lq_columns" : ["host_name",
"host_address"],
+ "filter_func" : lambda x: search_hosts_filter(x),
+ "match_url_tmpl_func" : lambda x,y:
"view.py?view_name=host&host=%(host_name)s&site=%(site)s" % y,
+ "search_url_tmpl_func" : lambda x,y: search_hosts_url_tmpl(x, y),
+})
+
+search_plugins.append({
+ "id" : "host_multi_address",
+ "qs_show" : "host_address",
+ "required_types" : ["hosts"],
+ "lq_table" : "hosts",
+ "lq_columns" : ["host_address",
"host_name"],
+ "filter_func" : lambda x: search_hosts_filter(x, True),
+ "match_url_tmpl_func" : lambda x,y:
"view.py?view_name=host&host_address=%(host_address)s&site=%(site)s" %
y,
+ "search_url_tmpl_func" : lambda x,y: search_hosts_url_tmpl(x, y, True),
+})