コード例 #1
0
ファイル: metrics.py プロジェクト: irslambouf/SyncServer
def MetlogLoader(**kwargs):
    # Delegates to metlog-py's client configuration functions
    cfgfilepath = kwargs['config']
    with open(cfgfilepath) as cfgfile:
        metlog = client_from_stream_config(cfgfile, 'metlog')
        CLIENT_HOLDER.set_client(metlog.logger, metlog)
    return CLIENT_HOLDER
コード例 #2
0
ファイル: command.py プロジェクト: dev-zero/metlog-py
def mb():
    arguments = docopt(mb_doc)
    host = arguments.get('HOST')
    port = int(arguments.get('PORT'))

    DEFAULT_CONFIG = {'logger': 'mb',
                      'sender': {'class': 'metlog.senders.udp.UdpSender',
                                 'args': (host, port),
                                 },
                      }

    if arguments.get('--raw'):
        udpsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        utcnow = datetime.utcnow()
        if utcnow.microsecond == 0:
            timestamp = "%s.000000Z" % utcnow.isoformat()
        else:
            timestamp = "%sZ" % utcnow.isoformat()
        msg = {"severity": 6, "timestamp": timestamp,
               "metlog_hostname": "spire",
               "fields": {"userid": 25, "req_time": 4}, "metlog_pid": 34328,
               "logger": "syncstorage", "type": "services", "payload": "foo",
               "env_version": "0.8"}
        json_msg = json.dumps(msg)
        while True:
            udpsock.sendto(json_msg, (host, port))

    if arguments.get('--metlogcfg'):
        with open(arguments['--metlogcfg']) as cfgfile:
            client = client_from_stream_config(cfgfile, 'metlog')
    else:
        client = client_from_dict_config(DEFAULT_CONFIG)

    while True:
        client.metlog('MBTEST', payload='MBTEST')
コード例 #3
0
def MetlogLoader(**kwargs):
    # Delegates to metlog-py's client configuration functions
    cfgfilepath = kwargs['config']
    with open(cfgfilepath) as cfgfile:
        metlog = client_from_stream_config(cfgfile, 'metlog')
        CLIENT_HOLDER.set_client(metlog.logger, metlog)
    return CLIENT_HOLDER
コード例 #4
0
ファイル: __init__.py プロジェクト: rnewman/campaign_manager
def main(global_config, **settings):
    load_into_settings(global_config['__file__'], settings)
    config = Configurator(root_factory=Root, settings=settings)
    config.include("cornice")
    config.include("pyramid_beaker")
    config.include("mozsvc")
    config.scan("campaign.views")
    config.registry['storage'] = Storage(config)
    config.registry['auth'] = configure_from_settings('auth',
            settings['config'].get_map('auth'))
    metlog_client = client_from_stream_config(
            open(global_config['__file__'], 'r'),
            'metlog')
    config.registry['metlog'] = metlog_client
    return config.make_wsgi_app()
コード例 #5
0
def mb():
    arguments = docopt(mb_doc)
    host = arguments.get('HOST')
    port = int(arguments.get('PORT'))

    DEFAULT_CONFIG = {
        'logger': 'mb',
        'sender': {
            'class': 'metlog.senders.udp.UdpSender',
            'args': (host, port),
        },
    }

    if arguments.get('--raw'):
        udpsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        utcnow = datetime.utcnow()
        if utcnow.microsecond == 0:
            timestamp = "%s.000000Z" % utcnow.isoformat()
        else:
            timestamp = "%sZ" % utcnow.isoformat()
        msg = {
            "severity": 6,
            "timestamp": timestamp,
            "metlog_hostname": "spire",
            "fields": {
                "userid": 25,
                "req_time": 4
            },
            "metlog_pid": 34328,
            "logger": "syncstorage",
            "type": "services",
            "payload": "foo",
            "env_version": "0.8"
        }
        json_msg = json.dumps(msg)
        while True:
            udpsock.sendto(json_msg, (host, port))

    if arguments.get('--metlogcfg'):
        with open(arguments['--metlogcfg']) as cfgfile:
            client = client_from_stream_config(cfgfile, 'metlog')
    else:
        client = client_from_dict_config(DEFAULT_CONFIG)

    while True:
        client.metlog('MBTEST', payload='MBTEST')
コード例 #6
0
ファイル: logger.py プロジェクト: lazaroj/campaign_manager
 def __init__(self, config, settings_file):
     global METLOG, BOTO
     settings = config.get_settings()
     self.logger = logging.getLogger(
         settings.get('logging.name', 'campaign-manager'))
     self.logger.level = 1
     if METLOG and settings.get('logging.use_metlog', True):
         self.metlog = client_from_stream_config(
             open(settings_file, 'r'),
             'metlog')
     else:
         METLOG = False
     if BOTO:
         try:
             self.boto = boto.connect_sdb(settings.get('aws.key'),
                                          settings.get('aws.secret')).\
                 lookup(settings.get('aws.domain'))
         except Exception, e:
             import pdb; pdb.set_trace()
             BOTO = False
コード例 #7
0
 def __init__(self, config, settings_file):
     global METLOG, BOTO
     settings = config.get_settings()
     self.logger = logging.getLogger(
         settings.get('logging.name', 'campaign-manager'))
     self.logger.level = 1
     if METLOG and settings.get('logging.use_metlog', True):
         self.metlog = client_from_stream_config(open(settings_file, 'r'),
                                                 'metlog')
     else:
         METLOG = False
     if BOTO:
         try:
             self.boto = boto.connect_sdb(settings.get('aws.key'),
                                          settings.get('aws.secret')).\
                 lookup(settings.get('aws.domain'))
         except Exception, e:
             import pdb
             pdb.set_trace()
             BOTO = False
コード例 #8
0
'''
from ConfigParser import SafeConfigParser
import argparse
from metlog.config import client_from_stream_config
import datetime
import time

parser = argparse.ArgumentParser(description="Upload JSON logs to HDFS")
parser.add_argument('--config',
        type=argparse.FileType('r'),
        required=True)

parsed_args = parser.parse_args()

cfg = SafeConfigParser()
client = client_from_stream_config(parsed_args.config, 'metlog')


def send_incr_pegs():
    """
    Just a check for increment counts
    """
    cluster_name = 'colo1'
    host_name = 'mozhost2'
    for k in ['syncstorage.request_rate.200',
            'syncstorage.request_rate.302',
            'syncstorage.request_rate.401',
            'syncstorage.request_rate.404',
            'syncstorage.request_rate.503']:

        print "Sending: %s" % k