diff --git a/agent_based/checkpoint_asg_sg_counters.py b/agent_based/checkpoint_asg_sg_counters.py new file mode 100644 index 0000000000000000000000000000000000000000..ff9b56dda00287e22fddf34f4023d370dc37995d --- /dev/null +++ b/agent_based/checkpoint_asg_sg_counters.py @@ -0,0 +1,227 @@ +#!/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 : 2020-11-09 +# +# Monitor Check Point Maestro SG Counters +# +# 2021-09-10: rewritten for CMK 2.0 +# 2021-09-11: added metrics file +# 2021-09-29: renamed from checkpoint_asg_smo_counters to checkpoint_asg_sg_counters +# +# sample snmpwalk +# .1.3.6.1.4.1.2620.1.48.20.1.0 = STRING: "111802" +# .1.3.6.1.4.1.2620.1.48.20.2.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.3.0 = STRING: "84" +# .1.3.6.1.4.1.2620.1.48.20.4.0 = STRING: "91" +# .1.3.6.1.4.1.2620.1.48.20.5.0 = STRING: "N/A" +# .1.3.6.1.4.1.2620.1.48.20.6.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.7.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.8.0 = STRING: "9" +# .1.3.6.1.4.1.2620.1.48.20.9.0 = STRING: "79" +# .1.3.6.1.4.1.2620.1.48.20.10.0 = STRING: "1" +# .1.3.6.1.4.1.2620.1.48.20.11.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.12.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.13.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.14.0 = STRING: "1" +# .1.3.6.1.4.1.2620.1.48.20.15.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.16.0 = STRING: "7" +# .1.3.6.1.4.1.2620.1.48.20.17.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.18.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.19.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.20.0 = STRING: "0" +# .1.3.6.1.4.1.2620.1.48.20.21.0 = STRING: "N/A" +# +# sample string_table +# [ +# [ +# '111802', '0', '84', '91', 'N/A', '0', '0', '9', '79', '1', '0', '0', '0', '1', '0', '7', '0', '0', '0', '0', 'N/A' +# ] +# ] +# + +from dataclasses import dataclass +from typing import Dict + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + Result, + Metric, + State, + SNMPTree, + all_of, + startswith, + any_of, + equals, +) +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + + +@dataclass +class CheckpointAsgSgCounters: + counters: Dict[str, int] + label: str + unit: str + text: str + + +def parse_checkpoint_asg_sg_counters(string_table: StringTable) -> Dict[str, CheckpointAsgSgCounters]: + items = {} + for entry in string_table: + asgThroughput, asgConnectionRate, asgPacketRate, asgConcurrConn, asgClearConn, asgAccelConnectionRate, \ + asgNonAccelConnectionRate, asgAccelConcurrConn, asgNonAccelConcurrConn, asgLoad, asgAccelLoadAvg, \ + asgAccelLoadMin, asgAccelLoadMax, asgInstancesLoadAvg, asgInstancesLoadMin, asgInstancesLoadMax, \ + asgVpnThroughput, asgVpnConn, asgNatConnRate, asgNatConn, asgVsxCpu1MinAvg = entry + + items['Concurrent connections'] = CheckpointAsgSgCounters( + counters={ + 'concurr_conn': int(asgConcurrConn), + 'accel_concurr_conn': int(asgAccelConcurrConn), + 'non_accel_concurr_conn': int(asgNonAccelConcurrConn), + }, + label='all/accelerated/non accelerated', + unit=' connections', + text=f'{int(asgConcurrConn):d}/{int(asgAccelConcurrConn):d}/{int(asgNonAccelConcurrConn):d}', + ) + items['Connection rate'] = CheckpointAsgSgCounters( + counters={ + 'connection_rate': int(asgConnectionRate), + 'accel_connection_rate': int(asgAccelConnectionRate), + 'non_accel_connection_rate': int(asgNonAccelConnectionRate), + }, + label='current/average/min/max', + unit=' connections/s', + text=f'{int(asgLoad):d}/{int(asgAccelLoadAvg):d}/{int(asgAccelLoadMin):d}/{int(asgAccelLoadMax):d}', + ) + items['Load'] = CheckpointAsgSgCounters( + counters={ + 'load': int(asgLoad), + 'accel_load_avg': int(asgAccelLoadAvg), + 'accel_load_min': int(asgAccelLoadMin), + 'accel_load_max': int(asgAccelLoadMax), + }, + label='current/average/min/max', + unit='%', + text=f'{int(asgLoad):d}/{int(asgAccelLoadAvg):d}/{int(asgAccelLoadMin):d}/{int(asgAccelLoadMax):d}', + ) + items['Instances load'] = CheckpointAsgSgCounters( + counters={ + 'instances_load_avg': int(asgInstancesLoadAvg), + 'instances_load_min': int(asgInstancesLoadMin), + 'instances_load_max': int(asgInstancesLoadMax), + }, + label='average/min/max', + unit='%', + text=f'{int(asgInstancesLoadAvg):d}/{int(asgInstancesLoadMin):d}/{int(asgInstancesLoadMax):d}', + ) + items['NAT'] = CheckpointAsgSgCounters( + counters={ + 'nat_conn_rate': int(asgNatConnRate), + 'nat_conn': int(asgNatConn), + }, + label='NAT Connections/NAT connection rate', + unit=' connections', + text=f'{int(asgNatConn):d}/{int(asgNatConn):d}', + ) + items['VPN'] = CheckpointAsgSgCounters( + counters={ + 'vpn_throughput': int(asgVpnThroughput), + 'vpn_conn': int(asgVpnConn), + }, + label='VPN Connections/VPN Throughput', + unit='', + text=f'{int(asgVpnConn):d}/{int(asgVpnThroughput):d}', + ) + items['Throughput'] = CheckpointAsgSgCounters( + counters={ + 'throughput': int(asgThroughput), + }, + label='Throughput', + unit=' Bytes/s', + text=f'{int(asgThroughput):d}' + ) + items['Packet rate'] = CheckpointAsgSgCounters( + counters={ + 'packet_rate': int(asgPacketRate), + }, + label='Packet Rate', + unit=' Packets/s', + text=f'{int(asgPacketRate):d}', + ) + if items: + return items + + +def discovery_checkpoint_asg_sg_counters(section:Dict[str, CheckpointAsgSgCounters]) -> DiscoveryResult: + for item in section.keys(): + yield Service(item=item) + + +def check_checkpoint_asg_sg_counters(item, params, section: Dict[str, CheckpointAsgSgCounters]) -> CheckResult: + try: + entry = section[item] + except KeyError: + yield Result(state=State.UNKNOWN, notice='Item not found in SNMP data') + return + + for key in entry.counters.keys(): + yield Metric(value=entry.counters[key], name=f'checkpoint_asg_sg_counters_{key}') + + yield Result(state=State.OK, summary=f'{entry.label}: {entry.text}{entry.unit}') + + +register.snmp_section( + name='checkpoint_asg_sg_counters', + parse_function=parse_checkpoint_asg_sg_counters, + fetch=SNMPTree( + base='.1.3.6.1.4.1.2620.1.48.20', # CHECKPOINT-MIB::asgIPv4PerformanceCounters + oids=[ + '1', # asgThroughput + '2', # asgConnectionRate + '3', # asgPacketRate + '4', # asgConcurrConn + '5', # asgClearConn + '6', # asgAccelConnectionRate + '7', # asgNonAccelConnectionRate + '8', # asgAccelConcurrConn + '9', # asgNonAccelConcurrConn + '10', # asgLoad + '11', # asgAccelLoadAvg + '12', # asgAccelLoadMin + '13', # asgAccelLoadMax + '14', # asgInstancesLoadAvg + '15', # asgInstancesLoadMin + '16', # asgInstancesLoadMax + '17', # asgVpnThroughput + '18', # asgVpnConn + '19', # asgNatConnRate + '20', # asgNatConn + '21', # asgVsxCpu1MinAvg + ] + ), + 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'), + ) + ) +) + +register.check_plugin( + name='checkpoint_asg_sg_counters', + service_name='ASG SG counters %s', + discovery_function=discovery_checkpoint_asg_sg_counters, + check_function=check_checkpoint_asg_sg_counters, + check_ruleset_name='checkpoint_asg_sg_counters', + check_default_parameters={}, +) diff --git a/checkpoint_asg_sg_counters.mkp b/checkpoint_asg_sg_counters.mkp new file mode 100644 index 0000000000000000000000000000000000000000..8c65b71bd4a798f18bf21d1d5bb4e364287c83c0 Binary files /dev/null and b/checkpoint_asg_sg_counters.mkp differ diff --git a/packages/checkpoint_asg_sg_counters b/packages/checkpoint_asg_sg_counters new file mode 100644 index 0000000000000000000000000000000000000000..9bec67b7d4da6cde353dabbe62df7b53b357e3c6 --- /dev/null +++ b/packages/checkpoint_asg_sg_counters @@ -0,0 +1,12 @@ +{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', + 'description': 'Monitor Check Point Maestro SG performance counters\n', + 'download_url': 'http://thl-cmk.hopto.org/', + 'files': {'agent_based': ['checkpoint_asg_sg_counters.py'], + 'web': ['plugins/metrics/checkpoint_asg_sg_counters.py']}, + 'name': 'checkpoint_asg_sg_counters', + 'num_files': 2, + 'title': 'Check Point Maestro SG performance counters', + 'version': '20210929.v0.3', + 'version.min_required': '2.0.0', + 'version.packaged': '2021.09.20', + 'version.usable_until': None} \ No newline at end of file diff --git a/web/plugins/metrics/checkpoint_asg_sg_counters.py b/web/plugins/metrics/checkpoint_asg_sg_counters.py new file mode 100644 index 0000000000000000000000000000000000000000..84014cee137c5a8faf8c15429f56f7d900ea86f3 --- /dev/null +++ b/web/plugins/metrics/checkpoint_asg_sg_counters.py @@ -0,0 +1,288 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# + +from cmk.gui.i18n import _ + +from cmk.gui.plugins.metrics import ( + metric_info, + graph_info, + perfometer_info, +) + +metric_info['checkpoint_asg_sg_counters_concurr_conn'] = { + 'title': _('Connections'), + 'unit': 'count', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_accel_concurr_conn'] = { + 'title': _('Connections Accelerated'), + 'unit': 'count', + 'color': '32/a', +} +metric_info['checkpoint_asg_sg_counters_non_accel_concurr_conn'] = { + 'title': _('Connections non Accelerated'), + 'unit': 'count', + 'color': '16/a', +} + +metric_info['checkpoint_asg_sg_counters_connection_rate'] = { + 'title': _('Connection Rate'), + 'unit': '1/s', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_accel_connection_rate'] = { + 'title': _('Connection Rate Accelerated'), + 'unit': '1/s', + 'color': '32/a', +} +metric_info['checkpoint_asg_sg_counters_non_accel_connection_rate'] = { + 'title': _('Connection Rate non Accelerated'), + 'unit': '1/s', + 'color': '16/a', +} + +metric_info['checkpoint_asg_sg_counters_load'] = { + 'title': _('Load'), + 'unit': '%', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_accel_load_max'] = { + 'title': _('Accel load (max)'), + 'unit': '%', + 'color': '31/a', +} +metric_info['checkpoint_asg_sg_counters_accel_load_avg'] = { + 'title': _('Accel load (avg)'), + 'unit': '%', + 'color': '16/a', +} +metric_info['checkpoint_asg_sg_counters_accel_load_min'] = { + 'title': _('Accel load (min)'), + 'unit': '%', + 'color': '11/a', +} + +metric_info['checkpoint_asg_sg_counters_instances_load_avg'] = { + 'title': _('Instances load (avg)'), + 'unit': '%', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_instances_load_min'] = { + 'title': _('Instances load (min)'), + 'unit': '%', + 'color': '32/a', +} +metric_info['checkpoint_asg_sg_counters_instances_load_max'] = { + 'title': _('Instances load (max)'), + 'unit': '%', + 'color': '16/a', +} + +metric_info['checkpoint_asg_sg_counters_nat_conn'] = { + 'title': _('NAT connections'), + 'unit': 'count', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_nat_conn_rate'] = { + 'title': _('NAT Conn Rate'), + 'unit': '1/s', + 'color': '32/a', +} + +metric_info['checkpoint_asg_sg_counters_vpn_conn'] = { + 'title': _('VPN connections'), + 'unit': 'count', + 'color': '26/a', +} +metric_info['checkpoint_asg_sg_counters_vpn_throughput'] = { + 'title': _('VPN Throughput'), + 'unit': 'bytes/s', + 'color': '32/a', +} + +metric_info['checkpoint_asg_sg_counters_throughput'] = { + 'title': _('Throughput'), + 'unit': 'bytes/s', + 'color': '26/a', +} + +metric_info['checkpoint_asg_sg_counters_packet_rate'] = { + 'title': _('Packet Rate'), + 'unit': '1/s', + 'color': '26/a', +} + +graph_info['checkpoint_asg_sg_counters_connections'] = { + 'title': _('Check Point SG Concurrent Connections'), + 'metrics': [ + ('checkpoint_asg_sg_counters_non_accel_concurr_conn', 'line'), + ('checkpoint_asg_sg_counters_accel_concurr_conn', 'line'), + ('checkpoint_asg_sg_counters_concurr_conn', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_concurr_conn:max'), +} + +graph_info['checkpoint_asg_sg_counters_connection_rate'] = { + 'title': _('Check Point SG Counter Connection Rate'), + 'metrics': [ + ('checkpoint_asg_sg_counters_non_accel_connection_rate', 'line'), + ('checkpoint_asg_sg_counters_accel_connection_rate', 'line'), + ('checkpoint_asg_sg_counters_connection_rate', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_connection_rate:max'), +} + +graph_info['checkpoint_asg_sg_counters_accel_load'] = { + 'title': _('Check Point SG Counter Load'), + 'metrics': [ + ('checkpoint_asg_sg_counters_accel_load_min', 'line'), + ('checkpoint_asg_sg_counters_accel_load_avg', 'line'), + ('checkpoint_asg_sg_counters_accel_load_max', 'line'), + ('checkpoint_asg_sg_counters_load', 'area'), + ], + 'range': (0, 110), +} + +graph_info['checkpoint_asg_sg_counters_instances_load'] = { + 'title': _('Check Point SG Counter Instances Load'), + 'metrics': [ + ('checkpoint_asg_sg_counters_instances_load_min', 'line'), + ('checkpoint_asg_sg_counters_instances_load_avg', 'area'), + ('checkpoint_asg_sg_counters_instances_load_max', 'line'), + ], + 'range': (0, 110), +} + +graph_info['checkpoint_asg_sg_counters_nat_conn'] = { + 'title': _('Check Point SG Counter NAT connections'), + 'metrics': [ + ('checkpoint_asg_sg_counters_nat_conn', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_nat_conn:max'), +} +graph_info['checkpoint_asg_sg_counters_nat_conn_rate'] = { + 'title': _('Check Point SG Counter NAT connection rate'), + 'metrics': [ + ('checkpoint_asg_sg_counters_nat_conn_rate', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_nat_conn_rate:max'), +} + +graph_info['checkpoint_asg_sg_counters_vpn_conn'] = { + 'title': _('Check Point SG Counter VPN connections'), + 'metrics': [ + ('checkpoint_asg_sg_counters_vpn_conn', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_vpn_conn:max'), +} +graph_info['checkpoint_asg_sg_counters_vpn_throughput'] = { + 'title': _('Check Point SGM Counter VPN Throughput'), + 'metrics': [ + ('checkpoint_asg_sg_counters_vpn_throughput', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_vpn_throughput:max'), +} + +graph_info['checkpoint_asg_sg_counters_throughput'] = { + 'title': _('Check Point SG Counter Throughput'), + 'metrics': [ + ('checkpoint_asg_sg_counters_throughput', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_throughput:max'), +} + +graph_info['checkpoint_asg_sg_counters_packet_rate'] = { + 'title': _('Check Point SG Counter Packet Rate'), + 'metrics': [ + ('checkpoint_asg_sg_counters_packet_rate', 'area'), + ], + 'range': (0, 'checkpoint_asg_sg_counters_packet_rate:max'), +} + + +perfometer_info.append(('stacked', [ + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_accel_concurr_conn', + 'half_value': 100000.0, + 'exponent': 2, + }, + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_non_accel_concurr_conn', + 'half_value': 100000.0, + 'exponent': 2, + }, +])) + +perfometer_info.append(('stacked', [ + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_accel_connection_rate', + 'half_value': 10000.0, + 'exponent': 2, + }, + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_non_accel_connection_rate', + 'half_value': 10000.0, + 'exponent': 2, + }, +])) + +perfometer_info.append({ + 'type': 'linear', + 'segments': ['checkpoint_asg_sg_counters_accel_load_avg'], + 'total': 100, +}) + +perfometer_info.append({ + 'type': 'linear', + 'segments': ['checkpoint_asg_sg_counters_instances_load_avg'], + 'total': 100, +}) + +perfometer_info.append(('stacked', [ + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_nat_conn', + 'half_value': 10000.0, + 'exponent': 2, + }, + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_nat_conn_rate', + 'half_value': 500.0, + 'exponent': 2, + }, +])) + +perfometer_info.append(('stacked', [ + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_vpn_conn', + 'half_value': 500.0, + 'exponent': 2, + }, + { + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_vpn_throughput', + 'half_value': 2592000.0, + 'exponent': 2, + }, +])) + +perfometer_info.append({ + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_throughput', + 'half_value': 500.0, + 'exponent': 2, +}) + +perfometer_info.append({ + 'type': 'logarithmic', + 'metric': 'checkpoint_asg_sg_counters_packet_rate', + 'half_value': 100000.0, + 'exponent': 2, +})