• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy python bindings to write to Carbon ( Re-write of carbonclient)

graphitesend

Build Status Changelog Coverage Status

Easy python bindings to write to Carbon ( Re-write of carbonclient).

Warning

This project is no longer maintained. Lacking rights to publish new versions, a collaborator has forked the project and maintain it there: graphitesender

Read The Docs

graphitesend.rtfd.org

Blog posts

dansysadm.com

Example Scripts

The github repo of graphitesend-examples has lots of examples using graphitesend to grab data from your local linux system.

Installing

pip

$ pip install graphitesend

easy_install

$ easy_install graphitesend

or

source

$ git clone git://github.com/daniellawrence/graphitesend.git
$ cd graphitesend
$ python ./setup.py install

Usage Example

Very basic sending of a metric called metric with a value of 45

>>> import graphitesend
>>> graphitesend.init()
>>> graphitesend.send('metric', 45)
>>> graphitesend.send('metric2', 55)

The above would send the following metric to graphite

system.localhostname.metric 45 epoch-time-stamp
system.localhostname.metric2 55 epoch-time-stamp

Cleaning up the interface and using a group of cpu to alter the metric prefix

>>> import graphitesend
>>> g = graphitesend.init(group='cpu')
>>> g.send('metric', 45)
>>> g.send('metric2', 55)

The above would send the following metric to graphite

system.localhostname.cpu.metric 45 epoch-time-stamp
system.localhostname.cpu.metric2 55 epoch-time-stamp

Using a different prefix (other then system.hostname)

>>> import graphitesend
>>> g = graphitesend.init(prefix='apache.rc')
>>> g.send('404', 4)
>>> g.send('200', 500)

The above would send the following metric to graphite

apache.rc.localhostname.404 4 epoch-time-stamp
apache.rc.localhostname.200 500 epoch-time-stamp

To get rid of localhostname, set another argument β€” system_name

>>> import graphitesend
>>> g = graphitesend.init(prefix='apache.rc', system_name='')
>>> g.send('404', 4)
>>> g.send('200', 500)

The above would send the following metric to graphite

apache.rc.404 4 epoch-time-stamp
apache.rc.200 500 epoch-time-stamp

Sending a dict()

    >>> import graphitesend
    >>> g = graphitesend.init()
    >>> g.send_dict({'metric': 45, 'metric2': 55})

Sending a list()

    >>> import graphitesend
    >>> g = graphitesend.init()
    >>> g.send_list([('metric', 45), ('metric2', 55)])

Sending a list(), with a custom timestamp for all metric-value pairs

    >>> import graphitesend
    >>> g = graphitesend.init()
    >>> g.send_list([('metric', 45), ('metric2', 55)], timestamp=12345)

Sending a list(), with a custom timestamp for each metric-value pairs

    >>> import graphitesend
    >>> g = graphitesend.init()
    >>> g.send_list([('metric', 45, 1234), ('metric2', 55, 1234)])

Learning? Use dryrun.

With dryrun enabled the data will never get sent to a remote service, it will just print out what would have been sent.

    >>> import graphitesend
    >>> g = graphitesend.init(dryrun=True)
    >>> g.send_list([('metric', 45, 1234), ('metric2', 55, 1234)])

Example: the init()

Set a metric prefix (Default arg)

>>> g = graphitesend.init('prefix')
>>> print g.send('metric', 1)
sent 34 long message: prefix.metric 1.000000 1365068929

set a metric prefix using kwargs

>>> g = graphitesend.init(prefix='prefix')
>>> print g.send('metric', 2)
sent 34 long message: prefix.metric 2.000000 1365068929

Squash any dots in the hostname

>>> g = graphitesend.init(fqdn_squash=True)
>>> print g.send('metric', 3)
sent 56 long message: systems.host_example_com.metric 2.00000 1365069029

view the default prefix, hardset systems. then followed by the name of the host that execute the send().

>>> g = graphitesend.init()
>>> print g.send('metric', 3)
sent 44 long message: systems.<system_name>.metric 3.000000 1365069029

Set a suffix, handy if you have a bunch of timers or percentages

>>> g = graphitesend.init(suffix='_ms')
>>> print g.send('metric', 4)
sent 47 long message: systems.<system_name>.metric_ms 4.000000 1365069100

set a system_name if your submitting results for a different system

>>> g = graphitesend.init(system_name='othersystem')
>>> print g.send('metric', 5)
sent 47 long message: systems.othersystem.metric 5.000000 1365069100

Lowercase all the metric names that are send to the graphite server.

