Skip to content

Commit

Permalink
Merge d6a4056 into b8fd835
Browse files Browse the repository at this point in the history
  • Loading branch information
road-cycling committed Jan 28, 2020
2 parents b8fd835 + d6a4056 commit 89bac46
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
@@ -0,0 +1,20 @@
[Core]
Name = CienaWS Device Metrics Enrichment Plugin
Module = plugin_enrichment_cienaws_device_metrics

[Documentation]
Author = Verizon Media, Inc.
Version = 0.1
Website = getpanoptes.io
Description = Plugin to collect device metrics enrichment for Ciena Waveserver devices

[main]
execute_frequency = 60
resource_filter = resource_class = "network" AND resource_type = "ciena" AND resource_metadata.model LIKE "%Waveserver%"
enrichment_ttl = 900
namespace = metrics

[snmp]
max_repetitions = 25
timeout = 10
retries = 2
@@ -0,0 +1,112 @@
"""
This module implements a Panoptes Plugin that can poll Ciena Waveserver devices for Device Metrics
"""

from cached_property import threaded_cached_property

from yahoo_panoptes.enrichment.schema.generic.snmp import PanoptesGenericSNMPMetricsEnrichmentGroup
from yahoo_panoptes.framework.enrichment import PanoptesEnrichmentSet
from yahoo_panoptes.plugins.enrichment.generic.snmp.plugin_enrichment_generic_snmp \
import PanoptesEnrichmentGenericSNMPPlugin


MIB_CIENA_CHASSIS = u'.1.3.6.1.4.1.1271'
cwsChassisFanStateOperationalState = MIB_CIENA_CHASSIS + u'.3.4.6.25.1.3'
cwsChassisPsuStateOperationalState = MIB_CIENA_CHASSIS + u'.3.4.6.21.1.3'


class CienaWSDeviceMetricsEnrichment(PanoptesGenericSNMPMetricsEnrichmentGroup):
pass


class CienaPluginWSDeviceMetricsEnrichment(PanoptesEnrichmentGenericSNMPPlugin):
def __init__(self):
self._plugin_context = None
self._logger = None
self._ciena_model = None
self._snmp_connection = None
self._max_repetitions = None
self._polling_execute_frequency = None
super(CienaPluginWSDeviceMetricsEnrichment, self).__init__()

@property
def metrics_enrichment_class(self):
return CienaWSDeviceMetricsEnrichment

@threaded_cached_property
def _num_fan_units(self):

varbinds = self._snmp_connection.bulk_walk(cwsChassisFanStateOperationalState, max_repetitions=2)
fans_total = len(varbinds)

return fans_total

@threaded_cached_property
def _num_power_supplies(self):

varbinds = self._snmp_connection.bulk_walk(cwsChassisPsuStateOperationalState, max_repetitions=2)
power_supplies = len(varbinds)

return power_supplies

def _build_metrics_oids_map(self):
self._oids_map = {
u"fan_status": {
u"method": u"bulk_walk",
u"oid": cwsChassisFanStateOperationalState
},
u"power_status": {
u"method": u"bulk_walk",
u"oid": cwsChassisPsuStateOperationalState
}
}

def _build_metrics_groups_conf(self):
self._metrics_groups = []
if self._num_fan_units > 0:

self._metrics_groups.append({
u"group_name": u"environment",
u"dimensions": {},
u"metrics": {
u"fans_ok": {
u"metric_type": u"gauge",
u"value": u"len([x for x in fan_status.values() if x == '1'])"
},
u"fans_total": self._num_fan_units
}
}),
if self._num_power_supplies > 0:
self._metrics_groups.append({
u"group_name": u"environment",
u"dimensions": {},
u"metrics": {
u"power_units_on": {
u"metric_type": u"gauge",
u"value": u"len([x for x in power_status.values() if x == '1'])"
},
u"power_units_total": self._num_power_supplies
}
})

def get_enrichment(self):
self._ciena_model = self._plugin_context.data.resource_metadata.get(u'model', u'unknown')
self._build_metrics_oids_map()
self._build_metrics_groups_conf()

enrichment_set = {
u"oids": self.oids_map,
u"metrics_groups": self.metrics_groups
}

try:
self.enrichment_group.add_enrichment_set(PanoptesEnrichmentSet(self.device_fqdn, enrichment_set))
except Exception as e:
self._logger.error(u'Error while adding enrichment set {} to enrichment group for the device {}: {}'.
format(enrichment_set, self.device_fqdn, repr(e)))

self.enrichment_group_set.add_enrichment_group(self.enrichment_group)

self._logger.debug(u'Metrics enrichment for device {}: {}'.format(self.device_fqdn, self.enrichment_group_set))

return self.enrichment_group_set
@@ -0,0 +1,19 @@
[Core]
Name = CienaWS Device Metrics Polling Plugin
Module = plugin_polling_generic_snmp

[Documentation]
Author = Verizon Media, Inc.
Version = 0.1
Website = getpanoptes.io
Description = Plugin to poll device metrics from Ciena Waveserver devices

[main]
execute_frequency = 60
resource_filter = resource_class = "network" AND resource_type = "ciena" AND resource_metadata.model LIKE "%Waveserver%"
namespace = metrics
polling_status_metric_name = polling_status

[enrichment]
preload = self:metrics

0 comments on commit 89bac46

Please sign in to comment.