Skip to content

Commit

Permalink
Merge pull request #20 from ipHeaders/feature/PR-20
Browse files Browse the repository at this point in the history
Feature/pr 20
  • Loading branch information
ipHeaders committed Feb 17, 2023
2 parents 3017a8c + ee43fc5 commit 3504ef6
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
30 changes: 29 additions & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,32 @@
| bgpNeighborStateStr_info | Label | state of bgp neighbor in string |
| bgpNeighborUptime | Gauge | uptime of the bgp neighbor |
| bgpNeighborReceivedPrefix | Gauge | total number of prefixes received from the neighbor |
| bgpNeighborSentPrefix | Gauge | total number of prefixes advertised to the neighbor |
| bgpNeighborSentPrefix | Gauge | total number of prefixes advertised to the neighbor |


## Appliances Flows

| Name | Type | Description |
| ------------ | ------------ | ------------ |
| activeTotalFlows | Gauge | number of active flows |
| activeStaleFlows | Gauge | number of active stale flows |
| activeInconsistentFlows | Gauge | number of active inconsistent flows |
| activeFlowsWithIssues | Gauge | number of active flows with issues |
| activeFlowsOptimized | Gauge | number of active optimized flows |
| activeFlowsWithIgnores | Gauge | no description in swagger |
| activeFlowsPassthrough | Gauge | number of active passthrough flows |
| activeFlowsManagement | Gauge | number of active management flows |
| activeFlowsAsymmetric | Gauge | number of active asymmetric flows |
| activeFlowsRouteDropped | Gauge | number of active flows dropped due to route |
| activeFlowsFirewallDropped | Gauge | number of active flows dropped due to firewall |
| inactiveTotalFlows | Gauge | number of inactive flows |
| inactiveStaleFlows | Gauge | number of inactive stale flows |
| inactiveInconsistentFlows | Gauge | number of inactive inconsistent flows |
| inactiveFlowsWithIssues | Gauge | number of inactive flows with issues |
| inactiveFlowsOptimized | Gauge | number of inactive optimized flows |
| inactiveFlowsWithIgnores | Gauge | no description in swagger |
| inactiveFlowsPassthrough | Gauge | number of inactive passthrough flows |
| inactiveFlowsManagement | Gauge | number of inactive management flows |
| inactiveFlowsAsymmetric | Gauge | number of inactive asymmetric flows |
| inactiveFlowsRouteDropped | Gauge | number of inactive flows dropped due to route |
| inactiveFlowsFirewallDropped | Gauge | number of inactive flows dropped due to firewall |
75 changes: 75 additions & 0 deletions silverpeak_exporter/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,22 @@ def applianceCollector(**kwargs):
except Exception as error:
log().error(f'failed to set argument {error}')

if 'flows' in kwargs['feature']:
try:
log().info(f'starting flows metric collection on {applianceName,ne_pk} every {interval} seconds')

collectApplianceFlows(
url = kwargs['url'],
ne_pk = ne_pk,
applianceName = applianceName,
key = kwargs['key'],
verify_ssl = kwargs['verify_ssl'],
interval = interval,
debug = kwargs['debug'],
Break = kwargs['Break'],
)
except Exception as error:
log().error(f'failed to set argument {error}')

def getAllAppliances(url,verify_ssl,api_key):
try:
Expand Down Expand Up @@ -394,6 +409,66 @@ def _getApplianBGPState(self):

return orch_return



class collectApplianceOSPF():
def __init__(self):
pass


class collectApplianceFlows():
def __init__(self,url,ne_pk,applianceName,key,verify_ssl,interval,debug, Break):
self.url = url
self.ne_pk = ne_pk
self.applianceName = applianceName
self.key = key
self.verify_ssl = verify_ssl
self.interval = interval
self.debug = debug
self.Break = Break
self.orch = Orchestrator(url=self.url, verify_ssl=self.verify_ssl, api_key=self.key )
while True:
# get a list of all the methods in this class
# loops over the list starting at index 1 to bypass __init__
# calls the method
methodList = inspect.getmembers(self, predicate=inspect.ismethod)
for m in range(1, len(methodList)):
i = methodList[m][1]()

logToFile().debug(message=dict({methodList[m][1].__name__ : i}), debug=self.debug)
confirmReturn(func=methodList[m][1].__name__ ,dictionary=i, debug=self.debug)
writeResult(func=list(i.keys())[0], result=i['result'], debug=self.debug)
if self.Break == False:
wait(self.interval)
else:
break

@errorHandler
def _getApplianceFlows(self):
orch_return = self.orch.get_appliance_flows(self.ne_pk,uptime="term5m")

activeTotalFlows.labels(applianceName=self.applianceName).set(orch_return['active']['total_flows']) #Setting Metric
activeStaleFlows.labels(applianceName=self.applianceName).set(orch_return['active']['stale_flows']) #Setting Metric
activeInconsistentFlows.labels(applianceName=self.applianceName).set(orch_return['active']['inconsistent_flows']) #Setting Metric
activeFlowsWithIssues.labels(applianceName=self.applianceName).set(orch_return['active']['flows_with_issues']) #Setting Metric
activeFlowsOptimized.labels(applianceName=self.applianceName).set(orch_return['active']['flows_optimized']) #Setting Metric
activeFlowsWithIgnores.labels(applianceName=self.applianceName).set(orch_return['active']['flows_with_ignores']) #Setting Metric
activeFlowsPassthrough.labels(applianceName=self.applianceName).set(orch_return['active']['flows_passthrough']) #Setting Metric
activeFlowsManagement.labels(applianceName=self.applianceName).set(orch_return['active']['flows_management']) #Setting Metric
activeFlowsAsymmetric.labels(applianceName=self.applianceName).set(orch_return['active']['flows_asymmetric']) #Setting Metric
activeFlowsRouteDropped.labels(applianceName=self.applianceName).set(orch_return['active']['flows_route_dropped']) #Setting Metric
activeFlowsFirewallDropped.labels(applianceName=self.applianceName).set(orch_return['active']['flows_firewall_dropped']) #Setting Metric

