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 ad1c1b70 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent d6b973e1
No related branches found
No related tags found
No related merge requests found
......@@ -13,3 +13,4 @@
2021-03-18: fixed missing update agent snmp section.
2021-07-24: fixed parse function for empty string_table
2021-08-10: added display hints
2023-04-23: refactoring, moved views file to ~/local/lib/check_mk/gui/plugins/views
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author: thl-cmk[at]outlook[dot]com / thl-cmk.hopto.org
# License: GNU General Public License v2
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2016-06-29
#
# Check Point base inventory
#
......@@ -11,25 +15,15 @@
# 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-08: transferred license/support info to separate plugin
# 2021-02-22: code cleanup
# 2021-03-05: added hostlabel section
# 2021-03-18: fixed missing update agent snmp section.
# 2021-07-24: fixed parse function for empty string_table
#
# sample string_table
# [
# [
# ['5M7C043', 'Smart-1 5150', 'CheckPoint', 'Smart-1', 'R80.40', '994000022', 'Gaia', '3', '10']
# ],
# [
# ['1959']
# ],
# ]
# 2023-04-23: refactoring
#
from typing import List, NamedTuple, Optional
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
HostLabelGenerator,
StringTable,
......@@ -47,51 +41,69 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
)
class CheckpointInvBaseInfo(NamedTuple):
serial_number: str
product_name: str
manufacturer: str
series: str
version: str
build: str
osname: str
os_major_ver: str
os_minor_ver: str
def parse_inv_checkpoint_base(string_table: List[StringTable]) -> Optional[List]:
class CheckpointInvBaseInfo(NamedTuple):
serialnumber: str
productname: str
manufacturer: str
series: str
version: str
build: str
osname: str
osmajorver: str
osminorver: str
if string_table == [[], []]:
"""
>>> from pprint import pp
>>> string_table = [[['5M7C043','Smart-1 5150','CheckPoint','Smart-1','R80.40','994000022','Gaia','3','10']]]
>>> string_table.append([['1959']])
>>> print(string_table)
[[['5M7C043', 'Smart-1 5150', 'CheckPoint', 'Smart-1', 'R80.40', '994000022', 'Gaia', '3', '10']], [['1959']]]
>>> pp(parse_inv_checkpoint_base(string_table))
[(['hardware', 'system'], 'serial', '5M7C043'),
(['hardware', 'system'], 'appliance_series', 'Smart-1'),
(['hardware', 'system'], 'manufacturer', 'CheckPoint'),
(['hardware', 'system'], 'product_name', 'Smart-1 5150'),
(['software', 'check_point', 'os_info'], 'svn_version', 'R80.40'),
(['software', 'check_point', 'os_info'], 'svn_build', '994000022'),
(['software', 'check_point', 'os_info'], 'os_name', 'Gaia'),
(['software', 'check_point', 'os_info'], 'deployment_agent_build', '1959'),
(['software', 'check_point', 'os_info'], 'os_version', '3.10')]
"""
try:
base_info = CheckpointInvBaseInfo(*string_table[0][0])
except IndexError:
return
section = []
baseinfo = CheckpointInvBaseInfo(*string_table[0][0])
try:
updateagentversion = string_table[1][0][0]
update_agent_version = string_table[1][0][0]
except IndexError:
updateagentversion = ''
update_agent_version = ''
invPath = ['hardware', 'system']
section = []
path = ['hardware', 'system']
for key, value in [
('serial', baseinfo.serialnumber),
('appliance_series', baseinfo.series),
('manufacturer', baseinfo.manufacturer),
('product_name', baseinfo.productname),
('serial', base_info.serial_number),
('appliance_series', base_info.series),
('manufacturer', base_info.manufacturer),
('product_name', base_info.product_name),
]:
if not value == '':
section.append((invPath, key, value))
section.append((path, key, value))
invPath = ['software', 'check_point', 'os_info']
path = ['software', 'check_point', 'os_info']
for key, value in [
('svn_version', baseinfo.version),
('svn_build', baseinfo.build),
('os_name', baseinfo.osname),
('deployment_agent_build', updateagentversion),
('os_version', baseinfo.osmajorver + '.' + baseinfo.osminorver),
('svn_version', base_info.version),
('svn_build', base_info.build),
('os_name', base_info.osname),
('deployment_agent_build', update_agent_version),
('os_version', base_info.os_major_ver + '.' + base_info.os_minor_ver),
]:
if not value == '':
section.append((invPath, key, value))
section.append((path, key, value))
return section
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# License: GNU General Public License v2
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2016-06-29
# 2023-04-23: moved views file to ~/local/lib/check_mk/gui/plugins/views
from cmk.gui.i18n import _
from cmk.gui.plugins.views.utils import (
inventory_displayhints,
)
inventory_displayhints.update({
'.software.check_point.os_info:': {
'title': _('OS Info'),
},
'.software.check_point.os_info.deployment_agent_build': {'title': _('Deployment Agent Build'), },
'.software.check_point.os_info.os_name': {'title': _('OS Name'), },
'.software.check_point.os_info.os_version': {'title': _('OS Version'), },
'.software.check_point.os_info.svn_build': {'title': _('SVN Build'), },
'.software.check_point.os_info.svn_version': {'title': _('SVN Version'), },
})
No preview for this file type
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'SNMP inventory of Check Point Appliances for:\n'
'Serial Number, Product Name, Manufacturer, OS/SVN/Deployment '
'Serial number, Product name, Manufacturer, OS/SVN/Deployment '
'agent version\n'
'\n'
'- 2021-02-08: initial release\n'
'- 2021-02-22: code cleanup\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_checkpoint_base.py'],
'web': ['plugins/views/inv_checkpoint_base.py']},
'gui': ['views/inv_checkpoint_base.py']},
'name': 'inv_checkpoint_base',
'num_files': 2,
'title': 'Check Point appliance base inventory plugin',
'version': '20210724.v.0.1a',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version': '0.2.1-20230423',
'version.min_required': '2.1.0b1',
'version.packaged': '2.1.0p21',
'version.usable_until': None}
\ No newline at end of file
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