Renaming agent packages to reflect monasca

Renamed monagent package to monasca_agent and monsetup package to monasca_setup.
Also, renamed the monstatsd agent package to statsd to more closely match the internal
collector and forwarder packages.

Change-Id: I0649ae4341fe325007e2a8d37161d330e4c95d72
This commit is contained in:
gary-hessler 2014-12-17 12:01:44 -07:00
parent 110781ca0c
commit 34d82d455e
147 changed files with 462 additions and 478 deletions

View File

@ -400,10 +400,10 @@ Plugins are the way to extend the Monasca Agent. Plugins add additional functio
Developers can extend the functionality of the Agent by writing custom plugins. Plugins are written in Python according to the conventions described below. The plugin script is placed in /etc/monasca/agent/checks.d, and a YAML file containing the configuration for the plugin is placed in /etc/monasca/agent/conf.d. The YAML file must have the same stem name as the plugin script.
### AgentCheck Interface
Most monasca-agent plugin code uses the AgentCheck interface. All custom checks inherit from the AgentCheck class found in monagent/collector/checks/__init__.py and require a check() method that takes one argument, instance, which is a dict specifying the configuration of the instance on behalf of the plugin being executed. The check() method is run once per instance defined in the check's configuration (discussed later).
Most monasca-agent plugin code uses the AgentCheck interface. All custom checks inherit from the AgentCheck class found in monasca_agent/collector/checks/__init__.py and require a check() method that takes one argument, instance, which is a dict specifying the configuration of the instance on behalf of the plugin being executed. The check() method is run once per instance defined in the check's configuration (discussed later).
### ServicesCheck interface
Some monasca-agent plugins use the ServicesCheck class found in monagent/collector/services_checks.py. These require a _check() method that is similar to AgentCheck's check(), but instead of being called once per iteration in a linear fashion, it is run against a threadpool to allow concurrent instances to be checked. Also, _check() must return a tuple consisting of either Status.UP or 'Status.DOWN(frommonagent.collector.checks.services_checks`), plus a text description.
Some monasca-agent plugins use the ServicesCheck class found in monasca_agent/collector/services_checks.py. These require a _check() method that is similar to AgentCheck's check(), but instead of being called once per iteration in a linear fashion, it is run against a threadpool to allow concurrent instances to be checked. Also, _check() must return a tuple consisting of either Status.UP or 'Status.DOWN(from monasca_agent.collector.checks.services_checks`), plus a text description.
The size of the threadpool is either 6 or the total number of instances, whichever is lower. This may be adjusted with the threads_count parameter in the plugin's init_config (see Plugin Configuration below).
@ -965,7 +965,7 @@ The following ceilometer processes are monitored, if they exist when the monasca
The Libvirt plugin provides metrics for virtual machines when run on the hypervisor server. It provides two sets of metrics per measurement: one designed for the owner of the VM, and one intended for the owner of the hypervisor server.
### Configuration
The `monasca-setup` program will configure the Libvirt plugin if `nova-api` is running, `/etc/nova/nova.conf` exists, and `python-novaclient` is installed. It uses a cache directory to persist data, which is `/dev/shm` by default. On non-Linux systems (BSD, Mac OSX), `/dev/shm` may not exist, so `cache_dir` would need to be changed accordingly, either in `monsetup/detection/plugins/libvirt.py` prior to running `monasca-setup`, or `/etc/monasca/agent/conf.d/libvirt.yaml` afterwards.
The `monasca-setup` program will configure the Libvirt plugin if `nova-api` is running, `/etc/nova/nova.conf` exists, and `python-novaclient` is installed. It uses a cache directory to persist data, which is `/dev/shm` by default. On non-Linux systems (BSD, Mac OSX), `/dev/shm` may not exist, so `cache_dir` would need to be changed accordingly, either in `monasca_setup/detection/plugins/libvirt.py` prior to running `monasca-setup`, or `/etc/monasca/agent/conf.d/libvirt.yaml` afterwards.
`nova_refresh` specifies the number of seconds between calls to the Nova API to refresh the instance cache. This is helpful for updating VM hostname and pruning deleted instances from the cache. By default, it is set to 14,400 seconds (four hours). Set to 0 to refresh every time the Collector runs, or to None to disable regular refreshes entirely (though the instance cache will still be refreshed if a new instance is detected).

View File

@ -79,24 +79,24 @@ use_mount: no
# non_local_traffic: no
# ========================================================================== #
# MonStatsd configuration #
# Monasca Statsd configuration #
# ========================================================================== #
# MonStatsd is a small server that aggregates your custom app metrics.
# Monasca Statsd is a small server that aggregates your custom app metrics.
# Make sure your client is sending to the same port.
monstatsd_port : 8125
monasca_statsd_port : 8125
## The monstatsd flush period.
# monstatsd_interval : 10
## The monasca_statsd flush period.
# monasca_statsd_interval : 10
## If 'yes', counters and rates will be normalized to 1 second (that is divided
## by the monstatsd_interval) before being sent to the server. Defaults to 'yes'
# monstatsd_normalize : yes
## by the monasca_statsd_interval) before being sent to the server. Defaults to 'yes'
# monasca_statsd_normalize : yes
# If you want to forward every packet received by the monstatsd server
# If you want to forward every packet received by the monasca_statsd server
# to another statsd server, uncomment these lines.
# WARNING: Make sure that forwarded packets are regular statsd packets and not "monstatsd" packets,
# WARNING: Make sure that forwarded packets are regular statsd packets and not "monasca_statsd" packets,
# as your other statsd server might not be able to handle them.
# statsd_forward_host: address_of_own_statsd_server
# statsd_forward_port: 8125
@ -155,7 +155,7 @@ log_level: INFO
collector_log_file: /var/log/monasca/agent/collector.log
forwarder_log_file: /var/log/monasca/agent/forwarder.log
monstatsd_log_file: /var/log/monasca/agent/monstatsd.log
statsd_log_file: /var/log/monasca/agent/statsd.log
# if syslog is enabled but a host and port are not set, a local domain socket
# connection will be attempted

View File

