- stdout = self.conf.execute_command(
- "date '+%Y-%m-%d'", compute_node.get_ip())
- date = stdout[0].strip()
- metrics = []
- for plugin_subdir in plugin_subdirectories:
- for meter_category in meter_categories:
- stdout = self.conf.execute_command(
- "tail -2 /var/lib/collectd/csv/"
- + "{0}.jf.intel.com/{1}/{2}-{3}".format(
- compute_node.get_name(), plugin_subdir, meter_category,
- date),
- compute_node.get_ip())
- # Storing last two values
- values = stdout
- if len(values) < 2:
- logger.error(
- 'Getting last two CSV entries of meter category '
- + '{0} in {1} subdir failed'.format(
- meter_category, plugin_subdir))
- else:
- old_value = int(values[0][0:values[0].index('.')])
- new_value = int(values[1][0:values[1].index('.')])
- metrics.append((
- plugin_subdir, meter_category, old_value, new_value))
+ compute_name = compute_node.get_name()
+ nodes = get_apex_nodes()
+ for node in nodes:
+ if compute_name == node.get_dict()['name']:
+ date = node.run_cmd(
+ "date '+%Y-%m-%d'")
+ hostname = node.run_cmd('hostname -A')
+ hostname = hostname.split()[0]
+ metrics = []
+ for plugin_subdir in plugin_subdirectories:
+ for meter_category in meter_categories:
+ stdout1 = node.run_cmd(
+ "tail -2 /var/lib/collectd/csv/"
+ + "{0}/{1}/{2}-{3}".format(
+ hostname, plugin_subdir,
+ meter_category, date))
+ stdout2 = node.run_cmd(
+ "tail -1 /var/lib/collectd/csv/"
+ + "{0}/{1}/{2}-{3}".format(
+ hostname, plugin_subdir,
+ meter_category, date))
+ # Storing last two values
+ values = stdout1
+ values2 = stdout2
+ if values is None:
+ logger.error(
+ 'Getting last two CSV entries of meter category'
+ + ' {0} in {1} subdir failed'.format(
+ meter_category, plugin_subdir))
+ elif values2 is None:
+ logger.error(
+ 'Getting last CSV entries of meter category'
+ + ' {0} in {1} subdir failed'.format(
+ meter_category, plugin_subdir))
+ else:
+ values = values.split(',')
+ old_value = float(values[0])
+ values2 = values2.split(',')
+ new_value = float(values2[0])
+ metrics.append((
+ plugin_subdir, meter_category, old_value,
+ new_value))