How to use graphyte - 10 common examples

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 Jetsetter / graphyte / test_graphyte.py View on Github external
"""Unit tests for the graphyte module."""

import re
try:
    import socketserver
except ImportError:
    import SocketServer as socketserver  # Python 2.x compatibility
import time
import unittest

import graphyte


class TestSender(graphyte.Sender):
    def __init__(self, *args, **kwargs):
        graphyte.Sender.__init__(self, 'dummy_host', *args, **kwargs)
        self.messages = []

    def send_socket(self, message):
        self.messages.append(message)

    def pop_message(self):
        assert self.messages, 'no messages sent'
        return self.messages.pop(0)


class TestHandler(socketserver.BaseRequestHandler):
    messages = []

    def handle(self):
github Jetsetter / graphyte / test_graphyte.py View on Github external
def __init__(self, *args, **kwargs):
        graphyte.Sender.__init__(self, 'dummy_host', *args, **kwargs)
        self.messages = []
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 / 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 / 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 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)

graphyte

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

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis