@@ -55,20 +55,20 @@ def parse_args():
55
55
"-f" ,
56
56
"--config-file" ,
57
57
type = pathlib .Path ,
58
- help = "Complete path to dhcpd-pools config-file. Usually located in /etc/dhcpd/" ,
58
+ help = "Complete path to dhcpd-pools config-file. Usually located in /etc/dhcpd/. Default: %(default)s " ,
59
59
default = DEFAULT_CONFIG_FILE ,
60
60
)
61
61
parser .add_argument (
62
62
"-C" ,
63
63
"--command" ,
64
- help = "Path to dhcpd-pools command" ,
64
+ help = "Path to dhcpd-pools command. Default: %(default)s " ,
65
65
type = pathlib .Path ,
66
66
default = DEFAULT_CMD_PATH ,
67
67
)
68
68
parser .add_argument (
69
69
"-p" ,
70
70
"--prefix" ,
71
- help = "Path prefix to use for the metric, overriding the default" ,
71
+ help = "Path prefix to use for the metric, overriding the default. Default: %(default)s " ,
72
72
type = str ,
73
73
default = DEFAULT_PREFIX ,
74
74
)
@@ -86,7 +86,7 @@ def parse_args():
86
86
parser .add_argument (
87
87
"-P" ,
88
88
"--protocol" ,
89
- help = "Protocol to use to send to graphite server" ,
89
+ help = "Protocol to use to send to graphite server. Default: %(default)s " ,
90
90
choices = protocol_choices ,
91
91
default = str (DEFAULT_PROTOCOL ),
92
92
type = str ,
@@ -159,6 +159,8 @@ def _tuplify(jsonblob, prefix):
159
159
output = list ()
160
160
for vlan_stat in data :
161
161
vlan = _clean_vlan (vlan_stat ["location" ])
162
+ if not vlan :
163
+ continue
162
164
for key , metric in METRIC_MAPPER .items ():
163
165
path = f"{ prefix } .{ vlan } .{ metric } "
164
166
value = vlan_stat [key ]
@@ -168,7 +170,10 @@ def _tuplify(jsonblob, prefix):
168
170
169
171
def _clean_vlan (location ):
170
172
regex = re .search ("vlan\d+" , location )
171
- return regex .group ()
173
+ if regex :
174
+ return regex .group ()
175
+ sys .stderr .write (f"No vlan found in location { location } : invalid\n " )
176
+ return None
172
177
173
178
174
179
# send the data
0 commit comments