FreeBSD 12.3 python38-3.8.15 isc-dhcp44-server-4.4.3P1 dhcpd-pools-3.1
I try to use isc_dhpcd_graphite.py but stumble quite early:
./isc_dhpcd_graphite.py -n <graphiteserver>
Traceback (most recent call last): File "/root/bin/isc_dhpcd_graphite.py", line 205, in <module> main() File "/root/bin/isc_dhpcd_graphite.py", line 194, in main output = render(jsonblob, args.actual_prefix, args.protocol) File "/root/bin/isc_dhpcd_graphite.py", line 134, in render return _render_text(jsonblob, prefix) File "/root/bin/isc_dhpcd_graphite.py", line 139, in _render_text input = _tuplify(jsonblob, prefix) File "/root/bin/isc_dhpcd_graphite.py", line 163, in _tuplify vlan = _clean_vlan(vlan_stat["location"]) File "/root/bin/isc_dhpcd_graphite.py", line 173, in _clean_vlan return regex.group() AttributeError: 'NoneType' object has no attribute 'group'
Where to begin debugging? Any flags to dhcpd-pools that are implicit to Linux and I am missing?
If I get this to work, examples of how to display the results via NAV are welcome.
--Ingeborg
On Fri, 11 Nov 2022 12:38:58 +0100 Ingeborg Hellemo ingeborg.hellemo@uit.no wrote:
I try to use isc_dhpcd_graphite.py but stumble quite early:
./isc_dhpcd_graphite.py -n <graphiteserver>
Yeah,
all I can say is: https://github.com/Uninett/nav/issues/2424
It's assigned to Hanne, who wrote the thing, but that's how far it's gotten.
ingeborg.hellemo@uit.no said:
File "/root/bin/isc_dhpcd_graphite.py", line 163, in _tuplify vlan = _clean_vlan(vlan_stat["location"]) File "/root/bin/isc_dhpcd_graphite.py", line 173, in _clean_vlan return regex.group() AttributeError: 'NoneType' object has no attribute 'group'
I've tried to look at the code and I think the error is related to the output of dhcpd-pools. We run our DHCP-server in failover-mode. I don't know if this has an impact of the output, but here are some output examples from our server(s):
{ "location":"All networks", "range":"158.39.125.10 - 158.39.125.254", "first_ip":"158.39.125.10", "last_ip":"158.39.125.254", "defined":245, "used":80, "touched":100, "free":165, "percent":32.6531, "touch_count":180, "touch_percent":73.4694, "backup_count":65, "backup_percent":26.5306, "status":0 }, { "location":"All networks", "range":"158.39.132.16 - 158.39.135.254", "first_ip":"158.39.132.16", "last_ip":"158.39.135.254", "defined":1007, "used":261, "touched":449, "free":746, "percent":25.9186, "touch_count":710, "touch_percent":70.5065, "backup_count":297, "backup_percent":29.4935, "status":0 },
--Ingeborg
Yes the regular expression is trying to run on something that is not a string.
1. We fetch the results of dhcpd-pools in 'exec_dhcpd_pools()' and store it as json 2. The result is a dictionary/hashmap where we care about the key "shared_networks" only. The value of the key is a list. 3. Then in 'render()' we use '_tuplify()' to loop over the list from "shared-networks" and push every key-value pair to graphite 4. Tuplify assumes that all "location"s have values that are strings that contain "vlan"
So, it crashes on your location being "All networks"! This must be considered a bug.
I think I'll add a debug option to make it easier to see what is going on as well.
________________________________________ From: Ingeborg Hellemo ingeborg.hellemo@uit.no Sent: Friday, November 11, 2022 15:20 To: nav-users@lister.sikt.no Subject: [Nav-users] Re: Any documentation about contrib/isc_dhpcd_graphite.py ?
ingeborg.hellemo@uit.no said:
File "/root/bin/isc_dhpcd_graphite.py", line 163, in _tuplify vlan = _clean_vlan(vlan_stat["location"]) File "/root/bin/isc_dhpcd_graphite.py", line 173, in _clean_vlan return regex.group() AttributeError: 'NoneType' object has no attribute 'group'
I've tried to look at the code and I think the error is related to the output of dhcpd-pools. We run our DHCP-server in failover-mode. I don't know if this has an impact of the output, but here are some output examples from our server(s):
{ "location":"All networks", "range":"158.39.125.10 - 158.39.125.254", "first_ip":"158.39.125.10", "last_ip":"158.39.125.254", "defined":245, "used":80, "touched":100, "free":165, "percent":32.6531, "touch_count":180, "touch_percent":73.4694, "backup_count":65, "backup_percent":26.5306, "status":0 }, { "location":"All networks", "range":"158.39.132.16 - 158.39.135.254", "first_ip":"158.39.132.16", "last_ip":"158.39.135.254", "defined":1007, "used":261, "touched":449, "free":746, "percent":25.9186, "touch_count":710, "touch_percent":70.5065, "backup_count":297, "backup_percent":29.4935, "status":0 },
--Ingeborg -- Ingeborg Østrem Hellemo -- ingeborg.hellemo@uit.no Dep. of Information Technology --- Univ. of Tromsø
_______________________________________________ Nav-users mailing list -- nav-users@lister.sikt.no To unsubscribe send an email to nav-users-leave@lister.sikt.no
So, it crashes on your location being "All networks"! This must be considered a bug.
I think I'll add a debug option to make it easier to see what is going on as well.
That would be nice. And also an example of expected output of dhcpd-pools will help. There is a -A flag that gives this output (together with -f j)
{ "location":"10.100.68.0/22", "range":"10.100.68.16 - 10.100.71.254", "first_ip":"10.100.68.16", "last_ip":"10.100.71.254", "defined":1007, "used":0, "touched":0, "free":1007, "percent":0, "touch_count":0, "touch_percent":0, "backup_count":503, "backup_percent":49.9503, "status":0 }, { "location":"10.100.72.0/21", "range":"10.100.72.16 - 10.100.79.254", "first_ip":"10.100.72.16", "last_ip":"10.100.79.254", "defined":2031, "used":36, "touched":1198, "free":1995, "percent":1.77253, "touch_count":1234, "touch_percent":60.7582, "backup_count":797, "backup_percent":39.2418, "status":0 },
Does this look better? The program still crashes though.
hanne.moa@sikt.no said:
- Tuplify assumes that all "location"s have values that are strings that
contain "vlan"
OK, this is a strange assumption since the DHCP server knows nothing about vlans only subnets and ranges.
--Ingeborg