import os\r
import docker\r
import json\r
+from copy import deepcopy\r
\r
logging.basicConfig(level=logging.INFO)\r
\r
link_dict = self.net.DCNetwork_graph[vnf_name][connected_sw]\r
vnf_interface = link_dict[0]['src_port_id']\r
\r
- for metric_dict in self.network_metrics:\r
+ for metric_dict in deepcopy(self.network_metrics):\r
if metric_dict['vnf_name'] == vnf_name and metric_dict['vnf_interface'] == vnf_interface \\r
and metric_dict['metric_key'] == metric:\r
\r
elif metric_dict['vnf_name'] == vnf_name and vnf_interface is None and metric is None:\r
self.monitor_lock.acquire()\r
self.network_metrics.remove(metric_dict)\r
- for collector in self.registry._collectors:\r
- collector_dict = collector._metrics.copy()\r
- for name, interface, id in collector_dict:\r
- if name == vnf_name:\r
- logging.info('3 name:{0} labels:{1} metrics:{2}'.format(collector._name, collector._labelnames,\r
- collector._metrics))\r
- collector.remove(name, interface, 'None')\r
+ logging.info('remove metric from monitor: vnf_name:{0} vnf_interface:{1} mon_port:{2}'.format(metric_dict['vnf_name'], metric_dict['vnf_interface'], metric_dict['mon_port']))\r
\r
delete_from_gateway(self.pushgateway, job='sonemu-SDNcontroller')\r
self.monitor_lock.release()\r
- logging.info('Stopped monitoring vnf: {0}'.format(vnf_name))\r
- return 'Stopped monitoring: {0}'.format(vnf_name)\r
+ continue\r
\r
- return 'Error stopping monitoring metric: {0} on {1}:{2}'.format(metric, vnf_name, vnf_interface)\r
+ if vnf_interface is None and metric is None:\r
+ logging.info('Stopped monitoring vnf: {0}'.format(vnf_name))\r
+ return 'Stopped monitoring: {0}'.format(vnf_name)\r
+ else:\r
+ return 'Error stopping monitoring metric: {0} on {1}:{2}'.format(metric, vnf_name, vnf_interface)\r
\r
\r
# get all metrics defined in the list and export it to Prometheus\r
\r
else:\r
time_delta = (port_uptime - metric_dict['previous_monitor_time'])\r
- metric_rate = (this_measurement - metric_dict['previous_measurement']) / float(time_delta)\r
+ #metric_rate = (this_measurement - metric_dict['previous_measurement']) / float(time_delta)\r
\r
metric_dict['previous_measurement'] = this_measurement\r
metric_dict['previous_monitor_time'] = port_uptime\r
\r
logging.exception('metric {0} not found on {1}:{2}'.format(metric_key, vnf_name, vnf_interface))\r
logging.exception('monport:{0}, dpid:{1}'.format(mon_port, switch_dpid))\r
+ logging.exception('monitored network_metrics:{0}'.format(self.network_metrics))\r
logging.exception('port dict:{0}'.format(port_stat_dict))\r
return 'metric {0} not found on {1}:{2}'.format(metric_key, vnf_name, vnf_interface)\r
\r