[checkmk-commits] Check_MK Git: check_mk: Switch port inventory: new view with overal statistics

Mathias Kettner mk at mathias-kettner.de
Fri Apr 24 12:08:14 CEST 2015


Module: check_mk
Branch: master
Commit: 1d85b3e501074219f5d14fb6ef168af89ff146d2
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1d85b3e501074219f5d14fb6ef168af89ff146d2

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Fri Apr 24 12:08:04 2015 +0200

Switch port inventory: new view with overal statistics

---

 inventory/if                   |    5 ++++-
 web/plugins/views/inventory.py |   48 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/inventory/if b/inventory/if
index 68c39a4..8cb77a2 100644
--- a/inventory/if
+++ b/inventory/if
@@ -79,7 +79,10 @@ def inv_if(info, params):
         else:
             if_available = None
 
-
+    node = inv_tree("networking.")
+    node["available_ethernet_ports"] = available_ethernet_ports
+    node["total_ethernet_ports"] = total_ethernet_ports
+    node["total_interfaces"] = len(info)
 
 inv_info['inv_if'] = {
     "inv_function" : inv_if,
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index fcc5706..c6fcf1c 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -528,6 +528,7 @@ inventory_displayhints.update({
     ".hardware.memory.arrays:*.devices:*.size"         : { "title" : _("Size"),                   "paint" : "bytes", },
     ".hardware.memory.arrays:*.devices:*.speed"        : { "title" : _("Speed"),                  "paint" : "hz", },
     ".hardware.system."                                : { "title" : _("System") },
+    ".hardware.system.product"                         : { "title" : _("Product") },
     ".hardware.storage."                               : { "title" : _("Storage") },
     ".hardware.storage.disks:"                         : { "title" : _("Block Devices") },
     ".hardware.storage.disks:*."                       : { "title" : _("Block Device %d") },
@@ -579,6 +580,9 @@ inventory_displayhints.update({
     ".software.packages:*.path"                        : { "title" : _("Path"), },
 
     ".networking."                                     : { "title" : _("Networking"), "icon" : "networking" },
+    ".networking.total_interfaces"                     : { "title" : _("Interfaces"), "paint" : "count", },
+    ".networking.total_ethernet_ports"                 : { "title" : _("Ports"), "paint" : "count", },
+    ".networking.available_ethernet_ports"             : { "title" : _("Ports available"), "paint" : "count", },
     ".networking.interfaces:"                          : { "title" : _("Interfaces"), "render" : render_inv_dicttable,
                                                            "keyorder" : [ "index", "description", "oper_status", "admin_status", "available", "speed" ], "view" : "invinterface_of_host", },
     ".networking.interfaces:*.index"                   : { "title" : _("Index"), "paint" : "number", "filter" : visuals.FilterInvtableIDRange },
@@ -597,7 +601,7 @@ for invpath, hint in inventory_displayhints.items():
     if "*" not in invpath:
         datatype = hint.get("paint", "str")
         long_title = inv_titleinfo_long(invpath, None)
-        declare_inv_column(invpath, datatype, long_title, hint.get("short", long_title))
+        declare_inv_column(invpath, datatype, long_title, hint.get("short", hint["title"]))
 
 
 #.
@@ -899,6 +903,8 @@ multisite_builtin_views["inv_host"] = {
     'sorters'                      : [],
 }
 
+generic_host_filters = multisite_builtin_views["allhosts"]["show_filters"]
+
 # View with table of all hosts, with some basic information
 multisite_builtin_views["inv_hosts_cpu"] = {
     # General options
@@ -951,6 +957,46 @@ multisite_builtin_views["inv_hosts_cpu"] = {
 }
 
 
+# View with available and used ethernet ports
+multisite_builtin_views["inv_hosts_ports"] = {
+    # General options
+    'datasource'                   : 'hosts',
+    'topic'                        : _('Inventory'),
+    'title'                        : _('Switch port statisticss'),
+    'linktitle'                    : _('Switch ports (all Hosts)'),
+    'description'                  : _('A list of all hosts with statistics about total, used and free networking interfaces'),
+    'public'                       : True,
+    'hidden'                       : False,
+
+    # Layout options
+    'layout'                       : 'table',
+    'num_columns'                  : 1,
+    'browser_reload'               : 0,
+    'column_headers'               : 'pergroup',
+    'user_sortable'                : True,
+    'play_sounds'                  : False,
+    'force_checkboxes'             : False,
+    'mustsearch'                   : False,
+    'mobile'                       : False,
+
+    # Columns
+    'group_painters'               : [],
+    'painters'                     : [
+         ('host',                       'invinterface_of_host', ''),
+         ('inv_hardware_system_product',             None, ''),
+         ('inv_networking_total_interfaces',         None, ''),
+         ('inv_networking_total_ethernet_ports',     None, ''),
+         ('inv_networking_available_ethernet_ports', None, ''),
+    ],
+
+    # Filters
+    'hard_filters'                 : [ 'has_inv' ],
+    'hard_filtervars'              : [ ('is_has_inv', '1' ), ],
+    'hide_filters'                 : [],
+    'show_filters'                 : generic_host_filters + [],
+    'sorters'                      : [ ('inv_networking_available_ethernet_ports', True) ],
+}
+
 
 
 #.



More information about the checkmk-commits mailing list