Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit d84de2fd authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent f781b13d
No related branches found
No related tags found
No related merge requests found
File added
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2020-07-14
#
# extended inventory of Huawei hardware components
#
def inv_huawei_hw_components(info, params):
def parse_huawei_hw_components(info):
def get_snmp_date(hwEntityManufacturedDate):
year = (ord(hwEntityManufacturedDate[0]) << 8) + ord(hwEntityManufacturedDate[1])
month = ord(hwEntityManufacturedDate[2])
day = ord(hwEntityManufacturedDate[3])
snmpDate = '%d-%02d-%02d' % (year, month, day)
return snmpDate
defaultEntities, huaweiEntities = info
entities = {}
for entry in huaweiEntities:
hwOID_END, hwEntityBomId, hwEntityBomEnDesc, hwEntityManufacturedDate, hwEntityBoardType, hwEntityOpticalVendorSn = entry
if hwEntityBomEnDesc != '':
entity = {}
entity['hwEntityBomId'] = hwEntityBomId
entity['hwEntityBomEnDesc'] = hwEntityBomEnDesc
entity['hwEntityManufacturedDate'] = get_snmp_date(hwEntityManufacturedDate)
entity['hwEntityBoardType'] = hwEntityBoardType
entity['serial_number'] = hwEntityOpticalVendorSn
for entry in defaultEntities:
OID_END, entPhysicalDescr, entPhysicalName, entPhysicalHardwareRev, entPhysicalFirmwareRev, entPhysicalSoftwareRev, entPhysicalSerialNum, entPhysicalMfgName = entry
if OID_END == hwOID_END:
entity['entPhysicalDescr'] = entPhysicalDescr
entity['entPhysicalName'] = entPhysicalName
entity['entPhysicalHardwareRev'] = entPhysicalHardwareRev
entity['entPhysicalFirmwareRev'] = entPhysicalFirmwareRev
entity['entPhysicalSoftwareRev'] = entPhysicalSoftwareRev
entity['entPhysicalMfgName'] = entPhysicalMfgName
if entity['serial_number'] == '':
entity['serial_number'] = entPhysicalSerialNum
entities[hwOID_END] = entity
return entities
node = inv_tree_list('hardware.components.huawei:')
entities = parse_huawei_hw_components(info)
for key, value in entities.items():
node.append({
'index': key,
'bom_id': value['hwEntityBomId'],
'bom_decription': value['hwEntityBomEnDesc'],
'manufactured_date': value['hwEntityManufacturedDate'],
'board_type': value['hwEntityBoardType'],
'description': value['entPhysicalDescr'],
'name': value['entPhysicalName'],
'hardware_revision': value['entPhysicalHardwareRev'],
'firmware_revision': value['entPhysicalFirmwareRev'],
'software_revision': value['entPhysicalSoftwareRev'],
'serial_number': value['serial_number'],
'vendor': value['entPhysicalMfgName'],
})
return node
inv_info['inv_huawei_hw_components'] = {
'inv_function': inv_huawei_hw_components,
'snmp_info': [
('.1.3.6.1.2.1.47.1.1.1.1', [
OID_END,
'2', # entPhysicalDescr
'7', # entPhysicalName
'8', # entPhysicalHardwareRev
'9', # entPhysicalFirmwareRev
'10', # entPhysicalSoftwareRev
'11', # entPhysicalSerialNum
'12', # entPhysicalMfgName
]),
('.1.3.6.1.4.1.2011.5.25.31.1.1', [
OID_END,
'2.1.1', # hwEntityBomId
'2.1.2', # hwEntityBomEnDesc
'2.1.4', # hwEntityManufacturedDate
'2.1.11', # hwEntityBoardType
'3.1.4' # hwEntityOpticalVendorSn
])
],
'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.2.0').startswith('.1.3.6.1.4.1.2011'),
}
{'author': u'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': u'SNMP inventory for Huawei hardware components.',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'inventory': ['huawei_hw_components'],
'web': ['plugins/views/inv_huawei_hw_components.py']},
'name': 'inv_huawei_hw_components',
'num_files': 2,
'title': u'Inventory for Huawei hardware components',
'version': '20200714.v0.1c',
'version.min_required': '1.2.8b8',
'version.packaged': '1.4.0p38'}
\ No newline at end of file
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
try:
from cmk.gui.plugins.views.inventory import (
declare_invtable_view,
render_inv_dicttable,
)
except:
pass
inventory_displayhints.update({
'.hardware.components.huawei:': {'title': _('Huawei'), 'render': render_inv_dicttable,
'keyorder': ['index', 'name', 'description', 'board_type', 'serial_number',
'manufactured_date', 'vendor',
],
'view': 'invhuawei_components_of_host',
},
'.hardware.components.huawei:*.index': {'title': _('Index'), },
'.hardware.components.huawei:*.name': {'title': _('Name')},
'.hardware.components.huawei:*.description': {'title': _('Description'), },
'.hardware.components.huawei:*.bom_id': {'title': _('BOM ID'), },
'.hardware.components.huawei:*.bom_decription': {'title': _('BOM Description')},
'.hardware.components.huawei:*.manufactured_date': {'title': _('Manufactured Date')},
'.hardware.components.huawei:*.board_type': {'title': _('Board Type'), },
'.hardware.components.huawei:*.software_revision': {'title': _('Software Revision'), },
'.hardware.components.huawei:*.firmware_revision': {'title': _('Firmware Revision'), },
'.hardware.components.huawei:*.hardware_revision': {'title': _('Hardware Revision'), },
'.hardware.components.huawei:*.serial_number': {'title': _('Serial Number'), },
'.hardware.components.huawei:*.vendor': {'title': _('Vendor'), },
})
declare_invtable_view('invhuawei_components', '.hardware.components.huawei:', _('Huawei hardware components'),
_('Huawei hardware components'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment