else:
        print "%s is not running" % program
        raise SystemExit(0)

elif action != 'start':
    parser.print_usage()
    raise SystemExit(1)

if exists(options.pidfile):
    print "Pidfile %s already exists, is %s already running?" % (
        options.pidfile, program)
    raise SystemExit(1)

# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings
settings.readFrom(options.config, 'aggregator')

# Import application components
from carbon.log import logToStdout, logToDir
from carbon.instrumentation import startRecording
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, startListener
from carbon.aggregator.rules import RuleManager
from carbon.aggregator import receiver
from carbon.aggregator import client
from carbon.rewrite import RewriteRuleManager
from carbon.events import metricReceived
from carbon.util import daemonize

RuleManager.read_from(options.rules)

rewrite_rules_conf = join(CONF_DIR, 'rewrite-rules.conf')
示例#2
0
        print "%s (instance %s) is not running" % (program, instance)
        raise SystemExit(0)

elif action != 'start':
    parser.print_usage()
    raise SystemExit(1)

if exists(pidfile):
    print "Pidfile %s already exists, is %s already running?" % (pidfile,
                                                                 program)
    raise SystemExit(1)

# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings

settings.readFrom(config, 'cache')

if instance:
    settings.readFrom(config, 'cache:%s' % instance)

# Import application components
from carbon.log import logToStdout, logToDir
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, CacheQueryHandler, startListener
from carbon.cache import MetricCache
from carbon.instrumentation import startRecording
from carbon.events import metricReceived

storage_schemas = join(CONF_DIR, 'storage-schemas.conf')
if not exists(storage_schemas):
    print "Error: missing required config %s" % storage_schemas
    sys.exit(1)
示例#3
0
        print('Usage: python graphite-router.py -k <metric key>')
        sys.exit()
    elif opt in ("-k", "--key"):
        metric_key = arg

# Check required key        
if not metric_key: 
    print('Usage: python graphite-router.py -k <metric key>')
    sys.exit(2)

## Settings
# Absolute path to the Graphite Data Directory
DATA_DIR = join(ROOT_DIR, 'storage/whisper')

# Parse config
settings.readFrom(join(ROOT_DIR, 'conf/carbon.conf'), 'relay')

# Read in destinations from config
destinations = util.parseDestinations(settings.DESTINATIONS)

# Setup Router
router = ConsistentHashingRouter(settings.REPLICATION_FACTOR)
 
for destination in destinations: 
    router.addDestination(destination);    
    
# Echo routes
print('routes for ' + metric_key) 
routes = router.getDestinations(metric_key)
for route in routes:
    print(route)
示例#4
0
    try:
        pid = int(pidfile.read().strip())
    except:
        print "Failed to read pid from %s" % options.pidfile
        raise SystemExit(1)

    if exists("/proc/%d" % pid):
        print "%s is running with pid %d" % (program, pid)
        raise SystemExit(0)
    else:
        print "%s is not running" % program
        raise SystemExit(0)


# Read config (we want failures to occur before daemonizing)
settings.readFrom(options.config, "cache")


# --debug
if options.debug:
    logToStdout()
else:
    if not isdir(options.logdir):
        os.makedirs(options.logdir)

    from carbon.util import daemonize, dropprivs

    daemonize()
    logToDir(options.logdir)

    pidfile = open(options.pidfile, "w")
示例#5
0
    print "%s is not running" % program
    raise SystemExit(0)

elif action != 'start':
  parser.print_usage()
  raise SystemExit(1)


if exists(options.pidfile):
  print "Pidfile %s already exists, is %s already running?" % (options.pidfile, program)
  raise SystemExit(1)


# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings
settings.readFrom(options.config, 'relay')

# Quick validation
if settings.RELAY_METHOD not in ('rules', 'consistent-hashing'):
  print "In carbon.conf, RELAY_METHOD must be either 'rules' or 'consistent-hashing'. Invalid value: '%s'" % settings.RELAY_METHOD
  sys.exit(1)

# Import application components
from carbon.log import logToStdout, logToDir, msg
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, startListener
from carbon.relay import createClientConnections, relay
from carbon.events import metricReceived
from carbon.instrumentation import startRecording
from carbon.rules import loadRules, allDestinationServers, parseHostList
from carbon.hashing import setDestinationHosts
示例#6
0
    print "%s is not running" % program
    raise SystemExit(0)

elif action != 'start':
  parser.print_usage()
  raise SystemExit(1)


if exists(options.pidfile):
  print "Pidfile %s already exists, is %s already running?" % (options.pidfile, program)
  raise SystemExit(1)


# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings
settings.readFrom(options.config, 'aggregator')


# Import application components
from carbon.log import logToStdout, logToDir
from carbon.instrumentation import startRecording
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, startListener
from carbon.aggregator.rules import RuleManager
from carbon.aggregator import receiver
from carbon.aggregator import client
from carbon.rewrite import RewriteRuleManager
from carbon.events import metricReceived
from carbon.util import daemonize

RuleManager.read_from(options.rules)
示例#7
0
    print "%s (instance %s) is not running" % (program, instance)
    raise SystemExit(0)

elif action != 'start':
  parser.print_usage()
  raise SystemExit(1)


if exists(pidfile):
  print "Pidfile %s already exists, is %s already running?" % (pidfile, program)
  raise SystemExit(1)


# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings
settings.readFrom(config, 'cache')

if instance:
  settings.readFrom(config, 'cache:%s' % instance)

# Import application components
from carbon.log import logToStdout, logToDir
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, CacheQueryHandler, startListener
from carbon.cache import MetricCache
from carbon.instrumentation import startRecording
from carbon.events import metricReceived

storage_schemas = join(CONF_DIR, 'storage-schemas.conf')
if not exists(storage_schemas):
  print "Error: missing required config %s" % storage_schemas
  sys.exit(1)
示例#8
0
    else:
        print "%s is not running" % program
        raise SystemExit(0)

elif action != 'start':
    parser.print_usage()
    raise SystemExit(1)

if exists(options.pidfile):
    print "Pidfile %s already exists, is %s already running?" % (
        options.pidfile, program)
    raise SystemExit(1)

# Read config (we want failures to occur before daemonizing)
from carbon.conf import settings
settings.readFrom(options.config, 'relay')

# Quick validation
if settings.RELAY_METHOD not in ('rules', 'consistent-hashing'):
    print "In carbon.conf, RELAY_METHOD must be either 'rules' or 'consistent-hashing'. Invalid value: '%s'" % settings.RELAY_METHOD
    sys.exit(1)

# Import application components
from carbon.log import logToStdout, logToDir, msg
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, startListener
from carbon.relay import createClientConnections, relay
from carbon.events import metricReceived
from carbon.instrumentation import startRecording
from carbon.rules import loadRules, allDestinationServers, parseHostList
from carbon.hashing import setDestinationHosts