Skip to content

Commit

Permalink
Rename "location"-flag to "namespace", update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Mar 7, 2024
1 parent a8f5128 commit 3cf58d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
8 changes: 5 additions & 3 deletions contrib/scripts/isc_dhpcd_graphite/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.


Expand Down
23 changes: 16 additions & 7 deletions contrib/scripts/isc_dhpcd_graphite/isc_dhpcd_graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -89,20 +98,20 @@ 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,
)
parser.add_argument(
"--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",
Expand Down

0 comments on commit 3cf58d9

Please sign in to comment.