How to use the graphyte.init function in graphyte

To help you get started, we’ve selected a few graphyte examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jetsetter / graphyte / test_graphyte.py View on Github external
def test_send_socket(self):
        graphyte.init('127.0.0.1')
        graphyte.send('foo', 42, timestamp=12345)
        graphyte.send('bar', 43.5, timestamp=12346)
        self.server.handle_request()
        self.server.handle_request()
        self.assertEqual(TestHandler.pop_message(), b'foo 42 12345\n')
        self.assertEqual(TestHandler.pop_message(), b'bar 43.5 12346\n')
github Jetsetter / graphyte / test_graphyte.py View on Github external
def test_send_socket(self):
        graphyte.init('127.0.0.1', protocol='udp')
        graphyte.send('foo', 42, timestamp=12345)
        graphyte.send('bar', 43.5, timestamp=12346)
        self.server.handle_request()
        self.server.handle_request()
        self.assertEqual(TestHandler.pop_message(), b'foo 42 12345\n')
        self.assertEqual(TestHandler.pop_message(), b'bar 43.5 12346\n')
github earthgecko / skyline / skyline / flux / populate_metric_worker.py View on Github external
# @added 20191010 - Feature #3250: Allow Skyline to send metrics to another Carbon host
# Added missing skyline_app required for send_graphite_metric
skyline_app = 'flux'

skyline_app_graphite_namespace = 'skyline.%s%s.populate_metric_worker' % (parent_skyline_app, SERVER_METRIC_PATH)

LOCAL_DEBUG = False

GRAPHITE_METRICS_PREFIX = None
CARBON_HOST = settings.FLUX_CARBON_HOST
CARBON_PORT = settings.FLUX_CARBON_PORT
FLUX_CARBON_PICKLE_PORT = settings.FLUX_CARBON_PICKLE_PORT

