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

Delete inv_cisco_support.py

parent 65283276
No related branches found
No related tags found
No related merge requests found
#!/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 : 2017-08-14
#
# CheckMK views for Cisco support APIs (EoX, SN2Info, PSIRT, SUGGESTION)
#
# 2021-07-23: rewrite for CMK 2.0
# suggestion removed --> table to complicated :-(
#
# 2021-07-25: removed inv_cisco_suggestion
# rework painter section
import time
from cmk.gui.plugins.views.inventory import (
declare_invtable_view,
decorate_inv_paint,
)
from cmk.gui.plugins.visuals.inventory import (
FilterInvtableText,
)
from cmk.gui.i18n import _
from cmk.gui.plugins.views import (
inventory_displayhints,
)
from cmk.gui.htmllib import HTML
#
# ToDo: move painters to local tree
# painters are at the moment hard coded in lib/python/cmk/gui/plugins/views/inventory.py
#
# to enable painters you must add the painter functions to ~/lib/python/cmk/gui/plugins/views/inventory.py
# and set ENABLE_PAINTERS to True
#
ENABLE_PAINTERS = True
# #################################################################################
#
# Painter functions START
#
@decorate_inv_paint()
def inv_paint_date_status(date_string):
warn_days = -90
crit_days = -30
# check if date_sting not None, if so return no CSS Class and None
if date_string is None:
return '', ''
try:
days = int((time.time() - time.mktime(time.strptime(date_string, '%Y-%m-%d'))) / 86400)
except ValueError:
return '', date_string
if days > crit_days:
css_class = 'date_crit'
elif days > warn_days:
css_class = 'date_warn'
else:
css_class = 'date_default'
return css_class, '%s' % date_string
@decorate_inv_paint()
def inv_paint_last_checked_status(date_string):
warn_days = 32
crit_days = 40
if date_string is None:
return '', ''
try:
days = int((time.time() - time.mktime(time.strptime(date_string, '%Y-%m-%d'))) / 86400)
except ValueError:
return '', date_string
if days <= warn_days:
css_class = ''
elif days >= crit_days:
css_class = 'date_crit'
else:
css_class = 'date_warn'
return css_class, ' %s' % date_string
@decorate_inv_paint()
def inv_paint_psirt_advisoryid(advisoryId):
psirt_url = HTML(
f'<a class="href_blue" target="_blank" '
f'href="https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/{advisoryId}">{advisoryId}</a>')
return '', psirt_url
@decorate_inv_paint()
def inv_paint_eox_eolid(eolid):
if eolid is not None:
search_eolid_url = HTML(
f'<a class="href_blue" target="_blank" '
f'href="https://search.cisco.com/search?query={eolid}%s">{eolid}</a>')
else:
search_eolid_url = ''
return '', search_eolid_url
@decorate_inv_paint()
def inv_paint_bug_bugid(bugid):
if bugid is not None:
search_bugid_url = HTML(
f'<a class="href_blue" target="_blank" '
f'href="https://bst.cloudapps.cisco.com/bugsearch/bug/{bugid}">{bugid}</a>')
else:
search_bugid_url = ''
return '', search_bugid_url
@decorate_inv_paint()
def inv_paint_psirt_bugid(bugids):
search_bugid_url = ''
bugids = bugids.split(',')
if bugids:
search_bugid_url = []
for bugid in bugids:
bugid = bugid.strip(' ')
search_bugid_url.append(f'<a class="href_blue" target="_blank" '
f'href="https://bst.cloudapps.cisco.com/bugsearch/bug/{bugid}">{bugid}</a>')
search_bugid_url = HTML(', '.join(search_bugid_url))
return '', search_bugid_url
#
# Painter functions END
#
# #################################################################################
# EoX display hints
inventory_displayhints.update({
'.hardware.support.cisco_eox:': {
'title': _('Cisco EoX'),
'keyorder':
[
'pid', 'serial_number', 'ProductIDDescription', 'Last_checked', 'ProductBulletinNumber',
'EOXExternalAnnouncementDate', 'EndOfSaleDate', 'LastDateOfSupport', 'EndOfSvcAttachDate',
'UpdatedTimeStamp',
],
'view': 'invciscoeox_of_host',
},
'.hardware.support.cisco_eox:*.pid': {'title': _('PID (EoX)'), },
'.hardware.support.cisco_eox:*.serial_number': {'title': _('Serial number'), },
'.hardware.support.cisco_eox:*.ProductIDDescription': {'title': _('Description'), },
'.hardware.support.cisco_eox:*.LinkToProductBulletinURL': {'title': _('EOL bulletin URL'), },
'.hardware.support.cisco_eox:*.UpdatedTimeStamp': {'title': _('EOL bulletin last update'), },
'.hardware.support.cisco_eox:*.MigrationProductId': {'title': _('Migration PID'), },
'.hardware.support.cisco_eox:*.MigrationInformation': {'title': _('Migration information'), },
'.hardware.support.cisco_eox:*.MigrationProductInfoURL': {'title': _('Migration PID URL'), },
'.hardware.support.cisco_eox:*.MigrationProductName': {'title': _('Migration product name'), },
})
# SN2Info (contract) display hints
inventory_displayhints.update({
'.hardware.support.cisco_contract:': {
'title': _('Cisco contract status'),
'keyorder': [
'pid', 'serial_number', 'ProductIDDescription', 'Last_checked', 'is_covered', 'service_contract_number',
'covered_product_line_end_date',
],
'view': 'invciscocontract_of_host',
},
'.hardware.support.cisco_contract:*.pid': {'title': _('PID (contract)'), },
'.hardware.support.cisco_contract:*.serial_number': {'title': _('Serial number'), },
'.hardware.support.cisco_contract:*.ProductIDDescription': {'title': _('Description'), },
'.hardware.support.cisco_contract:*.is_covered': {'title': _('is covered'), },
'.hardware.support.cisco_contract:*.contract_site_customer_name': {'title': _('Customer name'), },
'.hardware.support.cisco_contract:*.contract_site_address1': {'title': _('Address'), },
'.hardware.support.cisco_contract:*.contract_site_city': {'title': _('City'), },
'.hardware.support.cisco_contract:*.contract_site_state_province': {'title': _('State/Province'), },
'.hardware.support.cisco_contract:*.contract_site_country': {'title': _('Country'), },
'.hardware.support.cisco_contract:*.service_line_descr': {'title': _('Service description'), },
'.hardware.support.cisco_contract:*.service_contract_number': {'title': _('Contract number'), },
'.hardware.support.cisco_contract:*.parent_sr_no': {'title': _('Parent S/N'), },
'.hardware.support.cisco_contract:*.warranty_type': {'title': _('Warranty type'), },
'.hardware.support.cisco_contract:*.warranty_type_description': {'title': _('Warranty Description'), },
'.hardware.support.cisco_contract:*.warranty_end_date': {'title': _('Warranty end date'), },
})
# BUG display hints
inventory_displayhints.update({
'.software.support.cisco_bug.Total_records': {'title': _('Records total'), },
'.software.support.cisco_bug.duplicate_records': {'title': _('Records duplicate'), },
'.software.support.cisco_bug.missing_records': {'title': _('Records missing'), },
'.software.support.cisco_bug.PID': {'title': _('PID'), },
'.software.support.cisco_bug.os_version': {'title': _('OS version'), },
'.software.support.cisco_bug.bugs:': {
'title': _('Cisco BUG IDs'),
'keyorder': [
'bug_id', 'severity', 'status', 'last_modified_date', 'headline', 'support_case_count', 'behavior_changed',
],
'view': 'invciscobugs_of_host',
},
'.software.support.cisco_bug.bugs:*.status': {'title': _('Status'), },
'.software.support.cisco_bug.bugs:*.product': {'title': _('Product'), },
'.software.support.cisco_bug.bugs:*.description': {'title': _('Description'), },
'.software.support.cisco_bug.bugs:*.headline': {'title': _('Headline'), },
'.software.support.cisco_bug.bugs:*.support_case_count': {'title': _('Support case count'), },
'.software.support.cisco_bug.bugs:*.last_modified_date': {'title': _('Last modified date'), },
'.software.support.cisco_bug.bugs:*.behavior_changed': {'title': _('Behavior changed'), },
'.software.support.cisco_bug.bugs:*.base_pid': {'title': _('Base PID'), },
'.software.support.cisco_bug.bugs:*.known_fixed_releases': {'title': _('Known fixed releases'), },
'.software.support.cisco_bug.bugs:*.id': {'title': _('ID'), },
'.software.support.cisco_bug.bugs:*.known_affected_releases': {'title': _('known affected releases'), },
'.software.support.cisco_bug.bugs:*.severity': {'title': _('Severity'), },
})
# PSIRT display hints
inventory_displayhints.update({
'.software.support.cisco_psirt.dont_show_older_than': {'title': _('Don\'t show advisories not updated since'), },
'.software.support.cisco_psirt.dont_show_not_updated_since': {
'title': _('Don\'t show advisories not updated for X days'), },
'.software.support.cisco_psirt.removed_advisories': {'title': _('Advisories removed'), },
'.software.support.cisco_psirt.advisories:': {
'title': _('Cisco PSIRT advisories'),
'keyorder': [
'advisoryId', 'sir', 'cvssBaseScore', 'advisoryTitle',
],
'view': 'invciscopsirt_of_host',
},
'.software.support.cisco_psirt.advisories:*.advisoryTitle': {'title': _('Advisory Title'), },
'.software.support.cisco_psirt.advisories:*.cvssBaseScore': {'title': _('CVSS base Score'), },
'.software.support.cisco_psirt.advisories:*.firstFixed': {'title': _('First fixed in'), },
'.software.support.cisco_psirt.advisories:*.firstPublished': {'title': _('First Published'), },
'.software.support.cisco_psirt.advisories:*.installed_version': {'title': _('OS version/family'), },
'.software.support.cisco_psirt.advisories:*.lastUpdated': {'title': _('Last Updated'), },
'.software.support.cisco_psirt.advisories:*.publicationUrl': {'title': _('Public URL'), },
'.software.support.cisco_psirt.advisories:*.sir': {'title': _('Severity'), },
'.software.support.cisco_psirt.advisories:*.summary': {'title': _('Summary'), },
'.software.support.cisco_psirt.advisories:*.cwe': {'title': _('CWE'), },
'.software.support.cisco_psirt.advisories:*.cves': {'title': _('CVEs'), },
'.software.support.cisco_psirt.advisories:*.productNames': {'title': _('Product names'), },
'.software.support.cisco_psirt.advisories:*.ipsSignatures': {'title': _('IPS signatures')},
'.software.support.cisco_psirt.advisories:*.cvrfUrl': {'title': _('CVRF URL')},
'.software.support.cisco_psirt.advisories:*.ovalUrl': {'title': _('OVAL URL')},
'.software.support.cisco_psirt.os_version': {'title': _('OS version')},
'.software.support.cisco_psirt.not_updated_for_x_days': {'title': _('don\'t show advisories not updated for X days')},
'.software.support.cisco_psirt.dont_show_older_then': {'title': _('don\'t show advisories not updated after')},
})
if ENABLE_PAINTERS:
inventory_displayhints.update({
# EoX
'.hardware.support.cisco_eox:*.EOXExternalAnnouncementDate': {'title': _('EOL Announcement'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.EndOfSvcAttachDate': {'title': _('End of service attachment'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.EndOfSecurityVulSupportDate': {'title': _('End of service vulnerability support'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.EndOfSWMaintenanceReleases': {'title': _('End of software maintenace releases'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.EndOfRoutineFailureAnalysisDate': {'title': _('End of routine failure analysis'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.EndOfSaleDate': {'title': _('End of sale'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.LastDateOfSupport': {'title': _('End of support'), 'paint': 'date_status'},
'.hardware.support.cisco_eox:*.ProductBulletinNumber': {'title': _('EOL bulletin ID'), 'filter': FilterInvtableText,'paint': 'eox_eolid'},
'.hardware.support.cisco_eox:*.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status'},
# SN2Info
'.hardware.support.cisco_contract:*.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status'},
'.hardware.support.cisco_contract:*.covered_product_line_end_date': {'title': _('Contract end date'), 'paint': 'date_status'},
# Bug
'.software.support.cisco_bug.bugs:*.bug_id': {'title': _('Bug ID'), 'paint': 'bug_bugid'},
# Psirt
'.software.support.cisco_psirt.advisories:*.advisoryId': {'title': _('Advisory ID'), 'paint': 'psirt_advisoryid'},
'.software.support.cisco_psirt.advisories:*.bugIDs': {'title': _('Bug IDs'), 'paint': 'psirt_bugid'},
'.software.support.cisco_psirt.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status'},
})
else:
inventory_displayhints.update(({
# EoX
'.hardware.support.cisco_eox:*.EOXExternalAnnouncementDate': {'title': _('EOL Announcement')},
'.hardware.support.cisco_eox:*.EndOfSvcAttachDate': {'title': _('End of service attachment')},
'.hardware.support.cisco_eox:*.EndOfSecurityVulSupportDate': {'title': _('End of service vulnerability support')},
'.hardware.support.cisco_eox:*.EndOfSWMaintenanceReleases': {'title': _('End of software maintenace releases')},
'.hardware.support.cisco_eox:*.EndOfRoutineFailureAnalysisDate': {'title': _('End of routine failure analysis')},
'.hardware.support.cisco_eox:*.EndOfSaleDate': {'title': _('End of sale')},
'.hardware.support.cisco_eox:*.LastDateOfSupport': {'title': _('End of support')},
'.hardware.support.cisco_eox:*.ProductBulletinNumber': {'title': _('EOL bulletin ID')},
'.hardware.support.cisco_eox:*.Last_checked': {'title': _('Last checked'),},
# SN2Info
'.hardware.support.cisco_contract:*.Last_checked': {'title': _('Last checked')},
'.hardware.support.cisco_contract:*.covered_product_line_end_date': {'title': _('Contract end date')},
# Bug
'.software.support.cisco_bug.bugs:*.bug_id': {'title': _('Bug ID')},
# Psirt
'.software.support.cisco_psirt.advisories:*.advisoryId': {'title': _('Advisory ID')},
'.software.support.cisco_psirt.advisories:*.bugIDs': {'title': _('Bug IDs')},
'.software.support.cisco_psirt.Last_checked': {'title': _('Last checked')},
}))
declare_invtable_view('invciscoeox', '.hardware.support.cisco_eox:', _('Cisco EoX status'), _('Cisco EoX status'))
declare_invtable_view('invciscocontract', '.hardware.support.cisco_contract:', _('Cisco contract status'), _('Cisco contract status'))
declare_invtable_view('invciscopsirt', '.software.support.cisco_psirt.advisories:', _('Cisco PSIRT advisories'), _('Cisco PSIRT advisories'))
declare_invtable_view('invciscobugs', '.software.support.cisco_bug.bugs:', _('Cisco BUG IDs'), _('Cisco Bug IDs'))
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