diff --git a/agent_based/checkpoint_inv_updates.py b/agent_based/checkpoint_inv_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..868031a6c3d410c75c6eaa77577007a0e4c10cc6 --- /dev/null +++ b/agent_based/checkpoint_inv_updates.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Author: thl-cmk[at]outlook[dot]com / thl-cmk.hopto.org +# +# Check Point updates 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 +# +# sample string_table +# [ +# [ +# ['1', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'HFA', 'Installed'], +# ['2', 'Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'Wrapper', 'Installed'], +# ['3', 'Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'HFA', 'Installed'] +# ], +# [ +# ['1', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'R80.40 SmartConsole Build 411', 'capability', 'Installed', '2020-09-30T00:00:00Z', 'Recommended', '2020-10-12T15:19:51Z'], +# ['2', 'Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'R80.40 Jumbo Hotfix Accumulator General Availability (Take 78)', 'jumbo', 'Installed', '2020-08-24T00:00:00Z', 'Recommended', '2020-10-12T15:36:58Z'], +# ['3', 'Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'Check Point CPinfo build 202 for R80.40', 'capability', 'Installed', '2020-01-26T00:00:00Z', 'Recommended', '2020-10-12T15:19:16Z'], +# ['4', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B410_Win.tgz', 'Check Point SmartConsole R80.40 Jumbo Hotfix B410', 'capability', 'Available for Install', '2020-08-24T00:00:00Z', 'Not Recommended', '2020-09-08T16:33:07Z'], +# ['5', 'Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'jumbo', 'Installed as part of', '1970-01-01T00:00:00Z', 'Not Recommended', '2020-09-07T19:06:50Z'], +# ['6', 'Check_Point_R81_T392_Fresh_Install_and_Upgrade.tgz', 'R81 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['7', 'Blink_image_1.1_Check_Point_R81_T392_SecurityManagement.tgz', '<b>[Latest] R81 Security Management for appliances </b>', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['8', 'Blink_image_1.1_Check_Point_R80.40_T294_JHF_T78_SecurityManagement.tgz', '<b>[Latest] R80.40 Security Management + JHF T78 for Appliances and Open Servers</b>', 'major', 'Available for Download', '2020-08-24T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['9', 'Check_Point_R80.40_T294_Fresh_Install_and_Upgrade.tgz', 'Check Point R80.40 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-01-27T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'] +# ], +# ] +# + +from typing import List, NamedTuple + +from .agent_based_api.v1.type_defs import ( + StringTable, + InventoryResult, +) +from .agent_based_api.v1 import ( + Attributes, + register, + SNMPTree, + TableRow, + startswith, + all_of, + any_of, + equals, +) + +class CheckpointUpdatesRecommended(NamedTuple): + name: str + type: str + status: list + +class CheckpointUpdatesAvailable(NamedTuple): + filename: str + description: str + type: str + status: str + availablesince: str + recommended: str + installedat: str + +class CheckpointUpdates(NamedTuple): + updatesrecommended: list + updatesavailable: list + +def parse_checkpoint_updates(string_table: List[StringTable]) -> CheckpointUpdates: + section = CheckpointUpdates + section.updatesrecommended = string_table[0] + section.updatesavailable = string_table[1] + return section + + +register.snmp_section( + name='checkpoint_inv_updates', + parse_function=parse_checkpoint_updates, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.2620.1.6.20.8.1', # CHECKPOINT-MIB::updatesRecommendedEntry + oids=[ + '2', # updatesRecommendedName + '3', # updatesRecommendedType + '4', # updatesRecommendedStatus + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.2620.1.6.20.10.1', # CHECKPOINT-MIB::availableUpdates + oids=[ + '2', # filename + '3', # description + '4', # type + '5', # status + '6', # available_since + '7', # recommended + '8', # installed_at + ] + ), + ], + detect= any_of( + startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2620'), + all_of( + equals('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.8072.3.2.10'), + equals('.1.3.6.1.4.1.2620.1.6.1.0','SVN Foundation' ), + ) + ) + ) + + +def inventory_checkpoint_updates(section: CheckpointUpdates) -> InventoryResult: + + path = ['software', 'check_point', 'updates'] + + for update in section.updatesrecommended: + update = CheckpointUpdatesRecommended(*update) + yield TableRow( + path=path, + key_columns={'file_name':update.name}, + inventory_columns={ + # 'index': update.index, + 'type': update.type, + 'status': update.status, + 'recommended': 'Recommended', + }, + ) + + path = ['software', 'check_point', 'updates'] + + for update in section.updatesavailable: + update = CheckpointUpdatesAvailable(*update) + + if not 'installed' in update.status.lower(): + installedat = 'N/A' + else: + installedat = update.installedat.replace('T', ' ').replace('Z','') + + yield TableRow( + path=path, + key_columns={'file_name':update.filename}, + inventory_columns={ + # 'index': update.index, + 'description': update.description, + 'type': update.type, + 'status': update.status, + 'recommended': update.recommended, + 'available_since': update.availablesince[:10], + 'installed_at': installedat, + }, + ) + + +register.inventory_plugin( + name='checkpoint_inv_updates', + inventory_function=inventory_checkpoint_updates, +) diff --git a/inv_checkpoint_updates.mkp b/inv_checkpoint_updates.mkp new file mode 100644 index 0000000000000000000000000000000000000000..317c44e15ebdee16ca774c72cd8251ab5f8b40a4 Binary files /dev/null and b/inv_checkpoint_updates.mkp differ diff --git a/packages/inv_checkpoint_updates b/packages/inv_checkpoint_updates new file mode 100644 index 0000000000000000000000000000000000000000..d5995ea6cee34cbd2e80841431a8133ea71ad4da --- /dev/null +++ b/packages/inv_checkpoint_updates @@ -0,0 +1,15 @@ +{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', + 'description': 'SNMP inventory of Check Point Appliances for ' + 'available/recommended updates.\n' + '\n' + '- 2021-02-08: initial release\n', + 'download_url': 'https://thl-cmk.hopto.org', + 'files': {'agent_based': ['checkpoint_inv_updates.py'], + 'web': ['plugins/views/checkpoint_updates.py']}, + 'name': 'inv_checkpoint_updates', + 'num_files': 2, + 'title': 'Check Point appliance avilable updates 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_updates.py b/web/plugins/views/checkpoint_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..8e5eb6fb893a985c871b0f0c898497c50fda498f --- /dev/null +++ b/web/plugins/views/checkpoint_updates.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.updates:': { + 'title': _('Updates'), + 'keyorder': [ + 'file_name', + 'type', + 'status', + 'recommended', + 'available_since', + 'installed_at', + 'description' + ], + 'view': 'invcheckpointupdates_of_host', + }, + }) + +from cmk.gui.plugins.views.inventory import declare_invtable_view + +declare_invtable_view( + 'invcheckpointupdates', + '.software.check_point.updates:', + _('Check Point updates'), + _('Check Point updates'), +)