GraphiteSend

class graphitesend.GraphiteClient(prefix=None, graphite_server=None, graphite_port=2003, debug=False, group=None, system_name=None, suffix=None, lowercase_metric_names=False, connect_on_create=True, fqdn_squash=False, dryrun=False)[source]

Graphite Client that will setup a TCP connection to graphite.

Parameters:
  • prefix (Default: “systems.”) – string added to the start of all metrics
  • graphite_server (Default: graphite) – hostname or ip address of graphite server
  • graphite_port (Default: 2003) – TCP port we will connect to
  • debug (True or False) – Toggle debug messages
  • group – string added to after system_name and before metric name
  • system_name (Default: current FDQN) – FDQN of the system generating the metrics
  • suffix – string added to the end of all metrics
  • lowercase_metric_names – Toggle the .lower() of all metric names
  • fqdn_squash (True or False) – Change host.example.com to host_example_com
  • dryrun (True or False) – Toggle if it will really send metrics or just return them

It will then send any metrics that you give it via the .send() or .send_dict().

You can also take advantage of the prefix, group and system_name options that allow you to setup default locations where your whisper files will be kept. eg. ( where linuxserver is the name of the localhost)

>>> init().prefix
systems.linuxserver.

>>> init(system_name='remote_host').prefix
systems.remote_host.

>>> init(group='cpu').prefix
systems.linuxserver.cpu.

>>> init(prefix='apache').prefix
apache.
clean_metric_name(metric_name)[source]

Make sure the metric is free of control chars, spaces, tabs, etc.

connect()[source]

Make a TCP connection to the graphite server on port self.port

disconnect()[source]

Close the TCP connection with the graphite server.

send(metric, value, timestamp=None)[source]

Format a single metric/value pair, and send it to the graphite server.

Parameters:
  • metric – name of the metric
  • value – value of the metric
  • timestmap – epoch time of the event
>>> g = init()
>>> g.send("metric", 54)
>>> g = init()
>>> g.send(metric="metricname", value=73)
send_dict(data, timestamp=None)[source]

Format a dict of metric/values pairs, and send them all to the graphite server.

Parameters:
  • data – key,value pair of metric name and metric value
  • timestmap – epoch time of the event
>>> g = init()
>>> g.send_dict({'metric1': 54, 'metric2': 43, 'metricN': 999})
send_list(data, timestamp=None)[source]

Format a list of set’s of (metric, value) pairs, and send them all to the graphite server.

Parameters:
  • data – list of key,value pairs of metric name and metric value
  • timestmap – epoch time of the event
>>> g = init()
>>> g.send_list([('metric1', 54), ('metric2', 43, 1384418995), ('metricN', 999)])
graphitesend.cli()[source]

Allow the module to be called from the cli.

graphitesend.init(init_type='plaintext_tcp', *args, **kwargs)[source]

Create the module instance of the GraphiteClient.

graphitesend.reset()[source]

disconnect from the graphite server and destroy the module instance.

graphitesend.send(*args, **kwargs)[source]

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

graphitesend.send_dict(*args, **kwargs)[source]

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

graphitesend.send_list(*args, **kwargs)[source]

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

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.