Skip to content

Commit

Permalink
Check now supports multiple ranges of VLANs (#10)
Browse files Browse the repository at this point in the history
- #CCCP-1837
  • Loading branch information
martbhell authored and junousi committed Oct 25, 2017
1 parent 8ffc311 commit 7b62694
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions files/nrpe/check_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,12 @@ def check_vlan_capacity(self):

# The 'network_vlan_ranges' parameter looks like: 'default:80:89'
# the 2nd number is the lower vlan id, the 3rd is the higher id
vlan_range = config['network_vlan_ranges'].split(':')
vlans_total = int(vlan_range[2]) - int(vlan_range[1])
# It can also look like 'default:80:89,default:65:75' so we loop over it.
vlan_ranges = config['network_vlan_ranges'].split(',')
vlans_total = 0
for vrange in vlan_ranges:
vlan_range = vrange.split(':')
vlans_total = int(vlans_total) + (int(vlan_range[2]) - int(vlan_range[1]))

return { 'vlans_used': vlans_in_use, 'vlans_total': vlans_total }

Expand Down

0 comments on commit 7b62694

Please sign in to comment.