carbon_collector.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import graphitesend
4 import rospy
5 from pal_statistics_msgs.msg import Statistics
6 
8  def __init__(self, topics, system_name=None, dry_run=False):
9  self.dry_run = dry_run
10  self.gs = graphitesend.GraphiteClient(prefix='', graphite_server='localhost', \
11  system_name=system_name, dryrun=dry_run)
12 
13  self.statistics_subs = []
14  for topic in topics:
15  statistics_sub = rospy.Subscriber(topic, Statistics, self.statistics_callback)
16  self.statistics_subs.append(statistics_sub)
17 
18  def statistics_callback(self, msg):
19  timestamp = rospy.Time(msg.header.stamp.secs, msg.header.stamp.nsecs)
20 
21  stats = []
22  for stat in msg.statistics:
23  stats.append((stat.name, stat.value))
24 
25  result = self.gs.send_list(stats, timestamp.to_sec())
26 
27  if self.dry_run:
28  print result
29 
30  return result
31 
def __init__(self, topics, system_name=None, dry_run=False)


pal_carbon_collector
Author(s): Jordan Palacios
autogenerated on Mon Feb 28 2022 23:04:04