if settings.FLUX_SEND_TO_CARBON:
    try:
        graphyte.init(CARBON_HOST, port=CARBON_PORT, prefix=None, timeout=5)
        logger.info('populate_metric_worker :: succeeded to graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))
    except:
        logger.error(traceback.format_exc())
        logger.error('error :: populate_metric_worker :: failed to run graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))


class PopulateMetricWorker(Process):
    """
    The worker grabs metrics from the queue, surfaces the data from the remote
    Graphite and sends them to the Skyline Graphite.
    """
    def __init__(self, queue, parent_pid):
github sammoorhouse / watchful-eye / src / process.py View on Github external
def main():
    telemetry_target_host = os.getenv('TELEMETRY_TARGET_HOST')
    telemetry_target_port = int(os.getenv('TELEMETRY_TARGET_PORT', '2003'))
    telemetry_prefix = os.getenv('TELEMETRY_PREFIX', 'io.turntabl')

    print('prefix: ' + telemetry_prefix)

    SSID = get_ssid()
    wifi_signal_quality = get_wifi_signal_quality()
    upload, download = get_speeds()

    graphyte.init(host=telemetry_target_host, port=telemetry_target_port, prefix=telemetry_prefix)
    graphyte.send('wifi.signal_quality', wifi_signal_quality)
    graphyte.send('4g.upload', upload / 1024 / 1024)
    graphyte.send('4g.download', download / 1024 / 1024)
github sammoorhouse / watchful-eye / src / watchful-eye.py View on Github external
#!/usr/bin/env python

import graphyte
import os
import requests

from apscheduler.schedulers.blocking import BlockingScheduler
from subprocess import check_output, Popen, PIPE, CalledProcessError
from xml.etree import ElementTree

telemetry_target_host = os.getenv('TELEMETRY_TARGET_HOST')
telemetry_target_port = int(os.getenv('TELEMETRY_TARGET_PORT', '2003'))
telemetry_prefix = os.getenv('TELEMETRY_PREFIX', 'io.turntabl')
collect_huawei_router_data = os.getenv('COLLECT_HUAWEI_ROUTER_DATA') in ['true', 'TRUE', '1']

graphyte.init(host=telemetry_target_host, port=telemetry_target_port, prefix=telemetry_prefix)

def publish_wifi_signal_quality():
    SSID = get_ssid()
    try:
        shell_cmd = 'iwconfig {} | grep Link'.format('wlan0')

        proc = Popen(shell_cmd, shell=True, stdout=PIPE, stderr=PIPE)
        output, err = proc.communicate()
        msg = output.decode('utf-8').strip()

        # like:
        # Link Quality=41/70  Signal level=-69 dBm  

        quality_str = msg.split('Link Quality=')[1].split('/70')[0].strip() #hurl
        quality = int(quality_str)
github earthgecko / skyline / skyline / flux / populate_metric.py View on Github external
# URI arguments are solely used for identifying requests in the log, all the
# required metric data is submitted via a POST with a json payload.
validArguments = ['remote_target', 'metric', 'namespace_prefix', 'key', 'user']

skyline_app = 'flux'

LOCAL_DEBUG = False

GRAPHITE_METRICS_PREFIX = None
CARBON_HOST = settings.FLUX_CARBON_HOST
CARBON_PORT = settings.FLUX_CARBON_PORT

if settings.FLUX_SEND_TO_CARBON:
    try:
        graphyte.init(CARBON_HOST, port=CARBON_PORT, prefix=None, timeout=5)
        logger.info('populate_metric :: Succeeded to graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))
    except:
        logger.error(traceback.format_exc())
        logger.error('error :: failed to run graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))

# @modified 20191111 - Bug #3266: py3 Redis binary objects not strings
#                      Branch #3262: py3
# if settings.REDIS_PASSWORD:
#     redis_conn = StrictRedis(password=settings.REDIS_PASSWORD, unix_socket_path=settings.REDIS_SOCKET_PATH)
# else:
#     redis_conn = StrictRedis(unix_socket_path=settings.REDIS_SOCKET_PATH)
# @added 20191111 - Bug #3266: py3 Redis binary objects not strings
github earthgecko / skyline / skyline / flux / worker.py View on Github external
parent_skyline_app = 'flux'

# @added 20191010 - Feature #3250: Allow Skyline to send metrics to another Carbon host
# Added missing skyline_app required for send_graphite_metric
skyline_app = 'flux'

skyline_app_graphite_namespace = 'skyline.%s%s.worker' % (parent_skyline_app, SERVER_METRIC_PATH)

LOCAL_DEBUG = False

if settings.FLUX_SEND_TO_CARBON:
    GRAPHITE_METRICS_PREFIX = None
    CARBON_HOST = settings.FLUX_CARBON_HOST
    CARBON_PORT = settings.FLUX_CARBON_PORT
    try:
        graphyte.init(CARBON_HOST, port=CARBON_PORT, prefix=None, timeout=5)
        logger.info('worker :: succeeded to graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))
    except:
        logger.error(traceback.format_exc())
        logger.error('error :: worker :: failed to run graphyte.init with host: %s, port: %s, prefix: %s' % (
            str(CARBON_HOST), str(CARBON_PORT),
            str(GRAPHITE_METRICS_PREFIX)))
if settings.FLUX_SEND_TO_STATSD:
    STATSD_HOST = settings.FLUX_STATSD_HOST
    STATSD_PORT = settings.FLUX_STATSD_PORT
    try:
        statsd_conn = statsd.StatsClient(STATSD_HOST, STATSD_PORT)
        logger.info('worker :: initialized statsd.StatsClient with STATSD_HOST: %s, STATSD_PORT: %s' % (
            str(STATSD_HOST), str(STATSD_PORT)))
    except:

graphyte

Python 3 compatible library to send data to a Graphite metrics server (Carbon)

MIT
Latest version published 2 years ago

Package Health Score

52 / 100
Full package analysis