inactiveTotalFlows.labels(applianceName=self.applianceName).set(orch_return['inactive']['total_flows']) #Setting Metric
inactiveStaleFlows.labels(applianceName=self.applianceName).set(orch_return['inactive']['stale_flows']) #Setting Metric
inactiveInconsistentFlows.labels(applianceName=self.applianceName).set(orch_return['inactive']['inconsistent_flows']) #Setting Metric
inactiveFlowsWithIssues.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_with_issues']) #Setting Metric
inactiveFlowsOptimized.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_optimized']) #Setting Metric
inactiveFlowsWithIgnores.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_with_ignores']) #Setting Metric
inactiveFlowsPassthrough.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_passthrough']) #Setting Metric
inactiveFlowsManagement.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_management']) #Setting Metric
inactiveFlowsAsymmetric.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_asymmetric']) #Setting Metric
inactiveFlowsRouteDropped.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_route_dropped']) #Setting Metric
inactiveFlowsFirewallDropped.labels(applianceName=self.applianceName).set(orch_return['inactive']['flows_firewall_dropped']) #Setting Metric

return orch_return
31 changes: 30 additions & 1 deletion silverpeak_exporter/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,33 @@
bgpNeighborStateStr = Info('bgpNeighborStateStr', 'state of bgp neighbor in string',['applianceName','peer_ip','asn'])
bgpNeighborUptime = Gauge('bgpNeighborUptime', 'uptime of the bgp neighbor',['applianceName','peer_ip'])
bgpNeighborReceivedPrefix = Gauge('bgpNeighborReceivedPrefix', 'total number of prefixes received from the neighbor',['applianceName','peer_ip'])
bgpNeighborSentPrefix = Gauge('bgpNeighborSentPrefix', 'total number of prefixes advertised to the neighbor',['applianceName','peer_ip'])
bgpNeighborSentPrefix = Gauge('bgpNeighborSentPrefix', 'total number of prefixes advertised to the neighbor',['applianceName','peer_ip'])



#---------#---------#---------#---------#---------#
# Flows Metrics
#---------#---------#---------#---------#---------#

activeTotalFlows = Gauge('activeTotalFlows', 'number of active flows',['applianceName',])
activeStaleFlows = Gauge('activeStaleFlows', 'number of active stale flows',['applianceName',])
activeInconsistentFlows = Gauge('activeInconsistentFlows', 'number of active inconsistent flows',['applianceName',])
activeFlowsWithIssues = Gauge('activeFlowsWithIssues', 'number of active flows with issues',['applianceName',])
activeFlowsOptimized = Gauge('activeFlowsOptimized', 'number of active optimized flows',['applianceName',])
activeFlowsWithIgnores = Gauge('activeFlowsWithIgnores', 'no description in swagger',['applianceName',])
activeFlowsPassthrough = Gauge('activeFlowsPassthrough', 'number of active passthrough flows',['applianceName',])
activeFlowsManagement = Gauge('activeFlowsManagement', 'number of active management flows',['applianceName',])
activeFlowsAsymmetric = Gauge('activeFlowsAsymmetric', 'number of active asymmetric flows',['applianceName',])
activeFlowsRouteDropped = Gauge('activeFlowsRouteDropped', 'number of active flows dropped due to route',['applianceName',])
activeFlowsFirewallDropped = Gauge('activeFlowsFirewallDropped', 'number of active flows dropped due to firewall',['applianceName',])
inactiveTotalFlows = Gauge('inactiveTotalFlows', 'number of inactive flows',['applianceName',])
inactiveStaleFlows = Gauge('inactiveStaleFlows', 'number of inactive stale flows',['applianceName',])
inactiveInconsistentFlows = Gauge('inactiveInconsistentFlows', 'number of inactive inconsistent flows',['applianceName',])
inactiveFlowsWithIssues = Gauge('inactiveFlowsWithIssues', 'number of inactive flows with issues',['applianceName',])
inactiveFlowsOptimized = Gauge('inactiveFlowsOptimized', 'number of inactive optimized flows',['applianceName',])
inactiveFlowsWithIgnores = Gauge('inactiveFlowsWithIgnores', 'no description in swagger',['applianceName',])
inactiveFlowsPassthrough = Gauge('inactiveFlowsPassthrough', 'number of inactive passthrough flows',['applianceName',])
inactiveFlowsManagement = Gauge('inactiveFlowsManagement', 'number of inactive management flows',['applianceName',])
inactiveFlowsAsymmetric = Gauge('inactiveFlowsAsymmetric', 'number of inactive asymmetric flows',['applianceName',])
inactiveFlowsRouteDropped = Gauge('inactiveFlowsRouteDropped', 'number of inactive flows dropped due to route',['applianceName',])
inactiveFlowsFirewallDropped = Gauge('inactiveFlowsFirewallDropped', 'number of inactive flows dropped due to firewall',['applianceName',])
2 changes: 2 additions & 0 deletions test/test_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ appliances:
edge-1: # Change name accordingly
- {system: true, interval: 120}
- {bgp: true, interval: 120}
- {flows: true, interval: 120}
edge-2: # Change name accordingly
- {system: true, interval: 120}
- {bgp: true, interval: 120}
- {flows: true, interval: 120}


0 comments on commit 3504ef6

Please sign in to comment.