Skip to content

Commit

Permalink
Reformat all the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
calston committed Jan 16, 2015
1 parent b0275a5 commit 9a81616
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 94 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ API Documentation:

api/tensor.rst
api/protocol.rst
api/logs.rst
api/sources.rst
api/outputs.rst

Expand Down
11 changes: 4 additions & 7 deletions tensor/logs/follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
class LogFollower(object):
"""Provides a class for following log files between runs
**Arguments:**
:logfile: Full path to logfile
**Keyword arguments:**
:parser: Optional parser method for log lines
:param logfile: Full path to logfile
:type logfile: str
:param parser: Optional parser method for log lines
:type parser: str
"""

def __init__(self, logfile, parser=None, tmp_path="/var/lib/tensor/"):
Expand Down
5 changes: 2 additions & 3 deletions tensor/logs/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class ApacheLogParser:
Adapted from http://code.google.com/p/apachelog
**Arguments:**
:format: Apache log format definition eg
:param format: Apache log format definition eg
r'%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"'
or one of 'common', 'vhcommon' or 'combined'
:type format: str
"""
def __init__(self, format):
formats = {
Expand Down
49 changes: 13 additions & 36 deletions tensor/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ class Event(object):
All sources pass these to the queue, which form a proxy object
to create protobuf Event objects
**Arguments:**
:state: Some sort of string < 255 chars describing the state
:service: The service name for this event
:description: A description for the event, ie. "My house is on fire!"
:metric: int or float metric for this event
**Keyword arguments:**
:tags: List of tag strings
:hostname: Hostname for the event (defaults to system fqdn)
:aggregation: Aggregation function
:evtime: Event timestamp override
:param state: Some sort of string < 255 chars describing the state
:param service: The service name for this event
:param description: A description for the event, ie. "My house is on fire!"
:param metric: int or float metric for this event
:param tags: List of tag strings
:param hostname: Hostname for the event (defaults to system fqdn)
:param aggregation: Aggregation function
:param evtime: Event timestamp override
"""
def __init__(self, state, service, description, metric, ttl, tags=[],
hostname=None, aggregation=None, evtime=None):
Expand Down Expand Up @@ -75,19 +70,11 @@ class Output(object):
Outputs can inherit this object which provides a construct
for a working output
**Arguments:**
:config: Dictionary config for this queue (usually read from the
:param config: Dictionary config for this queue (usually read from the
yaml configuration)
:tensor: A TensorService object for interacting with the queue manager
:param tensor: A TensorService object for interacting with the queue manager
"""
def __init__(self, config, tensor):
"""Consturct a Output object
Arguments:
config -- Dictionary config for this output
tensor -- A TensorService object for interacting with the queue manager
"""
self.config = config
self.tensor = tensor

Expand Down Expand Up @@ -115,25 +102,15 @@ class Source(object):
Sources can inherit this object which provides a number of
utility methods.
**Arguments:**
:config: Dictionary config for this queue (usually read from the
:param config: Dictionary config for this queue (usually read from the
yaml configuration)
:queueBack: A callback method to recieve a list of Event objects
:tensor: A TensorService object for interacting with the queue manager
:param queueBack: A callback method to recieve a list of Event objects
:param tensor: A TensorService object for interacting with the queue manager
"""

sync = False

def __init__(self, config, queueBack, tensor):
"""Consturct a Source object
Arguments:
config -- Dictionary config for this source
queueBack -- Callback method for events originating from this source
called on config['interval']
tensor -- A TensorService object for interacting with the queue manager
"""
self.config = config
self.t = task.LoopingCall(self.tick)

Expand Down
14 changes: 7 additions & 7 deletions tensor/outputs/riemann.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class RiemannTCP(Output):
**Configuration arguments:**
:server: Riemann server hostname (default: localhost)
:param server: Riemann server hostname (default: localhost)
:type server: str.
:port: Riemann server port (default: 5555)
:param port: Riemann server port (default: 5555)
:type port: int.
:maxrate: Maximum de-queue rate (0 is no limit)
:param maxrate: Maximum de-queue rate (0 is no limit)
:type maxrate: int.
:interval: De-queue interval in seconds (default: 1.0)
:param interval: De-queue interval in seconds (default: 1.0)
:type interval: float.
:pressure: Maximum backpressure (-1 is no limit)
:param pressure: Maximum backpressure (-1 is no limit)
:type pressure: int.
"""
def __init__(self, *a):
Expand Down Expand Up @@ -109,9 +109,9 @@ class RiemannUDP(Output):
**Configuration arguments:**
:server: Riemann server IP address (default: 127.0.0.1)
:param server: Riemann server IP address (default: 127.0.0.1)
:type server: str.
:port: Riemann server port (default: 5555)
:param port: Riemann server port (default: 5555)
:type port: int.
"""

Expand Down
2 changes: 1 addition & 1 deletion tensor/sources/media/libav.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DarwinRTSP(Source):
**Configuration arguments:**
:destination: Host name or IP address to check
:param destination: Host name or IP address to check
:type method: str.
**Metrics:**
Expand Down
8 changes: 4 additions & 4 deletions tensor/sources/munin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class MuninNode(Source):
**Configuration arguments:**
:host: munin-node hostname (probably localhost)
:param host: munin-node hostname (probably localhost)
:type host: str.
:port: munin-node port (probably 4949)
:param port: munin-node port (probably 4949)
:type port: int.
**Metrics:**
:(service name).(plugin name).(keys...): A dot separated tree of munin
plugin keys
:(service name).(plugin name).(keys...): A dot separated tree of
munin plugin keys
"""

implements(ITensorSource)
Expand Down
10 changes: 5 additions & 5 deletions tensor/sources/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class HTTP(Source):
**Configuration arguments:**
:method: HTTP request method to use
:param method: HTTP request method to use
:type method: str.
:match: A text string to match in the document when it is correct
:param match: A text string to match in the document when it is correct
:type match: str.
:useragent: User-Agent header to use
:param useragent: User-Agent header to use
:type useragent: str.
**Metrics:**
Expand Down Expand Up @@ -84,8 +84,8 @@ class Ping(Source):
**Configuration arguments:**
:destination: Host name or IP address to ping
:type method: str.
:param destination: Host name or IP address to ping
:type destination: str.
**Metrics:**
Expand Down
14 changes: 8 additions & 6 deletions tensor/sources/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Nginx(Source):
**Configuration arguments:**
:stats_url: URL to fetch stub_status from
:param stats_url: URL to fetch stub_status from
:type stats_url: str.
**Metrics:**
Expand Down Expand Up @@ -99,14 +99,16 @@ class NginxLogMetrics(Source):
**Configuration arguments:**
:log_format: Log format passed to parser, same as the config definition
:param log_format: Log format passed to parser, same as the config
definition
:type log_format: str.
:file: Log file
:param file: Log file
:type file: str.
:max_lines: Maximum number of log lines to read per interval to prevent
overwhelming Tensor when reading large logs (default 2000)
:param max_lines: Maximum number of log lines to read per interval to
prevent overwhelming Tensor when reading large logs
(default 2000)
:type max_lines: int.
:resolution: Aggregate bucket resolution in seconds (default 10)
:param resolution: Aggregate bucket resolution in seconds (default 10)
:type resolution: int.
**Metrics:**
Expand Down
2 changes: 1 addition & 1 deletion tensor/sources/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Queues(Source):
**Configuration arguments:**
:vhost: Vhost name
:param vhost: Vhost name
:type vhost: str.
**Metrics:**
Expand Down
4 changes: 2 additions & 2 deletions tensor/sources/riak.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class RiakStats(Source):
**Configuration arguments:**
:url: Riak stats URL
:param url: Riak stats URL
:type url: str.
:useragent: User-Agent header to use
:param useragent: User-Agent header to use
:type useragent: str.
**Metrics:**
Expand Down
4 changes: 2 additions & 2 deletions tensor/sources/sflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class sFlow(Source):
**Configuration arguments:**
:port: UDP port to listen on
:param port: UDP port to listen on
:type port: int.
:dnslookup: Enable reverse DNS lookup for device IPs (default: True)
:param dnslookup: Enable reverse DNS lookup for device IPs (default: True)
:type dnslookup: bool.
**Metrics:**
Expand Down
22 changes: 11 additions & 11 deletions tensor/sources/snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
class SNMPConnection(object):
"""A wrapper class for PySNMP functions
**Arguments:**
:host: SNMP agent host
:param host: SNMP agent host
:type host: str.
:port: SNMP port
:param port: SNMP port
:type port: int.
:community: SNMP read community
:param community: SNMP read community
:type community: str.
(This is not a source and you shouldn't try to use it as one)
"""

def __init__(self, host, port, community):
Expand Down Expand Up @@ -100,11 +100,11 @@ class SNMP(Source):
**Configuration arguments:**
:ip: SNMP agent host (default: 127.0.0.1)
:param ip: SNMP agent host (default: 127.0.0.1)
:type ip: str.
:port: SNMP port (default: 161)
:param port: SNMP port (default: 161)
:type port: int.
:community: SNMP read community
:param community: SNMP read community
:type community: str.
"""

Expand Down Expand Up @@ -182,11 +182,11 @@ class SNMPCisco837(SNMP):
**Configuration arguments:**
:ip: SNMP agent host (default: 127.0.0.1)
:param ip: SNMP agent host (default: 127.0.0.1)
:type ip: str.
:port: SNMP port (default: 161)
:param port: SNMP port (default: 161)
:type port: int.
:community: SNMP read community
:param community: SNMP read community
:type community: str.
"""

Expand Down
16 changes: 7 additions & 9 deletions tensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@


class Resolver(object):
"""Helper class for DNS resolution
"""

def __init__(self):
self.recs = {}

Expand Down Expand Up @@ -93,18 +96,13 @@ def fork(executable, args=(), env={}, path=None, timeout=3600):
"""fork
Provides a deferred wrapper function with a timeout function
**Arguments:**
:executable: Executable
:param executable: Executable
:type executable: str.
**Keyword arguments:**
:args: Tupple of arguments
:param args: Tupple of arguments
:type args: tupple.
:env: Environment dictionary
:param env: Environment dictionary
:type env: dict.
:timeout: Kill the child process if timeout is exceeded
:param timeout: Kill the child process if timeout is exceeded
:type timeout: int.
"""
d = defer.Deferred()
Expand Down

0 comments on commit 9a81616

Please sign in to comment.