>>> g = graphitesend.init(lowercase_metric_names=True)
>>> print g.send('METRIC', 6)
sent 47 long message: systems.<hostname>.metric 6.000000 1365069100

Set a group name, handy if you just parsed iostat and want to prefix all the metrics with iostat, after its already in the <system_name> directory.

>>> g = graphitesend.init(group='groupname')
>>> print g.send('metric', 6)
sent 54 long message: systems.<system_name>.groupname.metric 6.000000 136506924

Connect to a different graphite server

>>> graphitesend.init(graphite_server='graphite.example.com')

Connect to a different graphite server port

>>> graphitesend.init(graphite_port=2003)

Send async messages

>>> graphitesend.init(asynchronous=True)

Change connect timeout (default 2)

>>> graphitesend.init(timeout_in_seconds=5)

CLI

Just added -- A cli script that allows for anything to send metrics over to graphite (not just python).

The usage is very simple you need to give the command a metric and a value.

	$ graphitesend name.of.the.metric 666

Send more* then 1 metric and value

	$ graphitesend name.of.the.metric 666
	$ graphitesend name.of.the.other_metric 2

* Call it 2 times ;)

Porcelain Overview

init

Create the module instance of GraphiteSend.

send

Make sure that we have an instance of the GraphiteClient. Then send the metrics to the graphite server.

send_dict

Make sure that we have an instance of the GraphiteClient. Then send the metrics to the graphite server.

reset

Disconnect from the graphite server and destroy the module instance.

TCP vs UDP

There is a new branch for UDP support called 'udp and tcp'. TCP will continue to be the default with UDP as an option

More Repositories

1

graphviz-aws

AWS architecture the easy way
Shell
69
star
2

aws-map

Map you AWS VPC deployment using graphviz/dot
Python
48
star
3

graphite-spark

A spark line for graphite, Turns graphite data into a cli sparkline : β–ˆ β–„ β–† β–‡ β–„
Python
40
star
4

fabric-web

Taking the magic of fabric and throwing up as a website for ease of use.
Python
37
star
5

simplenagios

Simple Nagios web client - Using bootstrap
Python
7
star
6

ansible-puppetmaster

ansible-puppetmaster
Shell
5
star
7

devpi-docker

Running devpi the easy way
Shell
5
star
8

30second-devops

Quick intro into the some devops toolsets
Ruby
5
star
9

aws-security-pictures

aws-security-pictures
Python
5
star
10

graphitesend-examples

A heap of scripts that are used to must metrics into graphite using graphitesend
Python
4
star
11

ddoc

Dynamic Documentation - Making documentation friendly & fun
HTML
4
star
12

debbie

Convert a directory into a simple debian package
Go
4
star
13

steam2elk

Parse cs:go logs and push them into ELK
Python
4
star
14

carbonclient

Easy python bindings to write to Carbon (frontend for Graphite's Whisper storage format)
Python
3
star
15

bagrep

Before / After Grep
Python
2
star
16

vala-docker-gui

C
2
star
17

external_naginator

Generate nagios configuration with 20,000 items from puppetdb in seconds.
Python
2
star
18

docker-voldemort

2
star
19

redis-file

This is a simple hack to allow the writing to redis as if it was just file object in python.
Python
2
star
20

total

A tribute to awk
Python
2
star
21

puppet-devpi

Install a basic devpi (http://doc.devpi.net/) system. The setup will be behind an nginx webserver.
Puppet
1
star
22

python-plugable-cli

Python
1
star
23

openrazer-python

Python helpers for the OpenRazer Keyboard Drivers
Python
1
star
24

github2gogs

quick script to backup repos into gogs from github
Python
1
star
25

fabphile

random fabric libraries to make fabric even better
Python
1
star
26

go-links-python

Very simple internal short-linking system.
Python
1
star
27

pair-programming-in-a-box

Shell
1
star
28

rhnlib

python api for redhat satellite or fedora spacewalk
1
star
29

flaskofmongo

A very(very) simple explorer for a mongodb using flask
CSS
1
star
30

recordkeeper

recordkeeper
Python
1
star
31

pyexetelsms

Python api for Exetel SMS Gateway
Python
1
star
32

fabric_scripts

some fabfiles and code examples
Python
1
star
33

graphite-ok

Easily check the status of a graphite metric via http return codes
Python
1
star
34

pytricks

Random python tricks that are awesome, however hard to remember...
Python
1
star
35

dansysadm.com

Shell
1
star
36

retrodate

print out the date in any format(including epoch) for any time in the past or future. I have found this very useful for date math in shell
C
1
star
37

go-go-serverinfo

Go
1
star