@ -15,10 +15,11 @@ import traceback
import yaml
from monagent.common.aggregator import MetricsAggregator
import monagent.common.config
import monagent.common.exceptions
import monagent.common.util
from monasca_agent.common.keystone import Keystone
from monasca_agent.common.aggregator import MetricsAggregator
import monasca_agent.common.config
import monasca_agent.common.exceptions
import monasca_agent.common.util
log = logging.getLogger(__name__)
@ -52,7 +53,7 @@ class Check(object):
self._counters = {} # metric_name: bool
self.logger = logger
try:
self.logger.addFilter(monagent.common.util.LaconicFilter())
self.logger.addFilter(monasca_agent.common.util.LaconicFilter())
except Exception:
self.logger.exception("Trying to install laconic log filter and failed")
@ -127,11 +128,11 @@ class Check(object):
if timestamp is None:
timestamp = time.time()
if metric not in self._sample_store:
raise monagent.common.exceptions.CheckException("Saving a sample for an undefined metric: %s" % metric)
raise monasca_agent.common.exceptions.CheckException("Saving a sample for an undefined metric: %s" % metric)
try:
value = monagent.common.util.cast_metric_val(value)
value = monasca_agent.common.util.cast_metric_val(value)
except ValueError as ve:
raise monagent.common.exceptions.NaN(ve)
raise monasca_agent.common.exceptions.NaN(ve)
# Sort and validate dimensions
self._set_dimensions(dimensions)
@ -147,7 +148,7 @@ class Check(object):
self._sample_store[metric][key] = self._sample_store[metric][key][-1:] + \
[(timestamp, value, hostname, device_name)]
else:
raise monagent.common.exceptions.CheckException("%s must be either gauge or counter, skipping sample at %s" %
raise monasca_agent.common.exceptions.CheckException("%s must be either gauge or counter, skipping sample at %s" %
(metric, time.ctime(timestamp)))
if self.is_gauge(metric):
@ -169,19 +170,19 @@ class Check(object):
try:
interval = sample2[0] - sample1[0]
if interval == 0:
raise monagent.common.exceptions.Infinity()
raise monasca_agent.common.exceptions.Infinity()
delta = sample2[1] - sample1[1]
if delta < 0:
raise monagent.common.exceptions.UnknownValue()
raise monasca_agent.common.exceptions.UnknownValue()
return (sample2[0], delta / interval, sample2[2], sample2[3])
except monagent.common.exceptions.Infinity:
except monasca_agent.common.exceptions.Infinity:
raise
except monagent.common.exceptions.UnknownValue:
except monasca_agent.common.exceptions.UnknownValue:
raise
except Exception as e:
raise monagent.common.exceptions.NaN(e)
raise monasca_agent.common.exceptions.NaN(e)
def get_sample_with_timestamp(self, metric, dimensions=None, device_name=None, expire=True):
"""Get (timestamp-epoch-style, value).
@ -192,11 +193,11 @@ class Check(object):
# Never seen this metric
if metric not in self._sample_store:
raise monagent.common.exceptions.UnknownValue()
raise monasca_agent.common.exceptions.UnknownValue()
# Not enough value to compute rate
elif self.is_counter(metric) and len(self._sample_store[metric][key]) < 2:
raise monagent.common.exceptions.UnknownValue()
raise monasca_agent.common.exceptions.UnknownValue()
elif self.is_counter(metric) and len(self._sample_store[metric][key]) >= 2:
res = self._rate(
@ -209,7 +210,7 @@ class Check(object):
return self._sample_store[metric][key][-1]
else:
raise monagent.common.exceptions.UnknownValue()
raise monasca_agent.common.exceptions.UnknownValue()
def get_sample(self, metric, dimensions=None, device_name=None, expire=True):
"""Return the last value for that metric.
@ -259,7 +260,7 @@ class Check(object):
try:
ts, val, hostname, device_name = self.get_sample_with_timestamp(
m, dimensions, device_name, expire)
except monagent.common.exceptions.UnknownValue:
except monasca_agent.common.exceptions.UnknownValue:
continue
attributes = {}
if dimensions_list:
@ -289,7 +290,7 @@ class AgentCheck(object):
self.name = name
self.init_config = init_config
self.agent_config = agent_config
self.hostname = monagent.common.util.get_hostname(agent_config)
self.hostname = monasca_agent.common.util.get_hostname(agent_config)
self.log = logging.getLogger('%s.%s' % (__name__, name))
self.aggregator = MetricsAggregator(self.hostname,
@ -455,7 +456,7 @@ class AgentCheck(object):
"""Get all metrics, including the ones that are tagged.
@return the list of samples
@rtype list of Measurement objects from monagent.common.metrics
@rtype list of Measurement objects from monasca_agent.common.metrics
"""
if prettyprint:
metrics = self.aggregator.flush()
@ -528,16 +529,16 @@ class AgentCheck(object):
try:
self.check(instance)
if self.has_warnings():
instance_status = monagent.common.check_status.InstanceStatus(i,
monagent.common.check_status.STATUS_WARNING,
instance_status = monasca_agent.common.check_status.InstanceStatus(i,
monasca_agent.common.check_status.STATUS_WARNING,
warnings=self.get_warnings())
else:
instance_status = monagent.common.check_status.InstanceStatus(i,
monagent.common.check_status.STATUS_OK)
instance_status = monasca_agent.common.check_status.InstanceStatus(i,
monasca_agent.common.check_status.STATUS_OK)
except Exception as e:
self.log.exception("Check '%s' instance #%s failed" % (self.name, i))
instance_status = monagent.common.check_status.InstanceStatus(i,
monagent.common.check_status.STATUS_ERROR,
instance_status = monasca_agent.common.check_status.InstanceStatus(i,
monasca_agent.common.check_status.STATUS_ERROR,
error=e,
tb=traceback.format_exc())
instance_statuses.append(instance_status)
@ -622,7 +623,7 @@ def run_check(name, path=None):
import tests.common
# Read the config file
confd_path = path or os.path.join(monagent.common.config.get_confd_path(monagent.common.util.get_os()),
confd_path = path or os.path.join(monasca_agent.common.config.get_confd_path(monasca_agent.common.util.get_os()),
'%s.yaml' % name)
try:

View File

@ -6,9 +6,9 @@ import system.win32 as w32
import threading
import time
import monagent.common.check_status
import monagent.common.metrics
import monagent.common.util
import monasca_agent.common.check_status
import monasca_agent.common.metrics
import monasca_agent.common.util
log = logging.getLogger(__name__)
@ -32,7 +32,7 @@ class Collector(object):
def __init__(self, agent_config, emitter, checksd=None):
self.emit_duration = None
self.agent_config = agent_config
self.os = monagent.common.util.get_os()
self.os = monasca_agent.common.util.get_os()
self.plugins = None
self.emitter = emitter
socket.setdefaulttimeout(15)
@ -79,18 +79,18 @@ class Collector(object):
# Don't try to send to an emitter if we're stopping/
if self.continue_running:
name = self.emitter.__name__
emitter_status = monagent.common.check_status.EmitterStatus(name)
emitter_status = monasca_agent.common.check_status.EmitterStatus(name)
try:
self.emitter(payload, log, self.agent_config['forwarder_url'])
except Exception as e:
log.exception("Error running emitter: %s" % self.emitter.__name__)
emitter_status = monagent.common.check_status.EmitterStatus(name, e)
emitter_status = monasca_agent.common.check_status.EmitterStatus(name, e)
statuses.append(emitter_status)
return statuses
def _set_status(self, check_statuses, emitter_statuses, collect_duration):
try:
monagent.common.check_status.CollectorStatus(check_statuses, emitter_statuses).persist()
monasca_agent.common.check_status.CollectorStatus(check_statuses, emitter_statuses).persist()
except Exception:
log.exception("Error persisting collector status")
@ -129,7 +129,7 @@ class Collector(object):
There are currently two types of checks the system checks and the configured ones from checks_d
"""
timer = monagent.common.util.Timer()
timer = monasca_agent.common.util.Timer()
self.run_count += 1
log.debug("Starting collection run #%s" % self.run_count)
@ -142,7 +142,7 @@ class Collector(object):
for check_type in self._legacy_checks:
try:
for name, value in check_type.check().iteritems():
metrics_list.append(monagent.common.metrics.Measurement(name,
metrics_list.append(monasca_agent.common.metrics.Measurement(name,
timestamp,
value,
{'component': 'monasca-agent',
@ -166,7 +166,7 @@ class Collector(object):
# Add in metrics on the collector run, emit_duration is from the previous run
for name, value in self.collector_stats(len(metrics_list), len(events),
collect_duration, self.emit_duration).iteritems():
metrics_list.append(monagent.common.metrics.Measurement(name,
metrics_list.append(monasca_agent.common.metrics.Measurement(name,
timestamp,
value,
{'component': 'monasca-agent',
@ -215,14 +215,14 @@ class Collector(object):
except Exception:
log.exception("Error running check %s" % check.name)
check_status = monagent.common.check_status.CheckStatus(check.name, instance_statuses, metric_count, event_count,
check_status = monasca_agent.common.check_status.CheckStatus(check.name, instance_statuses, metric_count, event_count,
library_versions=check.get_library_info())
check_statuses.append(check_status)
for check_name, info in self.init_failed_checks_d.iteritems():
if not self.continue_running:
return
check_status = monagent.common.check_status.CheckStatus(check_name, None, None, None,
check_status = monasca_agent.common.check_status.CheckStatus(check_name, None, None, None,
init_failed_error=info['error'],
init_failed_traceback=info['traceback'])
check_statuses.append(check_status)

View File

@ -5,8 +5,8 @@ import re
import time
import traceback
import monagent.collector
import monagent.common.util
import monasca_agent.collector
import monasca_agent.common.util
import utils
@ -111,7 +111,7 @@ class Dogstream(object):
if parser_spec:
try:
parse_func = monagent.collector.modules.load(parser_spec, 'parser')
parse_func = monasca_agent.collector.modules.load(parser_spec, 'parser')
if isinstance(parse_func, type):
logger.info('Instantiating class-based dogstream')
parse_func = parse_func(
@ -142,7 +142,7 @@ class Dogstream(object):
self.class_based = class_based
# Apply LaconicFilter to avoid log flooding
self.logger.addFilter(monagent.common.util.LaconicFilter("dogstream"))
self.logger.addFilter(monasca_agent.common.util.LaconicFilter("dogstream"))
self.log_path = log_path
self.parse_func = parse_func or self._default_line_parser

View File

@ -3,8 +3,8 @@ import Queue
import threading
import time
import monagent.collector.checks
import monagent.collector.checks.libs.thread_pool
import monasca_agent.collector.checks
import monasca_agent.collector.checks.libs.thread_pool
TIMEOUT = 180
@ -17,7 +17,7 @@ Status = up_down('UP', 'DOWN')
EventType = up_down("servicecheck.state_change.up", "servicecheck.state_change.down")
class ServicesCheck(monagent.collector.checks.AgentCheck):
class ServicesCheck(monasca_agent.collector.checks.AgentCheck):
SOURCE_TYPE_NAME = 'servicecheck'
"""Services checks inherits from this class.
@ -39,7 +39,7 @@ class ServicesCheck(monagent.collector.checks.AgentCheck):
"""
def __init__(self, name, init_config, agentConfig, instances):
monagent.collector.checks.AgentCheck.__init__(self, name, init_config, agentConfig, instances)
monasca_agent.collector.checks.AgentCheck.__init__(self, name, init_config, agentConfig, instances)
# A dictionary to keep track of service statuses
self.statuses = {}
@ -59,7 +59,7 @@ class ServicesCheck(monagent.collector.checks.AgentCheck):
default_size = min(self.instance_count(), DEFAULT_SIZE_POOL)
self.pool_size = int(self.init_config.get('threads_count', default_size))
self.pool = monagent.collector.checks.libs.thread_pool.Pool(self.pool_size)
self.pool = monasca_agent.collector.checks.libs.thread_pool.Pool(self.pool_size)
self.resultsq = Queue.Queue()
self.jobs_status = {}

View File

@ -13,16 +13,16 @@ import time
# project
import monagent.collector.checks.check
import monagent.common.metrics
import monagent.common.util
import monasca_agent.collector.checks.check
import monasca_agent.common.metrics
import monasca_agent.common.util
# locale-resilient float converter
to_float = lambda s: float(s.replace(",", "."))
class Disk(monagent.collector.checks.check.Check):
class Disk(monasca_agent.collector.checks.check.Check):
"""Collects metrics about the machine's disks.
"""
@ -60,7 +60,7 @@ class Disk(monagent.collector.checks.check.Check):
# parse into a list of Measurements
stats.update(inodes)
timestamp = time.time()
measurements = [monagent.common.metrics.Measurement(key.split('.', 1)[1],
measurements = [monasca_agent.common.metrics.Measurement(key.split('.', 1)[1],
timestamp,
value,
{'device': key.split('.', 1)[0],
@ -93,14 +93,14 @@ class Disk(monagent.collector.checks.check.Check):
if use_mount:
parts[0] = parts[-1]
if inodes:
if monagent.common.util.Platform.is_darwin(platform_name):
if monasca_agent.common.util.Platform.is_darwin(platform_name):
# Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted
# Inodes are in position 5, 6 and we need to compute the total
# Total
parts[1] = int(parts[5]) + int(parts[6]) # Total
parts[2] = int(parts[5]) # Used
parts[3] = int(parts[6]) # Available
elif monagent.common.util.Platform.is_freebsd(platform_name):
elif monasca_agent.common.util.Platform.is_freebsd(platform_name):
# Filesystem 1K-blocks Used Avail Capacity iused ifree %iused Mounted
# Inodes are in position 5, 6 and we need to compute the total
parts[1] = int(parts[5]) + int(parts[6]) # Total
@ -207,10 +207,10 @@ class Disk(monagent.collector.checks.check.Check):
return devices
class IO(monagent.collector.checks.check.Check):
class IO(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.header_re = re.compile(r'([%\\/\-_a-zA-Z0-9]+)[\s+]?')
self.item_re = re.compile(r'^([a-zA-Z0-9\/]+)')
self.value_re = re.compile(r'\d+\.\d+')
@ -300,7 +300,7 @@ class IO(monagent.collector.checks.check.Check):
"""
io = {}
try:
if monagent.common.util.Platform.is_linux():
if monasca_agent.common.util.Platform.is_linux():
stdout = sp.Popen(['iostat', '-d', '1', '2', '-x', '-k'],
stdout=sp.PIPE,
close_fds=True).communicate()[0]
@ -412,7 +412,10 @@ class IO(monagent.collector.checks.check.Check):
for dev_name, stats in filtered_io.iteritems():
filtered_stats = {stat: stats[stat]
for stat in stats.iterkeys() if stat not in self.stat_blacklist}
m_list = [monagent.common.metrics.Measurement(key, timestamp, value, {'device': dev_name,
m_list = [monasca_agent.common.metrics.Measurement(key,
timestamp,
value,
{'device': dev_name,
'service': 'monitoring',
'component': 'monasca-agent'},
None)
@ -426,10 +429,10 @@ class IO(monagent.collector.checks.check.Check):
return {}
class Load(monagent.collector.checks.check.Check):
class Load(monasca_agent.collector.checks.check.Check):
def check(self):
if monagent.common.util.Platform.is_linux():
if monasca_agent.common.util.Platform.is_linux():
try:
loadAvrgProc = open('/proc/loadavg', 'r')
uptime = loadAvrgProc.readlines()
@ -458,10 +461,10 @@ class Load(monagent.collector.checks.check.Check):
}
class Memory(monagent.collector.checks.check.Check):
class Memory(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
macV = None
if sys.platform == 'darwin':
macV = platform.mac_ver()
@ -485,7 +488,7 @@ class Memory(monagent.collector.checks.check.Check):
pass
def check(self):
if monagent.common.util.Platform.is_linux():
if monasca_agent.common.util.Platform.is_linux():
try:
meminfoProc = open('/proc/meminfo', 'r')
lines = meminfoProc.readlines()
@ -756,7 +759,7 @@ class Memory(monagent.collector.checks.check.Check):
return {}
class Cpu(monagent.collector.checks.check.Check):
class Cpu(monasca_agent.collector.checks.check.Check):
def check(self):
"""Return an aggregate of CPU stats across all CPUs.
@ -789,7 +792,7 @@ class Cpu(monagent.collector.checks.check.Check):
self.logger.debug("Cannot extract cpu value %s from %s (%s)" % (name, data, legend))
return 0.0
if monagent.common.util.Platform.is_linux():
if monasca_agent.common.util.Platform.is_linux():
mpstat = sp.Popen(['mpstat', '1', '3'], stdout=sp.PIPE, close_fds=True).communicate()[0]
# topdog@ip:~$ mpstat 1 3
# Linux 2.6.32-341-ec2 (ip) 01/19/2012 _x86_64_ (2 CPU)

View File

@ -1,4 +1,4 @@
import monagent.collector.checks.check
import monasca_agent.collector.checks.check
try:
import wmi
@ -15,10 +15,10 @@ B2MB = float(1048576)
KB2MB = B2KB = float(1024)
class Processes(monagent.collector.checks.check.Check):
class Processes(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.gauge('system.proc.queue_length')
self.gauge('system.proc.count')
@ -44,10 +44,10 @@ class Processes(monagent.collector.checks.check.Check):
return self.get_metrics()
class Memory(monagent.collector.checks.check.Check):
class Memory(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.logger = logger
self.gauge('system.mem.free')
self.gauge('system.mem.used')
@ -84,10 +84,10 @@ class Memory(monagent.collector.checks.check.Check):
return self.get_metrics()
class Cpu(monagent.collector.checks.check.Check):
class Cpu(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.logger = logger
self.gauge('system.cpu.user')
self.gauge('system.cpu.idle')
@ -143,10 +143,10 @@ class Cpu(monagent.collector.checks.check.Check):
return val
class Network(monagent.collector.checks.check.Check):
class Network(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.logger = logger
self.gauge('system.net.bytes_rcvd')
self.gauge('system.net.bytes_sent')
@ -170,10 +170,10 @@ class Network(monagent.collector.checks.check.Check):
return self.get_metrics()
class Disk(monagent.collector.checks.check.Check):
class Disk(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.logger = logger
self.gauge('system.disk.free')
self.gauge('system.disk.total')
@ -204,10 +204,10 @@ class Disk(monagent.collector.checks.check.Check):
return self.get_metrics()
class IO(monagent.collector.checks.check.Check):
class IO(monasca_agent.collector.checks.check.Check):
def __init__(self, logger):
monagent.collector.checks.check.Check.__init__(self, logger)
monasca_agent.collector.checks.check.Check.__init__(self, logger)
self.logger = logger
self.gauge('system.io.wkb_s')
self.gauge('system.io.w_s')

View File

@ -1,8 +1,8 @@
import urllib2
from monagent.collector.checks import AgentCheck
from monagent.collector.checks.utils import add_basic_auth
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.collector.checks.utils import add_basic_auth
from monasca_agent.common.util import headers
class Apache(AgentCheck):

View File

@ -3,7 +3,7 @@ from fnmatch import fnmatch
import os
import time
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
CFUNC_TO_AGGR = {
'AVERAGE': 'avg',

View File

@ -1,8 +1,8 @@
import json
import urllib2
from monagent.collector.checks import AgentCheck
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import headers
class CouchDb(AgentCheck):

View File

@ -3,9 +3,9 @@ import urllib2
import re
import sys
from monagent.collector.checks import AgentCheck
from monagent.collector.checks.utils import add_basic_auth
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.collector.checks.utils import add_basic_auth
from monasca_agent.common.util import headers
# Constants

View File

@ -6,7 +6,7 @@ from os.path import exists
from os.path import join
import time
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class DirectoryCheck(AgentCheck):

View File

@ -7,7 +7,7 @@ import urllib2
import urllib
from urlparse import urlsplit
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
DEFAULT_MAX_CONTAINERS = 20

View File

@ -6,9 +6,9 @@ import time
import urllib2
import urlparse
from monagent.collector.checks import AgentCheck
from monagent.collector.checks.utils import add_basic_auth
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.collector.checks.utils import add_basic_auth
from monasca_agent.common.util import headers
class NodeNotFound(Exception):

View File

@ -1,4 +1,4 @@
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class Gearman(AgentCheck):

View File

@ -13,7 +13,7 @@ except ImportError:
psutil = None
# project
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class GUnicornCheck(AgentCheck):

View File

@ -2,8 +2,8 @@ from collections import defaultdict
import time
import urllib2
from monagent.collector.checks import AgentCheck
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import headers
STATS_URL = "/;csv;norefresh"

View File

@ -1,4 +1,4 @@
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class HDFSCheck(AgentCheck):

View File

@ -7,8 +7,8 @@ import socket
import subprocess
import sys
from monagent.collector.checks.services_checks import ServicesCheck
from monagent.collector.checks.services_checks import Status
from monasca_agent.collector.checks.services_checks import ServicesCheck
from monasca_agent.collector.checks.services_checks import Status
class HostAlive(ServicesCheck):

View File

@ -12,10 +12,9 @@ from httplib2 import Http
from httplib2 import httplib
from httplib2 import HttpLib2Error
from monagent.collector.checks.check import AgentCheck
from monagent.collector.checks.services_checks import ServicesCheck
from monagent.collector.checks.services_checks import Status
from monagent.common.keystone import Keystone
from monasca_agent.collector.checks.check import AgentCheck
from monasca_agent.collector.checks.services_checks import ServicesCheck
from monasca_agent.collector.checks.services_checks import Status
class HTTPCheck(ServicesCheck):

View File

@ -6,7 +6,7 @@ try:
except Exception:
wmi = None
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class IIS(AgentCheck):

View File

@ -11,8 +11,8 @@ except ImportError:
except ImportError:
pass
from monagent.collector.checks import AgentCheck
from monagent.common.util import get_hostname
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import get_hostname
class Skip(Exception):

View File

@ -7,7 +7,7 @@ if sys.version_info < (2, 6):
raise Exception('kafka_consumer check requires at least Python 2.6')
from collections import defaultdict
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
try:
from kafka.client import KafkaClient

View File

@ -2,7 +2,7 @@ from collections import defaultdict
import re
import urllib2
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
db_stats = re.compile(r'^db_(\d)+$')

View File

@ -22,8 +22,8 @@ import yaml
from calendar import timegm
from datetime import datetime
from monagent.collector.virt import inspector
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.virt import inspector
from monasca_agent.collector.checks import AgentCheck
class LibvirtCheck(AgentCheck):

View File

@ -1,8 +1,8 @@
import urllib2
from monagent.collector.checks import AgentCheck
from monagent.collector.checks.utils import add_basic_auth
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.collector.checks.utils import add_basic_auth
from monasca_agent.common.util import headers
class Lighttpd(AgentCheck):

View File

@ -1,4 +1,4 @@
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
# Reference: http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
# Name Type Meaning

View File

@ -2,8 +2,8 @@ import re
import time
import types
from monagent.collector.checks import AgentCheck
from monagent.common.util import get_hostname
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import get_hostname
# When running with pymongo < 2.0

View File

@ -4,7 +4,7 @@ import subprocess
import sys
import traceback
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
GAUGE = "gauge"

View File

@ -11,7 +11,7 @@ import socket
import subprocess
import time
from monagent.collector.checks.services_checks import ServicesCheck, Status
from monasca_agent.collector.checks.services_checks import ServicesCheck, Status
class WrapNagios(ServicesCheck):

View File

@ -7,8 +7,8 @@ import re
import subprocess
# project
from monagent.collector.checks import AgentCheck
from monagent.common.util import Platform
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import Platform
class Network(AgentCheck):

View File

@ -1,9 +1,9 @@
import re
import urllib2
from monagent.collector.checks import AgentCheck
from monagent.collector.checks.utils import add_basic_auth
from monagent.common.util import headers
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.collector.checks.utils import add_basic_auth
from monasca_agent.common.util import headers
class Nginx(AgentCheck):

View File

@ -1,6 +1,6 @@
import os
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class PostfixCheck(AgentCheck):

View File

@ -1,5 +1,5 @@
from monagent.collector.checks import AgentCheck
from monagent.common.exceptions import CheckException
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.exceptions import CheckException
class ShouldRestartException(Exception):

View File

@ -1,8 +1,8 @@
"""Gather metrics on specific processes.
"""
from monagent.collector.checks import AgentCheck
from monagent.common.util import Platform
from monasca_agent.collector.checks import AgentCheck
from monasca_agent.common.util import Platform
class ProcessCheck(AgentCheck):

View File

@ -3,7 +3,7 @@ import time
import urllib2
import urlparse
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
EVENT_TYPE = SOURCE_TYPE_NAME = 'rabbitmq'

View File

@ -4,7 +4,7 @@
import re
import time
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class Redis(AgentCheck):

View File

@ -5,7 +5,7 @@ import json
import socket
import time
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class Riak(AgentCheck):

View File

@ -3,7 +3,7 @@
"""
import traceback
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
ALL_INSTANCES = 'ALL'

View File

@ -1,9 +1,9 @@
import socket
import time
from monagent.collector.checks.services_checks import EventType
from monagent.collector.checks.services_checks import ServicesCheck
from monagent.collector.checks.services_checks import Status
from monasca_agent.collector.checks.services_checks import EventType
from monasca_agent.collector.checks.services_checks import ServicesCheck
from monasca_agent.collector.checks.services_checks import Status
class BadConfException(Exception):

View File

@ -2,7 +2,7 @@ import re
import subprocess
import xml.parsers.expat # python 2.4 compatible
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class Varnish(AgentCheck):

View File

@ -8,7 +8,7 @@ try:
except Exception:
wmi = None
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
SOURCE_TYPE_NAME = 'event viewer'
EVENT_TYPE = 'win32_log_event'

View File

@ -9,7 +9,7 @@ try:
except Exception:
wmi = None
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
UP_METRIC = 'Up'
SEARCH_WILDCARD = '*'

View File

@ -27,7 +27,7 @@ import socket
from StringIO import StringIO
import struct
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
class Zookeeper(AgentCheck):

View File

@ -11,14 +11,14 @@ import time
# Custom modules
import checks.collector
import jmxfetch
import monagent.common.check_status
import monagent.common.config
import monagent.common.daemon
import monagent.common.emitter
import monagent.common.util
import monasca_agent.common.check_status
import monasca_agent.common.config
import monasca_agent.common.daemon
import monasca_agent.common.emitter
import monasca_agent.common.util
# set up logging before importing any other components
monagent.common.config.initialize_logging('collector')
monasca_agent.common.config.initialize_logging('collector')
os.umask(0o22)
# Check we're not using an old version of Python. We need 2.4 above because
@ -39,14 +39,14 @@ log = logging.getLogger('collector')
# todo the collector has daemon code but is always run in foreground mode
# from the supervisor, is there a reason for the daemon code then?
class CollectorDaemon(monagent.common.daemon.Daemon):
class CollectorDaemon(monasca_agent.common.daemon.Daemon):
"""The agent class is a daemon that runs the collector in a background process.
"""
def __init__(self, pidfile, autorestart, start_event=True):
monagent.common.daemon.Daemon.__init__(self, pidfile, autorestart=autorestart)
monasca_agent.common.daemon.Daemon.__init__(self, pidfile, autorestart=autorestart)
self.run_forever = True
self.collector = None
self.start_event = start_event
@ -68,7 +68,7 @@ class CollectorDaemon(monagent.common.daemon.Daemon):
def info(self, verbose=None):
logging.getLogger().setLevel(logging.ERROR)
return monagent.common.check_status.CollectorStatus.print_latest_status(verbose=verbose)
return monasca_agent.common.check_status.CollectorStatus.print_latest_status(verbose=verbose)
def run(self, config=None):
"""Main loop of the collector.
@ -85,15 +85,15 @@ class CollectorDaemon(monagent.common.daemon.Daemon):
signal.signal(signal.SIGINT, self._handle_sigterm)
# Save the agent start-up stats.
monagent.common.check_status.CollectorStatus().persist()
monasca_agent.common.check_status.CollectorStatus().persist()
# Intialize the collector.
if config is None:
config = monagent.common.config.get_config(parse_args=True)
config = monasca_agent.common.config.get_config(parse_args=True)
# Load the checks_d checks
checksd = monagent.common.config.load_check_directory(config)
self.collector = checks.collector.Collector(config, monagent.common.emitter.http_emitter, checksd)
checksd = monasca_agent.common.config.load_check_directory(config)
self.collector = checks.collector.Collector(config, monasca_agent.common.emitter.http_emitter, checksd)
# Configure the watchdog.
check_frequency = int(config['check_freq'])
@ -147,7 +147,7 @@ class CollectorDaemon(monagent.common.daemon.Daemon):
# Now clean-up.
try:
monagent.common.check_status.CollectorStatus.remove_latest_status()
monasca_agent.common.check_status.CollectorStatus.remove_latest_status()
except Exception:
pass
@ -160,7 +160,7 @@ class CollectorDaemon(monagent.common.daemon.Daemon):
def _get_watchdog(check_freq, agentConfig):
watchdog = None
if agentConfig.get("watchdog", True):
watchdog = monagent.common.util.Watchdog(check_freq * WATCHDOG_MULTIPLIER,
watchdog = monasca_agent.common.util.Watchdog(check_freq * WATCHDOG_MULTIPLIER,
max_mem_mb=agentConfig.get('limit_memory_consumption',
None))
watchdog.reset()
@ -175,12 +175,12 @@ class CollectorDaemon(monagent.common.daemon.Daemon):
log.info("Running an auto-restart.")
if self.collector:
self.collector.stop()
sys.exit(monagent.common.daemon.AgentSupervisor.RESTART_EXIT_STATUS)
sys.exit(monasca_agent.common.daemon.AgentSupervisor.RESTART_EXIT_STATUS)
def main():
options, args = monagent.common.config.get_parsed_args()
agentConfig = monagent.common.config.get_config(options=options)
options, args = monasca_agent.common.config.get_parsed_args()
agentConfig = monasca_agent.common.config.get_config(options=options)
# todo autorestart isn't used remove
autorestart = agentConfig.get('autorestart', False)
@ -206,7 +206,7 @@ def main():
sys.stderr.write("Unknown command: %s\n" % command)
return 3
pid_file = monagent.common.util.PidFile('monasca-agent')
pid_file = monasca_agent.common.util.PidFile('monasca-agent')
if options.clean:
pid_file.clean()
@ -214,7 +214,7 @@ def main():
agent = CollectorDaemon(pid_file.get_path(), autorestart)
if command in START_COMMANDS:
log.info('Agent version %s' % monagent.common.config.get_version())
log.info('Agent version %s' % monasca_agent.common.config.get_version())
if 'start' == command:
log.info('Start daemon')
@ -246,14 +246,14 @@ def main():
def parent_func():
agent.start_event = False
monagent.common.daemon.AgentSupervisor.start(parent_func, child_func)
monasca_agent.common.daemon.AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.run(config=agentConfig)
elif 'check' == command:
check_name = args[1]
checks = monagent.common.config.load_check_directory(agentConfig)
checks = monasca_agent.common.config.load_check_directory(agentConfig)
for check in checks['initialized_checks']:
if check.name == check_name:
check.run()
@ -268,7 +268,7 @@ def main():
elif 'check_all' == command:
print("Loading check directory...")
checks = monagent.common.config.load_check_directory(agentConfig)
checks = monasca_agent.common.config.load_check_directory(agentConfig)
print("...directory loaded.\n")
for check in checks['initialized_checks']:
print("#" * 80)
@ -279,12 +279,12 @@ def main():
print("#" * 80 + "\n\n")
elif 'configcheck' == command or 'configtest' == command:
osname = monagent.common.util.get_os()
osname = monasca_agent.common.util.get_os()
all_valid = True
for conf_path in glob.glob(os.path.join(monagent.common.config.get_confd_path(osname), "*.yaml")):
for conf_path in glob.glob(os.path.join(monasca_agent.common.config.get_confd_path(osname), "*.yaml")):
basename = os.path.basename(conf_path)
try:
monagent.common.config.check_yaml(conf_path)
monasca_agent.common.config.check_yaml(conf_path)
except Exception as e:
all_valid = False
print("%s contains errors:\n %s" % (basename, e))
@ -316,11 +316,11 @@ def main():
else:
jmx_command = args[1]
checks_list = args[2:]
confd_directory = monagent.common.config.get_confd_path(monagent.common.util.get_os())
confd_directory = monasca_agent.common.config.get_confd_path(monasca_agent.common.util.get_os())
should_run = jmxfetch.JMXFetch.init(
confd_directory,
agentConfig,
monagent.common.config.get_logging_config(),
monasca_agent.common.config.get_logging_config(),
15,
jmx_command,
checks_list,

View File

@ -1,7 +1,7 @@
from datetime import datetime
import re
from monagent.collector.dogstream import common
from monasca_agent.collector.dogstream import common
LOG4J_PRIORITY = [

View File

@ -8,7 +8,7 @@ import time
import yaml
import monagent.common.util
import monasca_agent.common.util
log = logging.getLogger(__name__)
@ -50,7 +50,7 @@ class InvalidJMXConfiguration(Exception):
class JMXFetch(object):
pid_file = monagent.common.util.PidFile("jmxfetch")
pid_file = monasca_agent.common.util.PidFile("jmxfetch")
pid_file_path = pid_file.get_path()
@classmethod
@ -234,7 +234,7 @@ class JMXFetch(object):
except Exception:
return False
if monagent.common.util.get_os() != 'windows':
if monasca_agent.common.util.get_os() != 'windows':
try:
os.kill(pid, 0)
# os.kill(pid, 0) will throw an exception if pid is not running
@ -290,7 +290,7 @@ class JMXFetch(object):
@classmethod
def get_path_to_jmxfetch(cls):
if monagent.common.util.get_os() != 'windows':
if monasca_agent.common.util.get_os() != 'windows':
return os.path.realpath(
os.path.join(os.path.abspath(__file__), "..", "../collector/checks", "libs",
JMX_FETCH_JAR_NAME))
@ -301,7 +301,7 @@ class JMXFetch(object):
@classmethod
def start(cls, confd_path, agentConfig, logging_config, path_to_java, java_run_opts,
default_check_frequency, jmx_checks, command, reporter=None):
statsd_port = agentConfig.get('monstatsd_port', "8125")
statsd_port = agentConfig.get('monasca_statsd_port', "8125")
if reporter is None:
reporter = "statsd:%s" % str(statsd_port)

View File

@ -18,8 +18,8 @@
from oslo.utils import units
from monagent.collector.virt.hyperv import utilsv2
from monagent.collector.virt import inspector as virt_inspector
from monasca_agent.collector.virt.hyperv import utilsv2
from monasca_agent.collector.virt import inspector as virt_inspector
class HyperVInspector(virt_inspector.Inspector):

View File

@ -25,7 +25,7 @@ import sys
if sys.platform == 'win32':
import wmi
from monagent.collector.virt import inspector
from monasca_agent.collector.virt import inspector
class HyperVException(inspector.InspectorException):

View File

@ -215,7 +215,7 @@ class Inspector(object):
def get_hypervisor_inspector():
try:
namespace = 'monagent.collector.virt'
namespace = 'monasca_agent.collector.virt'
mgr = driver.DriverManager(namespace,
cfg.CONF.hypervisor_inspector,
invoke_on_load=True)

View File

@ -20,7 +20,7 @@ from lxml import etree
from oslo.config import cfg
import six
from monagent.collector.virt import inspector as virt_inspector
from monasca_agent.collector.virt import inspector as virt_inspector
libvirt = None

View File

@ -19,8 +19,8 @@ from oslo.config import cfg
from oslo.utils import units
from oslo.vmware import api
from monagent.collector.virt import inspector as virt_inspector
from monagent.collector.virt.vmware import vsphere_operations
from monasca_agent.collector.virt import inspector as virt_inspector
from monasca_agent.collector.virt.vmware import vsphere_operations
opt_group = cfg.OptGroup(name='vmware',

View File

@ -24,7 +24,7 @@ except ImportError:
api = None
from ceilometer.compute.pollsters import util
from monagent.collector.virt import inspector as virt_inspector
from monasca_agent.collector.virt import inspector as virt_inspector
opt_group = cfg.OptGroup(name='xenapi',
title='Options for XenAPI')

View File

@ -1,9 +1,9 @@
""" Aggregation classes used by the collector and monstatsd to batch messages sent to the forwarder.
""" Aggregation classes used by the collector and statsd to batch messages sent to the forwarder.
"""
import logging
from time import time
from monagent.common.metrics import Gauge, BucketGauge, Counter, Histogram, Measurement, Set, Rate
from monasca_agent.common.metrics import Gauge, BucketGauge, Counter, Histogram, Measurement, Set, Rate
log = logging.getLogger(__name__)

View File

@ -512,9 +512,9 @@ class CollectorStatus(AgentStatus):
return status_info
class MonstatsdStatus(AgentStatus):
class MonascaStatsdStatus(AgentStatus):
NAME = 'Monstatsd'
NAME = 'Monasca_Statsd'
def __init__(self, flush_count=0, packet_count=0,
packets_per_second=0, metric_count=0, event_count=0):

View File

@ -25,7 +25,7 @@ except ImportError:
# project
from util import get_os
from monagent.collector.jmxfetch import JMXFetch, JMX_COLLECT_COMMAND
from monasca_agent.collector.jmxfetch import JMXFetch, JMX_COLLECT_COMMAND
# CONSTANTS
AGENT_CONF = "agent.conf"
@ -190,10 +190,10 @@ def get_config(parse_args=True, cfg_path=None, options=None):
# General config
agent_config = {
'check_freq': DEFAULT_CHECK_FREQUENCY,
'monstatsd_interval': DEFAULT_STATSD_FREQUENCY,
'monstatsd_agregator_bucket_size': DEFAULT_STATSD_BUCKET_SIZE,
'monstatsd_normalize': 'yes',
'monstatsd_port': 8125,
'monasca_statsd_interval': DEFAULT_STATSD_FREQUENCY,
'monasca_statsd_agregator_bucket_size': DEFAULT_STATSD_BUCKET_SIZE,
'monasca_statsd_normalize': 'yes',
'monasca_statsd_port': 8125,
'forwarder_url': 'http://localhost:17123',
'hostname': None,
'listen_port': None,
@ -202,8 +202,8 @@ def get_config(parse_args=True, cfg_path=None, options=None):
'additional_checksd': DEFAULT_CONFIG_DIR + '/checks_d/',
}
monstatsd_interval = DEFAULT_STATSD_FREQUENCY
monstatsd_agregator_bucket_size = DEFAULT_STATSD_BUCKET_SIZE
monasca_statsd_interval = DEFAULT_STATSD_FREQUENCY
monasca_statsd_agregator_bucket_size = DEFAULT_STATSD_BUCKET_SIZE
# Config handling
try:
@ -258,14 +258,14 @@ def get_config(parse_args=True, cfg_path=None, options=None):
if config.get('Main', 'watchdog').lower() in ('no', 'false'):
agent_config['watchdog'] = False
# monstatsd config
monstatsd_defaults = {
'monstatsd_port': 8125,
'monstatsd_interval': monstatsd_interval,
'monstatsd_agregator_bucket_size': monstatsd_agregator_bucket_size,
'monstatsd_normalize': 'yes',
# monasca_statsd config
monasca_statsd_defaults = {
'monasca_statsd_port': 8125,
'monasca_statsd_interval': monasca_statsd_interval,
'monasca_statsd_agregator_bucket_size': monasca_statsd_agregator_bucket_size,
'monasca_statsd_normalize': 'yes',
}
for key, value in monstatsd_defaults.iteritems():
for key, value in monasca_statsd_defaults.iteritems():
if config.has_option('Main', key):
agent_config[key] = config.get('Main', key)
else:
@ -278,8 +278,8 @@ def get_config(parse_args=True, cfg_path=None, options=None):
agent_config['statsd_forward_port'] = int(config.get('Main', 'statsd_forward_port'))
# normalize 'yes'/'no' to boolean
monstatsd_defaults['monstatsd_normalize'] = _is_affirmative(
monstatsd_defaults['monstatsd_normalize'])
monasca_statsd_defaults['monasca_statsd_normalize'] = _is_affirmative(
monasca_statsd_defaults['monasca_statsd_normalize'])
# Optional config
# FIXME not the prettiest code ever...
@ -511,7 +511,7 @@ def load_check_directory(agent_config):
''' Return the initialized checks from checks_d, and a mapping of checks that failed to
initialize. Only checks that have a configuration
file in conf.d will be returned. '''
from monagent.collector.checks import AgentCheck
from monasca_agent.collector.checks import AgentCheck
initialized_checks = {}
init_failed_checks = {}
@ -680,7 +680,7 @@ def get_logging_config(cfg_path=None):
'log_level': None,
'collector_log_file': DEFAULT_LOG_DIR + '/collector.log',
'forwarder_log_file': DEFAULT_LOG_DIR + '/forwarder.log',
'monstatsd_log_file': DEFAULT_LOG_DIR + '/monstatsd.log',
'statsd_log_file': DEFAULT_LOG_DIR + '/statsd.log',
'jmxfetch_log_file': DEFAULT_LOG_DIR + '/jmxfetch.log',
'log_to_event_viewer': False,
'log_to_syslog': True,

View File

@ -2,7 +2,7 @@ from hashlib import md5
import json
import urllib2
from monagent.common.metrics import Measurement
from monasca_agent.common.metrics import Measurement
def post_headers(payload):
@ -24,7 +24,7 @@ def http_emitter(message, log, url):
partial_payload = []
for measurement in message:
if not isinstance(measurement, Measurement):
log.error('Data was not in the form of a monagent.common.metrics.Measurement')
log.error('Data was not in the form of a monasca_agent.common.metrics.Measurement')
continue
# Measurements need their __dict__ encoded to avoid being expressed as a tuple
partial_payload.append(measurement.__dict__)

View File

@ -4,7 +4,7 @@ from collections import namedtuple
import logging
from time import time
from monagent.common.exceptions import Infinity, UnknownValue
from monasca_agent.common.exceptions import Infinity, UnknownValue
log = logging.getLogger(__name__)

View File

@ -144,7 +144,7 @@ def get_hostname(config=None):
# first, try the config
if config is None:
from monagent.common.config import get_config
from monasca_agent.common.config import get_config
config = get_config(parse_args=True)
config_hostname = config.get('hostname')
if config_hostname and is_valid_hostname(config_hostname):

View File

@ -3,8 +3,8 @@ import logging
from collections import deque
from monascaclient import exc as exc, client
from monagent.common.keystone import Keystone
from monagent.common.util import get_hostname
from monasca_agent.common.keystone import Keystone
from monasca_agent.common.util import get_hostname
import requests

View File

@ -11,11 +11,11 @@
"""
# set up logging before importing any other components
from monagent.common.config import initialize_logging
from monagent.forwarder.api.mon import MonAPI
from monasca_agent.common.config import initialize_logging
from monasca_agent.forwarder.api.mon import MonAPI
initialize_logging('forwarder')
from monagent.common.config import get_logging_config
from monasca_agent.common.config import get_logging_config
import os
os.umask(0o22)
@ -36,10 +36,10 @@ from tornado.escape import json_decode
from tornado.options import define, parse_command_line, options
# agent import
from monagent.common.check_status import ForwarderStatus
from monagent.common.config import get_config
from monagent.common.metrics import Measurement
from monagent.common.util import Watchdog, get_tornado_ioloop
from monasca_agent.common.check_status import ForwarderStatus
from monasca_agent.common.config import get_config
from monasca_agent.common.metrics import Measurement
from monasca_agent.common.util import Watchdog, get_tornado_ioloop
from transaction import Transaction, TransactionManager
log = logging.getLogger('forwarder')
@ -137,7 +137,7 @@ class AgentInputHandler(tornado.web.RequestHandler):
"""
# read the message it should be a list of
# monagent.common.metrics.Measurements expressed as a dict
# monasca_agent.common.metrics.Measurements expressed as a dict
msg = tornado.escape.json_decode(self.request.body)
try:
measurements = [Measurement(**m) for m in msg]

View File

@ -6,8 +6,8 @@ import logging
from operator import attrgetter
# project
from monagent.common.check_status import ForwarderStatus
from monagent.common.util import get_tornado_ioloop, plural
from monasca_agent.common.check_status import ForwarderStatus
from monasca_agent.common.util import get_tornado_ioloop, plural
log = logging.getLogger(__name__)

View File

@ -4,11 +4,11 @@ A Python Statsd implementation with dimensions added
"""
# set up logging before importing any other components
from monagent.common.config import initialize_logging
from monagent.monstatsd.reporter import Reporter
from monagent.monstatsd.udp import Server
from monasca_agent.common.config import initialize_logging
from monasca_agent.statsd.reporter import Reporter
from monasca_agent.statsd.udp import Server
initialize_logging('monstatsd')
initialize_logging('monasca_statsd')
import os
os.umask(0o22)
@ -20,18 +20,18 @@ import signal
import sys
# project
from monagent.common.aggregator import MetricsBucketAggregator
from monagent.common.check_status import MonstatsdStatus
from monagent.common.config import get_config
from monagent.common.daemon import Daemon, AgentSupervisor
from monagent.common.util import PidFile, get_hostname
from monasca_agent.common.aggregator import MetricsBucketAggregator
from monasca_agent.common.check_status import MonascaStatsdStatus
from monasca_agent.common.config import get_config
from monasca_agent.common.daemon import Daemon, AgentSupervisor
from monasca_agent.common.util import PidFile, get_hostname
log = logging.getLogger('monstatsd')
log = logging.getLogger('monasca_statsd')
class Monstatsd(Daemon):
class MonascaStatsd(Daemon):
""" This class is the monstatsd daemon. """
""" This class is the monasca_statsd daemon. """
def __init__(self, pid_file, server, reporter, autorestart):
Daemon.__init__(self, pid_file, autorestart=autorestart)
@ -63,25 +63,25 @@ class Monstatsd(Daemon):
# the reporting thread.
self.reporter.stop()
self.reporter.join()
log.info("Monstatsd is stopped")
log.info("monasca_statsd is stopped")
# Restart if asked to restart
if self.autorestart:
sys.exit(AgentSupervisor.RESTART_EXIT_STATUS)
def info(self):
logging.getLogger().setLevel(logging.ERROR)
return MonstatsdStatus.print_latest_status()
return MonascaStatsdStatus.print_latest_status()
def init_monstatsd(config_path=None, use_watchdog=False):
def init_monasca_statsd(config_path=None, use_watchdog=False):
"""Configure the server and the reporting thread.
"""
c = get_config(parse_args=False, cfg_path=config_path)
log.debug("Configuration monstatsd")
log.debug("Configuration monasca_statsd")
port = c['monstatsd_port']
interval = int(c['monstatsd_interval'])
aggregator_interval = int(c['monstatsd_agregator_bucket_size'])
port = c['monasca_statsd_port']
interval = int(c['monasca_statsd_interval'])
aggregator_interval = int(c['monasca_statsd_agregator_bucket_size'])
non_local_traffic = c['non_local_traffic']
forward_to_host = c.get('statsd_forward_host')
forward_to_port = c.get('statsd_forward_port')
@ -119,13 +119,13 @@ def init_monstatsd(config_path=None, use_watchdog=False):
def main(config_path=None):
""" The main entry point for the unix version of monstatsd. """
""" The main entry point for the unix version of monasca_statsd. """
parser = optparse.OptionParser("%prog [start|stop|restart|status]")
opts, args = parser.parse_args()
reporter, server, cnf = init_monstatsd(config_path, use_watchdog=True)
pid_file = PidFile('monstatsd')
daemon = Monstatsd(pid_file.get_path(), server, reporter,
reporter, server, cnf = init_monasca_statsd(config_path, use_watchdog=True)
pid_file = PidFile('monasca_statsd')
daemon = monasca_statsd(pid_file.get_path(), server, reporter,
cnf.get('autorestart', False))
# If no args were passed in, run the server in the foreground.

View File

@ -1,12 +1,12 @@
import json
import logging
import threading
from monagent.common.check_status import MonstatsdStatus
from monagent.common.emitter import http_emitter
from monagent.common.util import plural
from monagent.common.config import initialize_logging
initialize_logging('monstatsd')
log = logging.getLogger('monstatsd')
from monasca_agent.common.check_status import MonascaStatsdStatus
from monasca_agent.common.emitter import http_emitter
from monasca_agent.common.util import plural
from monasca_agent.common.config import initialize_logging
initialize_logging('monasca_statsd')
log = logging.getLogger('monasca_statsd')
WATCHDOG_TIMEOUT = 120
@ -35,7 +35,7 @@ class Reporter(threading.Thread):
self.watchdog = None
if use_watchdog:
from monagent.common.util import Watchdog
from monasca_agent.common.util import Watchdog
self.watchdog = Watchdog(WATCHDOG_TIMEOUT)
self.api_host = api_host
@ -55,7 +55,7 @@ class Reporter(threading.Thread):
log.debug("Watchdog enabled: %s" % bool(self.watchdog))
# Persist a start-up message.
MonstatsdStatus().persist()
MonascaStatsdStatus().persist()
while not self.finished.isSet(): # Use camel case isSet for 2.4 support.
self.finished.wait(self.interval)
@ -65,7 +65,7 @@ class Reporter(threading.Thread):
# Clean up the status messages.
log.debug("Stopped reporter")
MonstatsdStatus.remove_latest_status()
MonascaStatsdStatus.remove_latest_status()
def flush(self):
try:
@ -106,7 +106,7 @@ class Reporter(threading.Thread):
# Persist a status message.
packet_count = self.aggregator.total_count
packets_per_second = self.aggregator.packets_per_second(self.interval)
MonstatsdStatus(
MonascaStatsdStatus(
flush_count=self.flush_count,
packet_count=packet_count,
packets_per_second=packets_per_second,

View File

@ -2,9 +2,9 @@ import ast
import logging
import select
import socket
from monagent.common.config import initialize_logging
initialize_logging('monstatsd')
log = logging.getLogger('monstatsd')
from monasca_agent.common.config import initialize_logging
initialize_logging('monasca_statsd')
log = logging.getLogger('monasca_statsd')
UDP_SOCKET_TIMEOUT = 5

View File

@ -1,8 +1,8 @@
# set up logging before importing any other components
from config import initialize_logging
from monagent.pup import pup
from monasca_agent.pup import pup
from collector import modules
from monstatsd import dogstatsd
from monasca_agent.statsd import daemon
initialize_logging('collector')
@ -21,16 +21,16 @@ from ddagent import Application
from win32.common import handle_exe_click
from collector.jmxfetch import JMXFetch
from monagent.common.config import get_config, load_check_directory, set_win32_cert_path
from monasca_agent.common.config import get_config, load_check_directory, set_win32_cert_path
log = logging.getLogger(__name__)
RESTART_INTERVAL = 24 * 60 * 60 # Defaults to 1 day
class AgentSvc(win32serviceutil.ServiceFramework):
_svc_name_ = "DatadogAgent"
_svc_display_name_ = "Datadog Agent"
_svc_description_ = "Sends metrics to Datadog"
_svc_name_ = "MonascaAgent"
_svc_display_name_ = "Monasca Agent"
_svc_description_ = "Sends metrics to Monasca"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
@ -50,10 +50,9 @@ class AgentSvc(win32serviceutil.ServiceFramework):
# Keep a list of running processes so we can start/end as needed.
# Processes will start started in order and stopped in reverse order.
self.procs = {
'forwarder': DDForwarder(config),
'collector': DDAgent(agentConfig),
'dogstatsd': DogstatsdProcess(config),
'pup': PupProcess(config),
'monasca-forwarder': MonascaForwarder(config),
'monasca-collector': MonascaCollector(agentConfig),
'monasca-statsd': MonascaStatsd(config),
}
def SvcStop(self):
@ -107,10 +106,10 @@ class AgentSvc(win32serviceutil.ServiceFramework):
time.sleep(1)
class DDAgent(multiprocessing.Process):
class MonascaCollector(multiprocessing.Process):
def __init__(self, agentConfig, start_event=True):
multiprocessing.Process.__init__(self, name='ddagent')
multiprocessing.Process.__init__(self, name='monasca-collector')
self.config = agentConfig
self.start_event = start_event
# FIXME: `running` flag should be handled by the service
@ -118,7 +117,7 @@ class DDAgent(multiprocessing.Process):
self.is_enabled = True
def run(self):
log.debug("Windows Service - Starting collector")
log.debug("Windows Service - Starting monasca-collector")
emitters = self.get_emitters()
self.collector = Collector(self.config, emitters)
@ -131,7 +130,7 @@ class DDAgent(multiprocessing.Process):
time.sleep(self.config['check_freq'])
def stop(self):
log.debug("Windows Service - Stopping collector")
log.debug("Windows Service - Stopping monasca-collector")
self.collector.stop()
if JMXFetch.is_running():
JMXFetch.stop()
@ -149,15 +148,15 @@ class DDAgent(multiprocessing.Process):
return emitters
class DDForwarder(multiprocessing.Process):
class MonascaForwarder(multiprocessing.Process):
def __init__(self, agentConfig):
multiprocessing.Process.__init__(self, name='ddforwarder')
multiprocessing.Process.__init__(self, name='monasca-forwarder')
self.config = agentConfig
self.is_enabled = True
def run(self):
log.debug("Windows Service - Starting forwarder")
log.debug("Windows Service - Starting monasca-forwarder")
set_win32_cert_path()
port = self.config.get('listen_port', 17123)
if port is None:
@ -169,48 +168,30 @@ class DDForwarder(multiprocessing.Process):
self.forwarder.run()
def stop(self):
log.debug("Windows Service - Stopping forwarder")
log.debug("Windows Service - Stopping monasca-forwarder")
self.forwarder.stop()
class DogstatsdProcess(multiprocessing.Process):
class MonascaStatsdProcess(multiprocessing.Process):
def __init__(self, agentConfig):
multiprocessing.Process.__init__(self, name='dogstatsd')
multiprocessing.Process.__init__(self, name='monasca-statsd')
self.config = agentConfig
self.is_enabled = True
def run(self):
log.debug("Windows Service - Starting Monstatsd server")
self.reporter, self.server, _ = dogstatsd.init()
log.debug("Windows Service - Starting monasca-statsd server")
self.reporter, self.server, _ = daemon.init_monasca_statsd()
self.reporter.start()
self.server.start()
def stop(self):
log.debug("Windows Service - Stopping Monstatsd server")
log.debug("Windows Service - Stopping monasca-statsd server")
self.server.stop()
self.reporter.stop()
self.reporter.join()
class PupProcess(multiprocessing.Process):
def __init__(self, agentConfig):
multiprocessing.Process.__init__(self, name='pup')
self.config = agentConfig
self.is_enabled = self.config.get('use_web_info_page', True)
def run(self):
self.pup = pup
if self.is_enabled:
log.debug("Windows Service - Starting Pup")
self.pup.run_pup(self.config)
def stop(self):
if self.is_enabled:
log.debug("Windows Service - Stopping Pup")
self.pup.stop()
if __name__ == '__main__':
multiprocessing.freeze_support()
if len(sys.argv) == 1:

Some files were not shown because too many files have changed in this diff Show More