From 3f2e4fbff2c568da7d4d0508138891508dd4a24e Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Fri, 20 Jan 2023 11:57:57 +0100 Subject: [PATCH] Rename "location"-flag to "namespace", update docs --- contrib/scripts/isc_dhpcd_graphite/README.rst | 8 ++++--- .../isc_dhpcd_graphite/isc_dhpcd_graphite.py | 23 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/contrib/scripts/isc_dhpcd_graphite/README.rst b/contrib/scripts/isc_dhpcd_graphite/README.rst index 9eeaefd0bd..aab733d46f 100644 --- a/contrib/scripts/isc_dhpcd_graphite/README.rst +++ b/contrib/scripts/isc_dhpcd_graphite/README.rst @@ -15,12 +15,14 @@ Building the prefix =================== The dotted-path that graphite uses to store data is controlled by the prefix -argument to the script (-p), the optional location argument (-l) and what -``dhcpd_pool`` returns as its ``location`` key. +argument to the script (-p), the optional namespace argument (-N) and what +``dhcpd_pool`` returns as its ``location`` per entry of the ``shared_networks`` +list. (What ``dhcpd_pool`` calls "location" is elsewhere known as "DHCP network +name".) The default prefix is "nav.dhcp". -If ``-p`` is "nav.bloviate", ``-l`` is not set and the ``location`` in the json +If ``-p`` is "nav.bloviate", ``-N`` is not set and the ``location`` in the json is "vlan1" the resulting graphite path is ``nav.bloviate.vlan1``. diff --git a/contrib/scripts/isc_dhpcd_graphite/isc_dhpcd_graphite.py b/contrib/scripts/isc_dhpcd_graphite/isc_dhpcd_graphite.py index 9e807598be..3309143b0b 100644 --- a/contrib/scripts/isc_dhpcd_graphite/isc_dhpcd_graphite.py +++ b/contrib/scripts/isc_dhpcd_graphite/isc_dhpcd_graphite.py @@ -56,7 +56,16 @@ def escape_metric_name(name): # parse comand line flags def parse_args(): - parser = argparse.ArgumentParser(description="Send dhcp stats to graphite") + description = '''\ + Send dhcp stats to graphite + + The metric-name is taken from the location-field in the shared_networks + part of the output. + ''' + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=description, + ) parser.add_argument( "server", help="Graphite server to send data to", @@ -89,12 +98,12 @@ def parse_args(): default=DEFAULT_PREFIX, ) parser.add_argument( - "-l", - "--location", + "-N", + "--namespace", help=( - "Location, if any, to append to the metric prefix to build the path." - ' If the location is named "vlan1" and the location is "building1.cellar"' - " the resulting metric path would be PREFIX.building1.cellar.vlan1" + "Namespace, if any, to append to the metric prefix to build the path." + ' If the location is "vlan1" and the namespace is "building1.cellar"' + ' the resulting metric path would be "PREFIX.building1.cellar.vlan1"' ), type=str, ) @@ -102,7 +111,7 @@ def parse_args(): "--extract-vlan", help=( "Try to extract the name of a vlan from the location." - ' If the vlan is named "vlan1_baluba" ' + ' If the location is "vlan1_baluba" ' " the resulting metric path would be PREFIX.vlan1" ), action="store_true",