Coder Social home page Coder Social logo

Comments (3)

stefancoetzeetakealot avatar stefancoetzeetakealot commented on June 3, 2024 1

I just wrote my own sink that sends the data to multiple sinks

Just add a sink to statsite like:

stream_cmd = python statsite/sinks/multiplex.py /etc/multiplex.conf

and a config for multiplex

python /statsite/sinks/graphite.py graphite01 2003 statsd.
python /statsite/sinks/graphite.py graphite02 2003 statsd.

Here is the python code:

"""
Supports sending metrics to multiple sinks
"""
import os
import sys
import subprocess

def main():
    # Read from config
    with open(*sys.argv[1:]) as configFile:
        sinkList = configFile.readlines()
    # Remove newlines
    sinkList = [sink.strip() for sink in sinkList]

    # Gather the metrics
    metrics = ""
    while True:
        try:
            metrics += raw_input() + '\n'
        except EOFError:
            break

    # Send metrics to each of our sinks
    for sink in sinkList:
        proc = subprocess.Popen(sink, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        proc.stdin.write(metrics)
        proc.stdin.close()

if __name__ == "__main__":
    main()

from statsite.

sleepybishop avatar sleepybishop commented on June 3, 2024

would you mind pointing me to the documentation where that is stated? from the code it certainly doesn't seem to be the case.

some clever use of the tee command might be able to accomplish the same task as a workaround or really any script that pipes stdin to multiple processes.

from statsite.

mxsavchenko avatar mxsavchenko commented on June 3, 2024

Thank you

from statsite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.