[checkmk-commits] Check_MK Git: check_mk: inventory of switch ports: fixed speed > 10Gb, add alias

Mathias Kettner mk at mathias-kettner.de
Wed Apr 29 17:13:28 CEST 2015


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

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Apr 29 17:13:22 2015 +0200

inventory of switch ports: fixed speed > 10Gb, add alias

---

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

diff --git a/inventory/if b/inventory/if
index 8cb77a2..3c68cf9 100644
--- a/inventory/if
+++ b/inventory/if
@@ -36,8 +36,8 @@ def inv_if(info, params):
     available_ethernet_ports = 0
 
     node = inv_tree("networking.interfaces:")
-    for if_index, if_descr, if_type, if_speed, if_oper_status, if_admin_status, \
-        if_phys_address, if_last_change in info:
+    for if_index, if_descr, if_alias, if_type, if_speed, if_high_speed, \
+        if_oper_status, if_admin_status, if_phys_address, if_last_change in info:
 
         if if_type in ( "231", "232" ):
             continue # Useless entries for "TenGigabitEthernet2/1/21--Uncontrolled"
@@ -58,11 +58,16 @@ def inv_if(info, params):
             seconds = float(parts[3])
             last_change = seconds + 60*minutes + 3600*hours + 86400*days
 
+        if if_high_speed:
+            speed = int(if_high_speed) * 1000 * 1000
+        else:
+            speed = int(if_speed)
 
         node.append({
             "index"        : int(if_index),
             "description"  : if_descr,
-            "speed"        : int(if_speed),
+            "alias"        : if_alias,
+            "speed"        : speed,
             "phys_address" : render_mac_address(if_phys_address),
             "oper_status"  : int(if_oper_status),
             "admin_status" : int(if_admin_status), # 1(up) or 2(down)
@@ -86,15 +91,17 @@ def inv_if(info, params):
 
 inv_info['inv_if'] = {
     "inv_function" : inv_if,
-    'snmp_info': ( ".1.3.6.1.2.1.2.2.1", [
-         1,            # ifIndex
-         2,            # ifDescr
-         3,            # ifType
-         5,            # ifSpeed
-         8,            # ifOperStatus
-         7,            # ifAdminStatus
-         6,            # ifPhysAddress
-         9,            # ifLastChange
+    'snmp_info': ( ".1.3.6.1.2.1", [
+         "2.2.1.1",            # ifIndex
+         "2.2.1.2",            # ifDescr
+         "31.1.1.1.18",        # ifAlias
+         "2.2.1.3",            # ifType
+         "2.2.1.5",            # ifSpeed
+         "31.1.1.1.15",        # ifHighSpeed   .. 1000 means 1Gbit
+         "2.2.1.8",            # ifOperStatus
+         "2.2.1.7",            # ifAdminStatus
+         "2.2.1.6",            # ifPhysAddress
+         "2.2.1.9",            # ifLastChange
     ]),
     'snmp_scan_function': lambda oid: int(oid(".1.3.6.1.2.1.2.1.0")) >= 2,
 }
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index 17b2742..7027a30 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -456,7 +456,7 @@ def inv_paint_if_oper_status(oper_status):
     else:
         css_class = "if_state_other"
 
-    return "if_state " + css_class, interface_oper_states.get(oper_status, str(oper_status))
+    return "if_state " + css_class, interface_oper_states.get(oper_status, str(oper_status)).replace(" ", " ")
 
 
 # admin status can only be 1 or 2, matches oper status :-)
@@ -584,9 +584,10 @@ inventory_displayhints.update({
     ".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", },
+                                                           "keyorder" : [ "index", "description", "alias", "oper_status", "admin_status", "available", "speed" ], "view" : "invinterface_of_host", },
     ".networking.interfaces:*.index"                   : { "title" : _("Index"), "paint" : "number", "filter" : visuals.FilterInvtableIDRange },
     ".networking.interfaces:*.description"             : { "title" : _("Description") },
+    ".networking.interfaces:*.alias"                   : { "title" : _("Alias") },
     ".networking.interfaces:*.phys_address"            : { "title" : _("Physical Address (MAC)")  },
     ".networking.interfaces:*.oper_status"             : { "title" : _("Operational Status"), "short" : _("Status"), "paint" : "if_oper_status", "filter" : visuals.FilterInvtableOperStatus },
     ".networking.interfaces:*.admin_status"            : { "title" : _("Administrative Status"), "short" : _("Admin"), "paint" : "if_admin_status", "filter" : visuals.FilterInvtableAdminStatus },



More information about the checkmk-commits mailing list