diff --git a/agent_based/checkpoint_inv_support.py b/agent_based/checkpoint_inv_support.py new file mode 100644 index 0000000000000000000000000000000000000000..6d702f20519d249f4d88d157dd5697d7ff10be83 --- /dev/null +++ b/agent_based/checkpoint_inv_support.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Author: thl-cmk[at]outlook[dot]com / thl-cmk.hopto.org +# +# Check Point inventory +# +# 2016-06-29 : inventory Check Point Appliance +# 2018-03-05 : added Patches, Deployment Agent Build +# 2018-03-07 : added Licenses +# 2020-06-01 : cleanup, prepared for cmk1.7x, rename from inv_checkpoint_svn to checkpoint_inv_base +# 2020-11-27 : rewrite for CMK check API 1.0 (CMK 2.0) +# 2020-11-28 : added available updates +# 2021-02-08 : transfered license/support info to seperate plugin +# 2021-02-22 : code cleanup +# +# sample string_table +# [ +# [ +# ['0008262230', 'Smart-1 5150 NGSM', 'E4:43:4B:AA:BB:CC', 'a5rYfxLngVSZtHjK2sfghhp6noVfzuTvSEbt', 'CPAP-NGSM5150', 'Collaborative Enterprise Support - StandardPro Add-on for Products', '1751500800', '2'] +# ] +# ] +# + +import time + +from typing import List, NamedTuple + +from .agent_based_api.v1.type_defs import ( + StringTable, + InventoryResult, +) +from .agent_based_api.v1 import ( + register, + SNMPTree, + TableRow, + startswith, + all_of, + any_of, + equals, +) + + +class CheckpointLicensing(NamedTuple): + accountid: str + packagedescription: str + containerck: str + signaturekey: str + containersku: str + supportlevel: str + supportexpiration: str + activationstatus: str + + +def parse_checkpoint_inv_licensing(string_table: List[StringTable]) -> List: + section = [] + for license in string_table[0]: + license = CheckpointLicensing(*license) + if not license.containerck == '': + section.append(license) + return section + + +def inventory_checkpoint_licensing(section: List) -> InventoryResult: + path = ['software', 'check_point', 'support'] + + lic_state = { + '1': 'trial period', + '2': 'activated' + } + + for license in section: + license = CheckpointLicensing(*license) + supportexpiration = 'N/A' + if not license.supportexpiration == '': + supportexpiration = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(license.supportexpiration))) + + yield TableRow( + path=path, + key_columns={'certificate_key': license.containerck}, + inventory_columns={ + 'account_id': license.accountid, + 'description': license.packagedescription, + 'signatur_key': license.signaturekey, + 'container': license.containersku, + 'support_type': license.supportlevel, + 'support_renewal': supportexpiration, + 'state': lic_state.get(license.activationstatus, license.activationstatus) + }, + ) + + +register.snmp_section( + name='checkpoint_inv_licensing', + parse_function=parse_checkpoint_inv_licensing, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.2620.1.6.18.2', # CHECKPOINT-MIB::licensingAssetInfo + oids=[ + '1', # licensingAssetAccountId + '2', # licensingAssetPackageDescription + '3', # licensingAssetContainerCK + '4', # Signature key + '5', # licensingAssetContainerSKU + '6', # licensingAssetSupportLevel + '7', # licensingAssetSupportExpiration + '8', # licensingAssetActivationStatus + ] + ), + ], + detect=any_of( + startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2620'), # sysObjectID == CheckPoint + all_of( + equals('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.8072.3.2.10'), # sysObjectID == Linux + equals('.1.3.6.1.4.1.2620.1.6.1.0', 'SVN Foundation'), # CheckPoint software installed + ) + ) +) + +register.inventory_plugin( + name='checkpoint_inv_licensing', + inventory_function=inventory_checkpoint_licensing, +) diff --git a/inv_checkpoint_support.mkp b/inv_checkpoint_support.mkp new file mode 100644 index 0000000000000000000000000000000000000000..db378c455e10e320efa90ecc28c865a8ac9627cf Binary files /dev/null and b/inv_checkpoint_support.mkp differ diff --git a/packages/inv_checkpoint_support b/packages/inv_checkpoint_support new file mode 100644 index 0000000000000000000000000000000000000000..4262962d9dcec86a3926c12b68c0ae2c134488b8 --- /dev/null +++ b/packages/inv_checkpoint_support @@ -0,0 +1,13 @@ +{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', + 'description': 'SNMP inventory of Check Point Appliances for license/support ' + 'status\n', + 'download_url': 'https://thl-cmk.hopto.org', + 'files': {'agent_based': ['checkpoint_inv_support.py'], + 'web': ['plugins/views/checkpoint_support.py']}, + 'name': 'inv_checkpoint_support', + 'num_files': 2, + 'title': 'Check Point appliance support inventory plugin', + 'version': '20210208.v.0.1', + 'version.min_required': '2.0.0i1', + 'version.packaged': '2020.11.27', + 'version.usable_until': None} \ No newline at end of file diff --git a/web/plugins/views/checkpoint_support.py b/web/plugins/views/checkpoint_support.py new file mode 100644 index 0000000000000000000000000000000000000000..f97348edfef3f7133e513f86d97a1791edf8ce09 --- /dev/null +++ b/web/plugins/views/checkpoint_support.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import cmk.gui.utils +from cmk.gui.plugins.views import ( + inventory_displayhints,) +from cmk.gui.i18n import _ + +inventory_displayhints.update({ + '.software.check_point.support:': { + 'title': _('Support'), + 'keyorder': [ + 'account_id', + 'certificate_key', + 'container', + 'description', + 'state', + 'support_renewal', + 'support_type', + ], + 'view': 'invcheckpointsupport_of_host', + }, + }) + +from cmk.gui.plugins.views.inventory import declare_invtable_view + +declare_invtable_view( + 'invcheckpointsupport', + '.software.check_point.support:', + _('Check Point support'), + _('Check Point support'), +)