How to use the carbonate.util.local_addresses function in carbonate

To help you get started, we’ve selected a few carbonate 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 graphite-project / carbonate / carbonate / cli.py View on Github external
args = parser.parse_args()

    config = Config(args.config_file)
    cluster = Cluster(config, args.cluster)
    invert = args.invert

    if args.metrics_file and args.metrics_file[0] != '-':
        fi = args.metrics_file
    else:
        fi = []

    if args.node:
        match_dests = [args.node]
    else:
        match_dests = local_addresses()

    try:
        for metric in fileinput.input(fi):
            if args.field is None:
                m = metric.strip()
            else:
                fields = metric.split(args.field_separator)
                try:
                    m = fields[int(args.field)-1].strip()
                except IndexError:
                    raise SystemExit("Field index is out-of-bounds")

            for match in filterMetrics([m], match_dests, cluster, invert):
                print metric.strip()
    except KeyboardInterrupt:
        sys.exit(1)
github graphite-project / carbonate / carbonate / cli.py View on Github external
args = parser.parse_args()

    config = Config(args.config_file)
    cluster = Cluster(config, args.cluster)
    invert = args.invert

    if args.metrics_file and args.metrics_file[0] != '-':
        fi = args.metrics_file
    else:
        fi = []

    if args.node:
        match_dests = [args.node]
    else:
        match_dests = local_addresses()

    try:
        for metric in fileinput.input(fi):
            if args.field is None:
                m = metric.strip()
            else:
                fields = metric.split(args.field_separator)
                try:
                    m = fields[int(args.field)-1].strip()
                except IndexError:
                    raise SystemExit("Field index is out-of-bounds")

            for match in filterMetrics([m], match_dests, cluster, invert):
                print metric.strip()
    except KeyboardInterrupt:
        sys.exit(1)