Module: check_mk
Branch: master
Commit: c473d3a233e5cc88a0594e9b3ff2eab32bc7c132
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c473d3a233e5cc…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jun 27 11:55:45 2014 +0200
FIX hw/sw inventory: fixed display bug for byte fields with the value 0
There was an exception for fields represented in bytes when the value was set to 0.
---
.werks/946 | 9 +++++++++
ChangeLog | 1 +
web/plugins/views/inventory.py | 2 +-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/.werks/946 b/.werks/946
new file mode 100644
index 0000000..9a299da
--- /dev/null
+++ b/.werks/946
@@ -0,0 +1,9 @@
+Title: hw/sw inventory: fixed display bug for byte fields with the value 0
+Level: 2
+Component: inv
+Class: fix
+State: unknown
+Version: 1.2.5i5
+Date: 1403862812
+
+There was an exception for fields represented in bytes when the value was set to 0.
diff --git a/ChangeLog b/ChangeLog
index 5028a38..bc14a7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
HW/SW-Inventory:
* 0167 FIX: mk_inventory.linux: Changed field separator from pipe to tab...
* 1005 FIX: Fix exception when using pretty-print output format
+ * 0946 FIX: hw/sw inventory: fixed display bug for byte fields with the value 0...
1.2.5i4:
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index 762d116..9d51510 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -501,7 +501,7 @@ def inv_paint_bytes(b):
if b == None:
return "", _("unknown")
elif b == 0:
- return "0"
+ return "number", "0"
units = [ 'B', 'kB', 'MB', 'GB', 'TB' ]
i = 0
Module: check_mk
Branch: master
Commit: 6bceda1edabbbfac515ee579ddaa93092b6b03b4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6bceda1edabbbf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 27 11:22:56 2014 +0200
New Mutisite filter for the number of services a host has
This filter is available for all views but currently added only in
the <i>Host search</i> view. It allows you to find hosts based on the
number of services they have. That way you can find e.g. hosts where
no service inventory has been done or your hosts that produce most
of your services.
---
.werks/1033 | 12 ++++++++++++
ChangeLog | 1 +
web/plugins/views/builtin.py | 1 +
web/plugins/views/filters.py | 2 ++
4 files changed, 16 insertions(+)
diff --git a/.werks/1033 b/.werks/1033
new file mode 100644
index 0000000..068e0fd
--- /dev/null
+++ b/.werks/1033
@@ -0,0 +1,12 @@
+Title: New Mutisite filter for the number of services a host has
+Level: 1
+Component: multisite
+Version: 1.2.5i5
+Date: 1403860884
+Class: feature
+
+This filter is available for all views but currently added only in
+the <i>Host search</i> view. It allows you to find hosts based on the
+number of services they have. That way you can find e.g. hosts where
+no service inventory has been done or your hosts that produce most
+of your services.
diff --git a/ChangeLog b/ChangeLog
index 39bc22c..5028a38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,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...
* 0945 FIX: Sidebar snapin "Problem hosts": Now excludes hosts and services in downtime
WATO:
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index a13f422..4896045 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -1154,6 +1154,7 @@ multisite_builtin_views.update({
'host_tags',
'hostalias',
'host_favorites',
+ 'host_num_services',
],
'sorters': [],
'title': _('Host search'),
diff --git a/web/plugins/views/filters.py b/web/plugins/views/filters.py
index 08100b5..c7938c3 100644
--- a/web/plugins/views/filters.py
+++ b/web/plugins/views/filters.py
@@ -519,6 +519,8 @@ class FilterNumberRange(Filter): # type is int
declare_filter(232, FilterNumberRange("host_notif_number", _("Current Host Notification Number"), "host", "current_notification_number"))
declare_filter(232, FilterNumberRange("svc_notif_number", _("Current Service Notification Number"), "service", "current_notification_number"))
+declare_filter(234, FilterNumberRange("host_num_services", _("Number of Services of the Host"), "host", "num_services"))
+
# Filter for setting time ranges, e.g. on last_state_change and last_check
foobar11 comes after foobar2
Message-ID: <53ad223f.caGFJ4barIIvbnKb%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 22a6a06f2dbd88d73c3bc994ba6a4e96073fe6c6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=22a6a06f2dbd88…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 27 09:49:38 2014 +0200
Sort host names naturally, e.g. foobar11 comes after foobar2
Hostnames are now sorted naturally. That means that sequences of numbers
are being interpreted as numbers. This also works for host names that
have the form of an IPv4 address, e.g. <tt>10.1.1.5</tt> is now correctly
sorted before <tt>10.1.1.11</tt> and <tt>srv17_3</tt> comes before <tt>src17_108</tt>.
This new sorting is implemented in the status GUI and also in WATO.
---
.werks/1013 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/lib.py | 13 +++++++++++++
web/htdocs/views.py | 3 +++
web/htdocs/wato.py | 4 ++--
web/plugins/views/sorters.py | 9 +++------
6 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/.werks/1013 b/.werks/1013
new file mode 100644
index 0000000..e33313e
--- /dev/null
+++ b/.werks/1013
@@ -0,0 +1,12 @@
+Title: Sort host names naturally, e.g. foobar11 comes after foobar2
+Level: 2
+Component: multisite
+Version: 1.2.5i5
+Date: 1403855030
+Class: feature
+
+Hostnames are now sorted naturally. That means that sequences of numbers
+are being interpreted as numbers. This also works for host names that
+have the form of an IPv4 address, e.g. <tt>10.1.1.5</tt> is now correctly
+sorted before <tt>10.1.1.11</tt> and <tt>srv17_3</tt> comes before <tt>src17_108</tt>.
+This new sorting is implemented in the status GUI and also in WATO.
diff --git a/ChangeLog b/ChangeLog
index 1692787..7e3ba3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
* 0944 FIX: oracle_tablespaces: fixed calculation of space left and number of remaining increments...
Multisite:
+ * 1013 Sort host names naturally, e.g. foobar11 comes after foobar2...
* 0945 FIX: Sidebar snapin "Problem hosts": Now excludes hosts and services in downtime
WATO:
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 645aae9..a724079 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -365,6 +365,19 @@ def regex(r):
return rx
+# Splits a word into sequences of numbers and non-numbers.
+# Creates a tuple from these where the number are converted
+# into int datatype. That way a naturual sort can be
+# implemented.
+def num_split(s):
+ if not s:
+ return ()
+ elif s[0].isdigit():
+ first_num = regex("[^0-9]").split(s)[0]
+ return ( int(first_num), ) + num_split(s[len(first_num):])
+ else:
+ first_word = regex("[0-9]").split(s)[0]
+ return ( first_word, ) + num_split(s[len(first_word):])
__builtin__.default_user_localizations = {
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index dd155df..985ad18 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2780,6 +2780,9 @@ def cmp_simple_string(column, r1, r2):
v1, v2 = r1.get(column, ''), r2.get(column, '')
return cmp_insensitive_string(v1, v2)
+def cmp_num_split(column, r1, r2):
+ return cmp(num_split(r1[column]), num_split(r2[column]))
+
def cmp_string_list(column, r1, r2):
v1 = ''.join(r1.get(column, []))
v2 = ''.join(r2.get(column, []))
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 98735a5..9acf07f 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1310,7 +1310,7 @@ def show_hosts(folder):
html.write("<h3>" + _("Hosts") + "</h3>")
hostnames = folder[".hosts"].keys()
- hostnames.sort()
+ hostnames.sort(cmp = lambda a, b: cmp(num_split(a), num_split(b)))
search_text = html.var("search")
# Helper function for showing bulk actions. This is needed at the bottom
@@ -3493,7 +3493,7 @@ def search_hosts_in_folder(folder, crit):
if found:
render_folder_path(folder, True)
- found.sort()
+ found.sort(cmp = lambda a,b: cmp(num_split(a[0]), num_split(b[0])))
table.begin("search_hosts", "");
for hostname, host, effective in found:
diff --git a/web/plugins/views/sorters.py b/web/plugins/views/sorters.py
index a429c82..767dafa 100644
--- a/web/plugins/views/sorters.py
+++ b/web/plugins/views/sorters.py
@@ -96,11 +96,8 @@ multisite_sorters["hoststate"] = {
}
def cmp_site_host(r1, r2):
- c = cmp(r1["site"], r2["site"])
- if c != 0:
- return c
- else:
- return cmp_simple_string("host_name", r1, r2)
+ return cmp(r1["site"], r2["site"]) or \
+ cmp_num_split("host_name", r1, r2)
multisite_sorters["site_host"] = {
"title" : _("Host"),
@@ -221,7 +218,7 @@ multisite_sorters['svc_perf_val10'] = {
# Host
-declare_1to1_sorter("alias", cmp_simple_string)
+declare_1to1_sorter("alias", cmp_num_split)
declare_1to1_sorter("host_address", cmp_ip_address)
declare_1to1_sorter("host_plugin_output", cmp_simple_string)
declare_1to1_sorter("host_perf_data", cmp_simple_string)