Exemplo n.º 1
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     # These are a selection of argument names. If they're
     # present, then we'll use them, otherwise, we'll use
     # the default provided by the redis module itself
     redisArgs = {}
     for arg in ["host", "port", "db", "password", "charset", "errors", "unix_socket_path"]:
         try:
             redisArgs[arg] = kwargs[arg]
         except KeyError:
             pass
     self.redis = redis.Redis(**redisArgs)
     # The keys we should save from the 'info' command in redis
     self.info = kwargs.get("info", [])
     # The keys we should get and interpret as numbers
     self.get = kwargs.get("get", [])
     # The keys we should get, and report their length
     self.llen = kwargs.get("llen", [])
     # The keys we should get and report the hash length
     self.hlen = kwargs.get("hlen", [])
     # The keys we should get and report the particular key from
     self.hget = kwargs.get("hget", {})
     # The keys we should get and report the cardinality of
     self.scard = kwargs.get("scard", [])
     # The keys we should get and report the zcardinality of
     self.zcard = kwargs.get("zcard", [])
     # The patterns we should count the number of keys of
     self.patterns = kwargs.get("patterns", [])
Exemplo n.º 2
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     # These are a selection of argument names. If they're
     # present, then we'll use them, otherwise, we'll use
     # the default provided by the redis module itself
     redisArgs = {}
     for arg in [
             'host', 'port', 'db', 'password', 'charset', 'errors',
             'unix_socket_path'
     ]:
         try:
             redisArgs[arg] = kwargs[arg]
         except KeyError:
             pass
     self.redis = redis.Redis(**redisArgs)
     # The keys we should save from the 'info' command in redis
     self.info = kwargs.get('info', [])
     # The keys we should get and interpret as numbers
     self.get = kwargs.get('get', [])
     # The keys we should get, and report their length
     self.llen = kwargs.get('llen', [])
     # The keys we should get and report the hash length
     self.hlen = kwargs.get('hlen', [])
     # The keys we should get and report the particular key from
     self.hget = kwargs.get('hget', {})
     # The keys we should get and report the cardinality of
     self.scard = kwargs.get('scard', [])
     # The keys we should get and report the zcardinality of
     self.zcard = kwargs.get('zcard', [])
     # The patterns we should count the number of keys of
     self.patterns = kwargs.get('patterns', [])
