From f09c0e969dade8d5be027c515432c5e6d3ed8282 Mon Sep 17 00:00:00 2001 From: thl-cmk <thl-cmk@outlook.com> Date: Mon, 22 Feb 2021 21:31:22 +0100 Subject: [PATCH] update project --- agent_based/checkpoint_inv_updates.py | 159 ++++++++++++++++++++++++ inv_checkpoint_updates.mkp | Bin 0 -> 2756 bytes packages/inv_checkpoint_updates | 15 +++ web/plugins/views/checkpoint_updates.py | 32 +++++ 4 files changed, 206 insertions(+) create mode 100644 agent_based/checkpoint_inv_updates.py create mode 100644 inv_checkpoint_updates.mkp create mode 100644 packages/inv_checkpoint_updates create mode 100644 web/plugins/views/checkpoint_updates.py diff --git a/agent_based/checkpoint_inv_updates.py b/agent_based/checkpoint_inv_updates.py new file mode 100644 index 0000000..868031a --- /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 GIT binary patch literal 2756 zcmbWk_ahX50svr?opDB4QJg)_I%j4jbfGAFW}b6poV{K;WSleZB(joZmyj8<#}Ojy z9L|wVNI35O_WpqPeIhALOzAwTu5?t`vk(_|A5V9<|8v+gq)V{Bha1u}NM2b{SxHe@ zQC%TKK~X_T0Ri`?*>P|Pns4M9{SrgJsr_&>!zZ&P*UG!kG*6<O6!w&il&DEGgr?(j zMD6J6Nt1)Ix~(+Qaa<eF%_jV{Z#~&ey9%K<QhMo%UituZPy0U6lyvDu(M{_j`ge6d zGiK|cYSXUls8NCnIJXAHZn-a5=;IO<Ey255T`mcQ2Z!ol$EOd*@X=ZIr{Obs@}RWn z7%p$^R8k5le8j@*pw1oX(34}O27QTQ3_v*=Gd|}q<#d{O)xQBwy0O};k?)k=t^P`V z7MiKJU&8O{0VwP7$pG_RmWrS*VJ2U#SjKE8e9YH@(6u{dBNVX;w{pZbpg(ZCfP7Sy z#L7aiy>FN~k$#p+m-tZUTk`jr!bm%Tcf0FvB}WL0qh@MjBvilG+XCiIBTh>OkEIfo zPorA&`aw;1)VzG$;us=an{A}>90etvo~V$L3s@3>BcpMz5H1Wy$q3nPnXMa9KC2+< ziiAMO2Fm$S;}Hu%$Zv_3gFb6ByklSc095*twM?d6{FuuU1RMIJU}S8c237)@4cAY# zt|`B2!(P6jFZYjMritf$4C9Iop%u<sf2W5+Xp&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J$*6W~wx;Ur z2Y!^ddI~yfwrxu`F*5hXZWFjg_v;1{B{LZ-fwNax2<hVl9IwXlF5ZfQ$*fYn)GYdB zu27MJzceI=9{l>i0h0PB#s0;!CxpuN+%@bEn(6c!H|U#Roiw{b4*cc0^fz0jvO+e< zS3J*a!rASY?oID|Dj5tkvZ0pY1ih*-0b=^cpCt`K;J+c?9`Rt0`))ohlIyVsd|F|- z4vc#`Z(AyOrO-M6!{2A4iU?h>ZjiL0=hdE6pIMY89v9y(fjoL0-Qo+j%0*qKHln4^ z;`s9G=(DdT6#u5MbvNeN3(F%bK``>Q`y^ey1C7Lqna)PF3tZI{%f(DXbru6))6cuf zw`sxqBd*tH)-JG?vPch;c71|fRMl9Lfr?ndef~$Aspj_vBy#U?i%6|cXpEs!ANePq z%!_=W8k_CK+K0qy4-u(C_SPbEJD(ADXBT6!%jbpFls0~s9qnN{6_WnI>IQNgYmAi^ zt%$hew2K_Ml8w4N*0?LM6;eS*7s<sNC9M59TblUEZ@68#Tkfx}ndjk`nV-mm=l|@< z!Zw$`0-fgvAj(tjw4^xa{*AXQE_balDOg1Nrb5O7*a1Ea8JM=8?87gj2{jG#xcsVy z$W1So$w%lH7a3GHH;s`Xj_`x;T9`L7>O|)A2^ir=J2}R7+$~6xwOG*q1p0O_!Xz>A s78tKA<;y$7+g$A;&WrTGr}P??sS&3f-~#_Isv1Q^Dm99SCX9yWzY6wKjQ{`u literal 0 HcmV?d00001 diff --git a/packages/inv_checkpoint_updates b/packages/inv_checkpoint_updates new file mode 100644 index 0000000..d5995ea --- /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 0000000..8e5eb6f --- /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'), +) -- GitLab