diff --git a/active_check_traceroute-0.0.2-20230607.mkp b/active_check_traceroute-0.0.2-20230607.mkp new file mode 100644 index 0000000000000000000000000000000000000000..a9094ace724afdaeb5df5af74dc3567a090e3b55 Binary files /dev/null and b/active_check_traceroute-0.0.2-20230607.mkp differ diff --git a/active_check_traceroute.mkp b/active_check_traceroute.mkp index 92b0a170ac12c41c5166e4f06c0572cbbde79b36..a9094ace724afdaeb5df5af74dc3567a090e3b55 100644 Binary files a/active_check_traceroute.mkp and b/active_check_traceroute.mkp differ diff --git a/gui/metrics/traceroute.py b/gui/metrics/traceroute.py new file mode 100644 index 0000000000000000000000000000000000000000..4178f650fee16fb5ad6429e8c0340a367e8e521e --- /dev/null +++ b/gui/metrics/traceroute.py @@ -0,0 +1,29 @@ +#!/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 : 2021-12-04 +# + +from cmk.gui.i18n import _ + +from cmk.gui.plugins.metrics.utils import ( + metric_info, + perfometer_info + +) + +metric_info['hops'] = { + 'title': _('Number of hops'), + 'unit': 'count', + 'color': '41/a', +} + +perfometer_info.append({ + 'type': 'linear', + 'segments': ['hops'], + 'total': 30, +}) diff --git a/gui/wato/active_checks_routing.py b/gui/wato/active_checks_routing.py new file mode 100644 index 0000000000000000000000000000000000000000..5e7c237de7f749242d38f4fb4f7c6640065944c2 --- /dev/null +++ b/gui/wato/active_checks_routing.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# original form lib/check_mk/gui/plugins/wato/active_checks.py +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2021-12-03 +# +# added: description, method UDP, port, destination_address, queries, max_ttl, source_interface, source_address +# + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + ListOf, + Tuple, + Transform, + Checkbox, + DropdownChoice, + TextInput, + Integer, + TextAscii, +) + +from cmk.gui.plugins.wato.utils import ( + rulespec_registry, + HostRulespec, +) + +from cmk.gui.plugins.wato.active_checks import ( + RulespecGroupActiveChecks +) + + +def _ip_address_family_element(): + return ( + 'address_family', + DropdownChoice( + title=_('IP address family'), + choices=[ + (None, _('Primary address family')), + ('ipv4', _('Enforce IPv4')), + ('ipv6', _('Enforce IPv6')), + ], + default_value=None, + ), + ) + + +def _transform_add_address_family(v): + v.setdefault('address_family', None) + return v + + +def _valuespec_active_checks_traceroute(): + return Transform( + Dictionary( + title=_('Check current routing'), + help=_( + 'This active check uses <tt>traceroute</tt> in order to determine the current ' + 'routing from the monitoring host to the target host. You can specify any number ' + 'of missing or expected routes in order to detect e.g. an (unintended) failover ' + 'to a secondary route.' + ), + elements=[ + ('description', + TextAscii( + title=_('Service Description suffix'), + help=_('Must be unique for every host. The service description starts always with \"Routing\".'), + size=30, + )), + ('dns', + Checkbox( + title=_('Name resolution'), + label=_('Use DNS to convert IP addresses into hostnames'), + help=_( + 'If you use this option, then <tt>traceroute</tt> is <b>not</b> being ' + 'called with the option <tt>-n</tt>. That means that all IP addresses ' + 'are tried to be converted into names. This usually adds additional ' + 'execution time. Also DNS resolution might fail for some addresses.' + ), + ),), + _ip_address_family_element(), + ('routers', + ListOf( + Tuple( + elements=[ + TextInput( + title=_('Router (FQDN, IP-Address)'), + allow_empty=False, + ), + DropdownChoice( + title=_('How'), + choices=[ + ('W', _('WARN - if this router is not being used')), + ('C', _('CRIT - if this router is not being used')), + ('w', _('WARN - if this router is being used')), + ('c', _('CRIT - if this router is being used')), + ], + ), + ] + ), + title=_('Router that must or must not be used'), + add_label=_('Add Condition'), + ),), + ('method', + DropdownChoice( + title=_('Method of probing'), + choices=[ + (None, _('UDP lite (default behaviour of traceroute)')), + ('udp', _('UDP (without increasing the port for each probe)')), + ('icmp', _('ICMP Echo Request')), + ('tcp', _('TCP SYN, needs root permissions')), + ], + default_value='icmp', + ),), + ('port', + Integer( + title=_('Port'), + help=_('Set the destination port to use. It is either initial udp port value for \"default\" ' + 'method (incremented by each probe, default is 33434), or initial seq for \"icmp\" ' + '(incremented as well, default from 1), or some constant destination port for other ' + 'methods (with default of 80 for \"tcp\", 53 for \"udp\", etc.)'), + maxvalue=65535, + default_value=53, + ),), + ('destination_address', + TextAscii( + title=_('Alternate Destination'), + help=_('Path trace to alternate destination instead of \"HOSTADDRESS\".'), + ),), + ('queries', + Integer( + title=_('Number of queries'), + help=_('Set the number of probes per each hop. Default is 3.'), + default_value=3, + minvalue=1, + maxvalue=10, + ),), + ('max_ttl', + Integer( + title=_('Max hops'), + help=_('Set the max number of hops (max TTL to be reached). Default is 30'), + default_value=30, + minvalue=1, + maxvalue=255, + ),), + ('source_interface', + TextAscii( + title=_('Source interface'), + help=_('Specify a network interface to operate with. Needs root permissions.'), + ),), + ('source_address', + TextAscii( + title=_('Source address'), + help=_('Use source source address for outgoing packets'), + ),), + ], + optional_keys=['description', 'max_ttl', 'queries', 'destination_address', 'source_address', + 'source_interface', 'port'], + ), + forth=_transform_add_address_family, + ) + + +rulespec_registry.register( + HostRulespec( + group=RulespecGroupActiveChecks, + match_type='all', + name='active_checks:traceroute', + valuespec=_valuespec_active_checks_traceroute, + ) +) diff --git a/lib/nagios/plugins/check_traceroute b/lib/nagios/plugins/check_traceroute index a483066de256ee4ac5446f70778d87daea82345c..df5a3273a133e710f050e9b2d41830bf98f424e4 100755 --- a/lib/nagios/plugins/check_traceroute +++ b/lib/nagios/plugins/check_traceroute @@ -18,6 +18,8 @@ # Source address and source interface uses the 'shell=True' option in in # the 'subprocess.Popen' command. This is highly insecure, so be careful. +# 2023-06-07: moved gui files to ~/local/lib/chek_mk/gui/plugins/... + # This check does a traceroute to the specified target host # (usually $HOSTADDRESS$ itself) and checks which route(s) are # being taken. That way you can check if your preferred or diff --git a/packages/active_check_traceroute b/packages/active_check_traceroute index 963bc243b44a64953edf61c845ffc15dedaac4fc..b8638db2179e0c5d83a89e104779927450bac947 100644 --- a/packages/active_check_traceroute +++ b/packages/active_check_traceroute @@ -28,13 +28,11 @@ 'on Ubuntu 20.04.3 LTS.\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'checks': ['check_traceroute'], - 'lib': ['nagios/plugins/check_traceroute'], - 'web': ['plugins/wato/active_checks_routing.py', - 'plugins/metrics/traceroute.py']}, + 'gui': ['metrics/traceroute.py', 'wato/active_checks_routing.py'], + 'lib': ['nagios/plugins/check_traceroute']}, 'name': 'active_check_traceroute', - 'num_files': 4, 'title': 'Check Traceroute (extended)', - 'version': '20212107.v.0.0.1b', - 'version.min_required': '2.0.0', - 'version.packaged': '2021.09.20', + 'version': '0.0.2-20230607', + 'version.min_required': '2.1.0b1', + 'version.packaged': '2.1.0p21', 'version.usable_until': None} \ No newline at end of file