Exemplo n.º 3
0
 def reconfig(self, name, host=None, user=None, passwd=None, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.name   = name
     self.host   = host
     self.user   = user
     self.passwd = passwd
     self.conn   = None
     self.cur    = None
Exemplo n.º 4
0
 def reconfig(self, name, bucket, keys=None, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.bucketName = bucket
     self.prefix = kwargs.get('prefix', '')
     try:
         self.conn = S3Connection(kwargs.get('aws_id', None), kwargs.get('aws_secret', None))
         self.bucket = self.conn.get_bucket(bucket)
     except BotoClientError as e:
         raise MetricException(repr(e))
Exemplo n.º 5
0
 def reconfig(self, name, bucket, keys=None, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.bucketName = bucket
     self.prefix = kwargs.get('prefix', '')
     try:
         self.conn = S3Connection(kwargs.get('aws_id', None),
                                  kwargs.get('aws_secret', None))
         self.bucket = self.conn.get_bucket(bucket)
     except BotoClientError as e:
         raise MetricException(repr(e))
Exemplo n.º 6
0
 def reconfig(self, name, path, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.name = name
     self.patterns = dict([(k, re.compile(v)) for k,v in kwargs.items()])
     self.path = path
     try:
         self.f = file(self.path)    # The file object we'll read from
     except IOError as e:
         raise MetricException(e)
     self.stat = os.lstat(self.path) # The stats on that particular file
Exemplo n.º 7
0
 def reconfig(self, name, path, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.name = name
     self.patterns = dict([(k, re.compile(v)) for k, v in kwargs.items()])
     self.path = path
     try:
         self.f = file(self.path)  # The file object we'll read from
     except IOError as e:
         raise MetricException(e)
     self.stat = os.lstat(self.path)  # The stats on that particular file
 def reconfig(self, *args, **kwargs):
   Metric.reconfig(self, *args, **kwargs)
   if not isinstance(self.metrics, list):
     raise MetricException('metrics should be a list')
   self.serverstatus_metrics = self.metrics
   for metric in self.serverstatus_metrics:
     try:
       assert NginxServerStatusMetric.AVAILABLE_METRICS_DATA.has_key(metric)
     except AssertionError:
       raise MetricException('Metric is not available, choose out of %s' % (", ".join(NginxServerStatusMetric.AVAILABLE_METRICS_DATA.keys())))
 def reconfig(self, *args, **kwargs):
   Metric.reconfig(self, *args, **kwargs)
   if not self.__dict__.has_key('url'):
     self.url = 'http://127.0.0.1/server-status?auto'
   if not isinstance(self.metrics, list):
     raise MetricException('metrics should be a list')
   self.serverstatus_metrics = self.metrics
   for metric in self.serverstatus_metrics:
     try:
       assert HttpdServerStatus.AVAILABLE_METRICS_DATA.has_key(metric)
     except AssertionError:
       raise MetricException('Metric is not available, choose out of %s' % (", ".join(HttpdServerStatus.AVAILABLE_METRICS_DATA.keys())))
Exemplo n.º 10
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     rabbitmq_default = {
         'host': 'localhost',
         'port': 55672,
         'user': '******',
         'password': '******',
         'vhost': '/'}
     rabbitmq_url_parts = dict([(k, kwargs.get(k, rabbitmq_default[k])) for k in rabbitmq_default.keys()])
     rabbitmq_url_parts['vhost'] = quote(rabbitmq_url_parts['vhost'], '')
     self.queues_api_url = 'http://%(user)s:%(password)s@%(host)s:%(port)i/api/queues/%(vhost)s' % rabbitmq_url_parts
     self.queue_names = kwargs['queues']
Exemplo n.º 11
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     rabbitmq_default = {
         'host': 'localhost',
         'port': 55672,
         'user': '******',
         'password': '******',
         'vhost': '/'
     }
     rabbitmq_url_parts = dict([(k, kwargs.get(k, rabbitmq_default[k]))
                                for k in rabbitmq_default.keys()])
     rabbitmq_url_parts['vhost'] = quote(rabbitmq_url_parts['vhost'], '')
     self.queues_api_url = 'http://%(user)s:%(password)s@%(host)s:%(port)i/api/queues/%(vhost)s' % rabbitmq_url_parts
     self.queue_names = kwargs['queues']
Exemplo n.º 12
0
 def reconfig(self, name, serializer, url, metrics, interval='60', **kwargs):
   Metric.reconfig(self, name, serializer, **kwargs)
   self.url = url
   self.interval = interval
   if not isinstance(metrics, list):
     raise MetricException('metrics should be a list')
   self.serverstatus_metrics = metrics
   for metric in self.serverstatus_metrics:
     try:
       assert HttpdServerStatus.AVAILABLE_METRICS_DATA.has_key(metric)
     except AssertionError:
       raise MetricException('Metric is not available, choose out of %s' % (", ".join(HttpdServerStatus.AVAILABLE_METRICS_DATA.keys())))
   try:
     server_status = httplib2.Http() 
   except Exception as e:
     raise MetricException(e)
Exemplo n.º 13
0
 def reconfig(self, name, url, metrics, interval='60', **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.name = name
     self.url = url
     self.interval = interval
     if not isinstance(metrics, list):
         raise MetricException('metrics should be a list')
     self.serverstatus_metrics = metrics
     for metric in self.serverstatus_metrics:
         try:
             assert HttpdServerStatus.AVAILABLE_METRICS_DATA.has_key(metric)
         except AssertionError:
             raise MetricException(
                 'Metric is not available, choose out of %s' % (", ".join(
                     HttpdServerStatus.AVAILABLE_METRICS_DATA.keys())))
     try:
         server_status = httplib2.Http()
     except Exception as e:
         raise MetricException(e)
Exemplo n.º 14
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.kwargs = kwargs
     for k in ['name', 'user', 'args', 'cwd']:
         try:
             self.kwargs[k] = re.compile(self.kwargs[k])
         except KeyError:
             pass
         except re.error:
             raise MetricException('Invalid regular expression: %s' % self.kwargs[k])
     self.attrs = {
         'user-cpu'    : (ProcMetric.userCPU, 'Seconds'),
         'sys-cpu'     : (ProcMetric.sysCPU , 'Seconds'),
         'real-mem'    : (ProcMetric.realMem, 'Megabytes'),
         'virt-mem'    : (ProcMetric.virtMem, 'Megabytes'),
         'files'       : (ProcMetric.numFiles, 'Count'),
         'children'    : (ProcMetric.numChildren, 'Count'),
         'connections' : (ProcMetric.numConnections, 'Count'),
         'uptime'      : (ProcMetric.uptime, 'Seconds'),
         'percent-mem' : (psutil.Process.get_memory_percent, 'Percent'),
         'threads'     : (psutil.Process.get_num_threads, 'Count')
     }
Exemplo n.º 15
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.kwargs = kwargs
     for k in ["name", "user", "args", "cwd"]:
         try:
             self.kwargs[k] = re.compile(self.kwargs[k])
         except KeyError:
             pass
         except re.error:
             raise MetricException("Invalid regular expression: %s" % self.kwargs[k])
     self.attrs = {
         "user-cpu": (ProcMetric.userCPU, "Seconds"),
         "sys-cpu": (ProcMetric.sysCPU, "Seconds"),
         "real-mem": (ProcMetric.realMem, "Megabytes"),
         "virt-mem": (ProcMetric.virtMem, "Megabytes"),
         "files": (ProcMetric.numFiles, "Count"),
         "children": (ProcMetric.numChildren, "Count"),
         "connections": (ProcMetric.numConnections, "Count"),
         "uptime": (ProcMetric.uptime, "Seconds"),
         "percent-mem": (psutil.Process.get_memory_percent, "Percent"),
         "threads": (psutil.Process.get_num_threads, "Count"),
     }
Exemplo n.º 16
0
 def reconfig(self, name, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.kwargs = kwargs
     for k in ['name', 'user', 'args', 'cwd']:
         try:
             self.kwargs[k] = re.compile(self.kwargs[k])
         except KeyError:
             pass
         except re.error:
             raise MetricException('Invalid regular expression: %s' %
                                   self.kwargs[k])
     self.attrs = {
         'user-cpu': (ProcMetric.userCPU, 'Seconds'),
         'sys-cpu': (ProcMetric.sysCPU, 'Seconds'),
         'real-mem': (ProcMetric.realMem, 'Megabytes'),
         'virt-mem': (ProcMetric.virtMem, 'Megabytes'),
         'files': (ProcMetric.numFiles, 'Count'),
         'children': (ProcMetric.numChildren, 'Count'),
         'connections': (ProcMetric.numConnections, 'Count'),
         'uptime': (ProcMetric.uptime, 'Seconds'),
         'percent-mem': (psutil.Process.get_memory_percent, 'Percent'),
         'threads': (psutil.Process.get_num_threads, 'Count')
     }
Exemplo n.º 17
0
 def reconfig(self, name, url, post=None, timeout=30, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.url  = url
     self.post = post
     self.timeout = timeout  
Exemplo n.º 18
0
 def reconfig(self, name, cmd, units, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.cmd = cmd
     self.units = units
Exemplo n.º 19
0
 def __init__(self, name, serializer, url, **kwargs):
   Metric.__init__(self, name, serializer, **kwargs)
   self.reconfig(name, serializer, url, **kwargs)
Exemplo n.º 20
0
 def reconfig(self, name, start, stop, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.start = start
     self.stop  = stop
Exemplo n.º 21
0
 def __init__(self, name, cmd, units, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, cmd, units)
Exemplo n.º 22
0
 def __init__(self, name, host='127.0.0.1', port=9306, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, host, port)
Exemplo n.º 23
0
 def __init__(self, name, bucket, keys=None, **kwargs):
     Metric.__init__(self, name, keys, **kwargs)
     self.reconfig(name, bucket, keys, **kwargs)
Exemplo n.º 24
0
 def __init__(self, name, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, **kwargs)
Exemplo n.º 25
0
 def reconfig(self, name, start, stop, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.start = start
     self.stop = stop
Exemplo n.º 26
0
 def reconfig(self, **kwargs):
   Metric.reconfig(self, **kwargs)
   self.conn   = None
   self.cur    = None
Exemplo n.º 27
0
 def reconfig(self, name, host='127.0.0.1', port=9306, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.host   = host
     self.port   = port
     self.conn   = None
     self.cur    = None
Exemplo n.º 28
0
 def __init__(self, name, bucket, keys=None, **kwargs):
     Metric.__init__(self, name, keys, **kwargs)
     self.reconfig(name, bucket, keys, **kwargs)
Exemplo n.º 29
0
 def __init__(self, name, path, **kwargs):
     Metric.__init__(self, name)
     self.reconfig(name, path, **kwargs)
Exemplo n.º 30
0
 def reconfig(self, name, serializer, path, **kwargs):
     Metric.reconfig(self, name, serializer, **kwargs)
     self.path = path
Exemplo n.º 31
0
 def reconfig(self, name, cmd, units, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.cmd   = cmd
     self.units = units
Exemplo n.º 32
0
 def __init__(self, name, host=None, user=None, passwd=None, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, host, user, passwd)
Exemplo n.º 33
0
 def reconfig(self, url, **kwargs):
   '''parameters: url, [ post={}, timeout=30 ]'''
   Metric.reconfig(self, **kwargs)
   self.url  = url
Exemplo n.º 34
0
 def reconfig(self, name, path, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.path = path
Exemplo n.º 35
0
 def reconfig(self, name, path, **kwargs):
     Metric.reconfig(self, name, **kwargs)
     self.path = path
Exemplo n.º 36
0
 def __init__(self, name, url, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, url, **kwargs)
Exemplo n.º 37
0
 def __init__(self, name, serializer, cmd, units, **kwargs):
     Metric.__init__(self, name, serializer, **kwargs)
     self.reconfig(name, cmd, serializer, units)
Exemplo n.º 38
0
 def __init__(self, name, start, stop, **kwargs):
     Metric.__init__(self, name, **kwargs)
     self.reconfig(name, start, stop)