id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
222,300
python-diamond/Diamond
src/collectors/elb/elb.py
ElbCollector.publish_delayed_metric
def publish_delayed_metric(self, name, value, timestamp, raw_value=None, precision=0, metric_type='GAUGE', instance=None): """ Metrics may not be immediately available when querying cloudwatch. Hence, allow the ability to publish a me...
python
def publish_delayed_metric(self, name, value, timestamp, raw_value=None, precision=0, metric_type='GAUGE', instance=None): """ Metrics may not be immediately available when querying cloudwatch. Hence, allow the ability to publish a me...
[ "def", "publish_delayed_metric", "(", "self", ",", "name", ",", "value", ",", "timestamp", ",", "raw_value", "=", "None", ",", "precision", "=", "0", ",", "metric_type", "=", "'GAUGE'", ",", "instance", "=", "None", ")", ":", "# Get metric Path", "path", "...
Metrics may not be immediately available when querying cloudwatch. Hence, allow the ability to publish a metric from some the past given its timestamp.
[ "Metrics", "may", "not", "be", "immediately", "available", "when", "querying", "cloudwatch", ".", "Hence", "allow", "the", "ability", "to", "publish", "a", "metric", "from", "some", "the", "past", "given", "its", "timestamp", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/elb/elb.py#L184-L205
222,301
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol.agr_busy
def agr_busy(self): """ Collector for average disk busyness per aggregate As of Nov 22nd 2013 there is no API call for agr busyness. You have to collect all disk busyness and then compute agr busyness. #fml """ c1 = {} # Counters from time a c2 = {...
python
def agr_busy(self): """ Collector for average disk busyness per aggregate As of Nov 22nd 2013 there is no API call for agr busyness. You have to collect all disk busyness and then compute agr busyness. #fml """ c1 = {} # Counters from time a c2 = {...
[ "def", "agr_busy", "(", "self", ")", ":", "c1", "=", "{", "}", "# Counters from time a", "c2", "=", "{", "}", "# Counters from time b", "disk_results", "=", "{", "}", "# Disk busyness results %", "agr_results", "=", "{", "}", "# Aggregate busyness results $", "nam...
Collector for average disk busyness per aggregate As of Nov 22nd 2013 there is no API call for agr busyness. You have to collect all disk busyness and then compute agr busyness. #fml
[ "Collector", "for", "average", "disk", "busyness", "per", "aggregate" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L71-L135
222,302
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol.consistency_point
def consistency_point(self): """ Collector for getting count of consistancy points """ cp_delta = {} xml_path = 'instances/instance-data/counters' netapp_api = NaElement('perf-object-get-instances') netapp_api.child_add_string('objectname', 'wafl') instance = NaE...
python
def consistency_point(self): """ Collector for getting count of consistancy points """ cp_delta = {} xml_path = 'instances/instance-data/counters' netapp_api = NaElement('perf-object-get-instances') netapp_api.child_add_string('objectname', 'wafl') instance = NaE...
[ "def", "consistency_point", "(", "self", ")", ":", "cp_delta", "=", "{", "}", "xml_path", "=", "'instances/instance-data/counters'", "netapp_api", "=", "NaElement", "(", "'perf-object-get-instances'", ")", "netapp_api", ".", "child_add_string", "(", "'objectname'", ",...
Collector for getting count of consistancy points
[ "Collector", "for", "getting", "count", "of", "consistancy", "points" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L137-L206
222,303
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol.zero_disk
def zero_disk(self, disk_xml=None): """ Collector and publish not zeroed disk metrics """ troubled_disks = 0 for filer_disk in disk_xml: raid_state = filer_disk.find('raid-state').text if not raid_state == 'spare': continue is_zeroed =...
python
def zero_disk(self, disk_xml=None): """ Collector and publish not zeroed disk metrics """ troubled_disks = 0 for filer_disk in disk_xml: raid_state = filer_disk.find('raid-state').text if not raid_state == 'spare': continue is_zeroed =...
[ "def", "zero_disk", "(", "self", ",", "disk_xml", "=", "None", ")", ":", "troubled_disks", "=", "0", "for", "filer_disk", "in", "disk_xml", ":", "raid_state", "=", "filer_disk", ".", "find", "(", "'raid-state'", ")", ".", "text", "if", "not", "raid_state",...
Collector and publish not zeroed disk metrics
[ "Collector", "and", "publish", "not", "zeroed", "disk", "metrics" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L225-L238
222,304
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol.spare_disk
def spare_disk(self, disk_xml=None): """ Number of spare disk per type. For example: storage.ontap.filer201.disk.SATA """ spare_disk = {} disk_types = set() for filer_disk in disk_xml: disk_types.add(filer_disk.find('effective-disk-type').text) ...
python
def spare_disk(self, disk_xml=None): """ Number of spare disk per type. For example: storage.ontap.filer201.disk.SATA """ spare_disk = {} disk_types = set() for filer_disk in disk_xml: disk_types.add(filer_disk.find('effective-disk-type').text) ...
[ "def", "spare_disk", "(", "self", ",", "disk_xml", "=", "None", ")", ":", "spare_disk", "=", "{", "}", "disk_types", "=", "set", "(", ")", "for", "filer_disk", "in", "disk_xml", ":", "disk_types", ".", "add", "(", "filer_disk", ".", "find", "(", "'effe...
Number of spare disk per type. For example: storage.ontap.filer201.disk.SATA
[ "Number", "of", "spare", "disk", "per", "type", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L240-L265
222,305
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol.get_netapp_elem
def get_netapp_elem(self, netapp_api=None, sub_element=None): """ Retrieve netapp elem """ netapp_data = self.server.invoke_elem(netapp_api) if netapp_data.results_status() == 'failed': self.log.error( 'While using netapp API failed to retrieve ' ...
python
def get_netapp_elem(self, netapp_api=None, sub_element=None): """ Retrieve netapp elem """ netapp_data = self.server.invoke_elem(netapp_api) if netapp_data.results_status() == 'failed': self.log.error( 'While using netapp API failed to retrieve ' ...
[ "def", "get_netapp_elem", "(", "self", ",", "netapp_api", "=", "None", ",", "sub_element", "=", "None", ")", ":", "netapp_data", "=", "self", ".", "server", ".", "invoke_elem", "(", "netapp_api", ")", "if", "netapp_data", ".", "results_status", "(", ")", "...
Retrieve netapp elem
[ "Retrieve", "netapp", "elem" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L267-L282
222,306
python-diamond/Diamond
src/collectors/netapp/netappDisk.py
netappDiskCol._netapp_login
def _netapp_login(self): """ Login to our netapp filer """ self.server = NaServer(self.ip, 1, 3) self.server.set_transport_type('HTTPS') self.server.set_style('LOGIN') self.server.set_admin_user(self.netapp_user, self.netapp_password)
python
def _netapp_login(self): """ Login to our netapp filer """ self.server = NaServer(self.ip, 1, 3) self.server.set_transport_type('HTTPS') self.server.set_style('LOGIN') self.server.set_admin_user(self.netapp_user, self.netapp_password)
[ "def", "_netapp_login", "(", "self", ")", ":", "self", ".", "server", "=", "NaServer", "(", "self", ".", "ip", ",", "1", ",", "3", ")", "self", ".", "server", ".", "set_transport_type", "(", "'HTTPS'", ")", "self", ".", "server", ".", "set_style", "(...
Login to our netapp filer
[ "Login", "to", "our", "netapp", "filer" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L284-L291
222,307
python-diamond/Diamond
src/collectors/ceph/ceph.py
CephCollector._get_socket_paths
def _get_socket_paths(self): """Return a sequence of paths to sockets for communicating with ceph daemons. """ socket_pattern = os.path.join(self.config['socket_path'], (self.config['socket_prefix'] + '*.' + sel...
python
def _get_socket_paths(self): """Return a sequence of paths to sockets for communicating with ceph daemons. """ socket_pattern = os.path.join(self.config['socket_path'], (self.config['socket_prefix'] + '*.' + sel...
[ "def", "_get_socket_paths", "(", "self", ")", ":", "socket_pattern", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", "[", "'socket_path'", "]", ",", "(", "self", ".", "config", "[", "'socket_prefix'", "]", "+", "'*.'", "+", "self", "."...
Return a sequence of paths to sockets for communicating with ceph daemons.
[ "Return", "a", "sequence", "of", "paths", "to", "sockets", "for", "communicating", "with", "ceph", "daemons", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L78-L85
222,308
python-diamond/Diamond
src/collectors/ceph/ceph.py
CephCollector._get_counter_prefix_from_socket_name
def _get_counter_prefix_from_socket_name(self, name): """Given the name of a UDS socket, return the prefix for counters coming from that source. """ base = os.path.splitext(os.path.basename(name))[0] if base.startswith(self.config['socket_prefix']): base = base[len(se...
python
def _get_counter_prefix_from_socket_name(self, name): """Given the name of a UDS socket, return the prefix for counters coming from that source. """ base = os.path.splitext(os.path.basename(name))[0] if base.startswith(self.config['socket_prefix']): base = base[len(se...
[ "def", "_get_counter_prefix_from_socket_name", "(", "self", ",", "name", ")", ":", "base", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "name", ")", ")", "[", "0", "]", "if", "base", ".", "startswith", "(", "...
Given the name of a UDS socket, return the prefix for counters coming from that source.
[ "Given", "the", "name", "of", "a", "UDS", "socket", "return", "the", "prefix", "for", "counters", "coming", "from", "that", "source", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L87-L94
222,309
python-diamond/Diamond
src/collectors/ceph/ceph.py
CephCollector._get_stats_from_socket
def _get_stats_from_socket(self, name): """Return the parsed JSON data returned when ceph is told to dump the stats from the named socket. In the event of an error error, the exception is logged, and an empty result set is returned. """ try: json_blob = subpr...
python
def _get_stats_from_socket(self, name): """Return the parsed JSON data returned when ceph is told to dump the stats from the named socket. In the event of an error error, the exception is logged, and an empty result set is returned. """ try: json_blob = subpr...
[ "def", "_get_stats_from_socket", "(", "self", ",", "name", ")", ":", "try", ":", "json_blob", "=", "subprocess", ".", "check_output", "(", "[", "self", ".", "config", "[", "'ceph_binary'", "]", ",", "'--admin-daemon'", ",", "name", ",", "'perf'", ",", "'du...
Return the parsed JSON data returned when ceph is told to dump the stats from the named socket. In the event of an error error, the exception is logged, and an empty result set is returned.
[ "Return", "the", "parsed", "JSON", "data", "returned", "when", "ceph", "is", "told", "to", "dump", "the", "stats", "from", "the", "named", "socket", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L96-L125
222,310
python-diamond/Diamond
src/collectors/ceph/ceph.py
CephCollector._publish_stats
def _publish_stats(self, counter_prefix, stats): """Given a stats dictionary from _get_stats_from_socket, publish the individual values. """ for stat_name, stat_value in flatten_dictionary( stats, prefix=counter_prefix, ): self.publish_gauge(st...
python
def _publish_stats(self, counter_prefix, stats): """Given a stats dictionary from _get_stats_from_socket, publish the individual values. """ for stat_name, stat_value in flatten_dictionary( stats, prefix=counter_prefix, ): self.publish_gauge(st...
[ "def", "_publish_stats", "(", "self", ",", "counter_prefix", ",", "stats", ")", ":", "for", "stat_name", ",", "stat_value", "in", "flatten_dictionary", "(", "stats", ",", "prefix", "=", "counter_prefix", ",", ")", ":", "self", ".", "publish_gauge", "(", "sta...
Given a stats dictionary from _get_stats_from_socket, publish the individual values.
[ "Given", "a", "stats", "dictionary", "from", "_get_stats_from_socket", "publish", "the", "individual", "values", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L127-L135
222,311
python-diamond/Diamond
src/diamond/handler/graphitepickle.py
GraphitePickleHandler._pickle_batch
def _pickle_batch(self): """ Pickle the metrics into a form that can be understood by the graphite pickle connector. """ # Pickle payload = pickle.dumps(self.batch) # Pack Message header = struct.pack("!L", len(payload)) message = header + payload...
python
def _pickle_batch(self): """ Pickle the metrics into a form that can be understood by the graphite pickle connector. """ # Pickle payload = pickle.dumps(self.batch) # Pack Message header = struct.pack("!L", len(payload)) message = header + payload...
[ "def", "_pickle_batch", "(", "self", ")", ":", "# Pickle", "payload", "=", "pickle", ".", "dumps", "(", "self", ".", "batch", ")", "# Pack Message", "header", "=", "struct", ".", "pack", "(", "\"!L\"", ",", "len", "(", "payload", ")", ")", "message", "...
Pickle the metrics into a form that can be understood by the graphite pickle connector.
[ "Pickle", "the", "metrics", "into", "a", "form", "that", "can", "be", "understood", "by", "the", "graphite", "pickle", "connector", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphitepickle.py#L88-L101
222,312
python-diamond/Diamond
src/diamond/handler/g_metric.py
GmetricHandler._send
def _send(self, metric): """ Send data to gmond. """ metric_name = self.get_name_from_path(metric.path) tmax = "60" dmax = "0" slope = "both" # FIXME: Badness, shouldn't *assume* double type metric_type = "double" units = "" group =...
python
def _send(self, metric): """ Send data to gmond. """ metric_name = self.get_name_from_path(metric.path) tmax = "60" dmax = "0" slope = "both" # FIXME: Badness, shouldn't *assume* double type metric_type = "double" units = "" group =...
[ "def", "_send", "(", "self", ",", "metric", ")", ":", "metric_name", "=", "self", ".", "get_name_from_path", "(", "metric", ".", "path", ")", "tmax", "=", "\"60\"", "dmax", "=", "\"0\"", "slope", "=", "\"both\"", "# FIXME: Badness, shouldn't *assume* double type...
Send data to gmond.
[ "Send", "data", "to", "gmond", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/g_metric.py#L87-L106
222,313
python-diamond/Diamond
src/diamond/handler/mqtt.py
MQTTHandler.process
def process(self, metric): """ Process a metric by converting metric name to MQTT topic name; the payload is metric and timestamp. """ if not mosquitto: return line = str(metric) topic, value, timestamp = line.split() if len(self.prefix): ...
python
def process(self, metric): """ Process a metric by converting metric name to MQTT topic name; the payload is metric and timestamp. """ if not mosquitto: return line = str(metric) topic, value, timestamp = line.split() if len(self.prefix): ...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "if", "not", "mosquitto", ":", "return", "line", "=", "str", "(", "metric", ")", "topic", ",", "value", ",", "timestamp", "=", "line", ".", "split", "(", ")", "if", "len", "(", "self", ".", ...
Process a metric by converting metric name to MQTT topic name; the payload is metric and timestamp.
[ "Process", "a", "metric", "by", "converting", "metric", "name", "to", "MQTT", "topic", "name", ";", "the", "payload", "is", "metric", "and", "timestamp", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mqtt.py#L175-L194
222,314
python-diamond/Diamond
src/diamond/handler/tsdb.py
TSDBHandler.process
def process(self, metric): """ Process a metric by sending it to TSDB """ entry = {'timestamp': metric.timestamp, 'value': metric.value, "tags": {}} entry["tags"]["hostname"] = metric.host if self.cleanMetrics: metric = MetricWrapper(metric, ...
python
def process(self, metric): """ Process a metric by sending it to TSDB """ entry = {'timestamp': metric.timestamp, 'value': metric.value, "tags": {}} entry["tags"]["hostname"] = metric.host if self.cleanMetrics: metric = MetricWrapper(metric, ...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "entry", "=", "{", "'timestamp'", ":", "metric", ".", "timestamp", ",", "'value'", ":", "metric", ".", "value", ",", "\"tags\"", ":", "{", "}", "}", "entry", "[", "\"tags\"", "]", "[", "\"hostna...
Process a metric by sending it to TSDB
[ "Process", "a", "metric", "by", "sending", "it", "to", "TSDB" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/tsdb.py#L189-L225
222,315
python-diamond/Diamond
src/diamond/handler/tsdb.py
TSDBHandler._send
def _send(self, content): """ Send content to TSDB. """ retry = 0 success = False while retry < 3 and success is False: self.log.debug(content) try: request = urllib2.Request("http://"+self.host+":" + ...
python
def _send(self, content): """ Send content to TSDB. """ retry = 0 success = False while retry < 3 and success is False: self.log.debug(content) try: request = urllib2.Request("http://"+self.host+":" + ...
[ "def", "_send", "(", "self", ",", "content", ")", ":", "retry", "=", "0", "success", "=", "False", "while", "retry", "<", "3", "and", "success", "is", "False", ":", "self", ".", "log", ".", "debug", "(", "content", ")", "try", ":", "request", "=", ...
Send content to TSDB.
[ "Send", "content", "to", "TSDB", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/tsdb.py#L227-L252
222,316
python-diamond/Diamond
src/collectors/snmp/snmp.py
SNMPCollector.get
def get(self, oid, host, port, community): """ Perform SNMP get for a given OID """ # Initialize return value ret = {} # Convert OID to tuple if necessary if not isinstance(oid, tuple): oid = self._convert_to_oid(oid) # Convert Host to IP if ...
python
def get(self, oid, host, port, community): """ Perform SNMP get for a given OID """ # Initialize return value ret = {} # Convert OID to tuple if necessary if not isinstance(oid, tuple): oid = self._convert_to_oid(oid) # Convert Host to IP if ...
[ "def", "get", "(", "self", ",", "oid", ",", "host", ",", "port", ",", "community", ")", ":", "# Initialize return value", "ret", "=", "{", "}", "# Convert OID to tuple if necessary", "if", "not", "isinstance", "(", "oid", ",", "tuple", ")", ":", "oid", "="...
Perform SNMP get for a given OID
[ "Perform", "SNMP", "get", "for", "a", "given", "OID" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/snmp/snmp.py#L75-L109
222,317
python-diamond/Diamond
src/collectors/snmp/snmp.py
SNMPCollector.walk
def walk(self, oid, host, port, community): """ Perform an SNMP walk on a given OID """ # Initialize return value ret = {} # Convert OID to tuple if necessary if not isinstance(oid, tuple): oid = self._convert_to_oid(oid) # Convert Host to IP...
python
def walk(self, oid, host, port, community): """ Perform an SNMP walk on a given OID """ # Initialize return value ret = {} # Convert OID to tuple if necessary if not isinstance(oid, tuple): oid = self._convert_to_oid(oid) # Convert Host to IP...
[ "def", "walk", "(", "self", ",", "oid", ",", "host", ",", "port", ",", "community", ")", ":", "# Initialize return value", "ret", "=", "{", "}", "# Convert OID to tuple if necessary", "if", "not", "isinstance", "(", "oid", ",", "tuple", ")", ":", "oid", "=...
Perform an SNMP walk on a given OID
[ "Perform", "an", "SNMP", "walk", "on", "a", "given", "OID" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/snmp/snmp.py#L111-L148
222,318
python-diamond/Diamond
src/collectors/diskusage/diskusage.py
DiskUsageCollector.get_disk_statistics
def get_disk_statistics(self): """ Create a map of disks in the machine. http://www.kernel.org/doc/Documentation/iostats.txt Returns: (major, minor) -> DiskStatistics(device, ...) """ result = {} if os.access('/proc/diskstats', os.R_OK): s...
python
def get_disk_statistics(self): """ Create a map of disks in the machine. http://www.kernel.org/doc/Documentation/iostats.txt Returns: (major, minor) -> DiskStatistics(device, ...) """ result = {} if os.access('/proc/diskstats', os.R_OK): s...
[ "def", "get_disk_statistics", "(", "self", ")", ":", "result", "=", "{", "}", "if", "os", ".", "access", "(", "'/proc/diskstats'", ",", "os", ".", "R_OK", ")", ":", "self", ".", "proc_diskstats", "=", "True", "fp", "=", "open", "(", "'/proc/diskstats'", ...
Create a map of disks in the machine. http://www.kernel.org/doc/Documentation/iostats.txt Returns: (major, minor) -> DiskStatistics(device, ...)
[ "Create", "a", "map", "of", "disks", "in", "the", "machine", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/diskusage/diskusage.py#L72-L145
222,319
python-diamond/Diamond
src/diamond/handler/riemann.py
RiemannHandler.process
def process(self, metric): """ Send a metric to Riemann. """ event = self._metric_to_riemann_event(metric) try: self.client.send_event(event) except Exception as e: self.log.error( "RiemannHandler: Error sending event to Riemann: %s...
python
def process(self, metric): """ Send a metric to Riemann. """ event = self._metric_to_riemann_event(metric) try: self.client.send_event(event) except Exception as e: self.log.error( "RiemannHandler: Error sending event to Riemann: %s...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "event", "=", "self", ".", "_metric_to_riemann_event", "(", "metric", ")", "try", ":", "self", ".", "client", ".", "send_event", "(", "event", ")", "except", "Exception", "as", "e", ":", "self", "...
Send a metric to Riemann.
[ "Send", "a", "metric", "to", "Riemann", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/riemann.py#L83-L92
222,320
python-diamond/Diamond
src/diamond/handler/riemann.py
RiemannHandler._metric_to_riemann_event
def _metric_to_riemann_event(self, metric): """ Convert a metric to a dictionary representing a Riemann event. """ # Riemann has a separate "host" field, so remove from the path. path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), ...
python
def _metric_to_riemann_event(self, metric): """ Convert a metric to a dictionary representing a Riemann event. """ # Riemann has a separate "host" field, so remove from the path. path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), ...
[ "def", "_metric_to_riemann_event", "(", "self", ",", "metric", ")", ":", "# Riemann has a separate \"host\" field, so remove from the path.", "path", "=", "'%s.%s.%s'", "%", "(", "metric", ".", "getPathPrefix", "(", ")", ",", "metric", ".", "getCollectorPath", "(", ")...
Convert a metric to a dictionary representing a Riemann event.
[ "Convert", "a", "metric", "to", "a", "dictionary", "representing", "a", "Riemann", "event", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/riemann.py#L94-L111
222,321
python-diamond/Diamond
src/collectors/s3/s3.py
S3BucketCollector.collect
def collect(self): """ Collect s3 bucket stats """ if boto is None: self.log.error("Unable to import boto python module") return {} for s3instance in self.config['s3']: self.log.info("S3: byte_unit: %s" % self.config['byte_unit']) a...
python
def collect(self): """ Collect s3 bucket stats """ if boto is None: self.log.error("Unable to import boto python module") return {} for s3instance in self.config['s3']: self.log.info("S3: byte_unit: %s" % self.config['byte_unit']) a...
[ "def", "collect", "(", "self", ")", ":", "if", "boto", "is", "None", ":", "self", ".", "log", ".", "error", "(", "\"Unable to import boto python module\"", ")", "return", "{", "}", "for", "s3instance", "in", "self", ".", "config", "[", "'s3'", "]", ":", ...
Collect s3 bucket stats
[ "Collect", "s3", "bucket", "stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/s3/s3.py#L51-L74
222,322
python-diamond/Diamond
src/collectors/scribe/scribe.py
ScribeCollector.key_to_metric
def key_to_metric(self, key): """Replace all non-letter characters with underscores""" return ''.join(l if l in string.letters else '_' for l in key)
python
def key_to_metric(self, key): """Replace all non-letter characters with underscores""" return ''.join(l if l in string.letters else '_' for l in key)
[ "def", "key_to_metric", "(", "self", ",", "key", ")", ":", "return", "''", ".", "join", "(", "l", "if", "l", "in", "string", ".", "letters", "else", "'_'", "for", "l", "in", "key", ")" ]
Replace all non-letter characters with underscores
[ "Replace", "all", "non", "-", "letter", "characters", "with", "underscores" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/scribe/scribe.py#L37-L39
222,323
python-diamond/Diamond
src/collectors/ipmisensor/ipmisensor.py
IPMISensorCollector.parse_value
def parse_value(self, value): """ Convert value string to float for reporting """ value = value.strip() # Skip missing sensors if value == 'na': return None # Try just getting the float value try: return float(value) excep...
python
def parse_value(self, value): """ Convert value string to float for reporting """ value = value.strip() # Skip missing sensors if value == 'na': return None # Try just getting the float value try: return float(value) excep...
[ "def", "parse_value", "(", "self", ",", "value", ")", ":", "value", "=", "value", ".", "strip", "(", ")", "# Skip missing sensors", "if", "value", "==", "'na'", ":", "return", "None", "# Try just getting the float value", "try", ":", "return", "float", "(", ...
Convert value string to float for reporting
[ "Convert", "value", "string", "to", "float", "for", "reporting" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ipmisensor/ipmisensor.py#L51-L74
222,324
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector.collect
def collect(self): """Collect statistics from a Nagios perfdata directory. """ perfdata_dir = self.config['perfdata_dir'] try: filenames = os.listdir(perfdata_dir) except OSError: self.log.error("Cannot read directory `{dir}'".format( dir=...
python
def collect(self): """Collect statistics from a Nagios perfdata directory. """ perfdata_dir = self.config['perfdata_dir'] try: filenames = os.listdir(perfdata_dir) except OSError: self.log.error("Cannot read directory `{dir}'".format( dir=...
[ "def", "collect", "(", "self", ")", ":", "perfdata_dir", "=", "self", ".", "config", "[", "'perfdata_dir'", "]", "try", ":", "filenames", "=", "os", ".", "listdir", "(", "perfdata_dir", ")", "except", "OSError", ":", "self", ".", "log", ".", "error", "...
Collect statistics from a Nagios perfdata directory.
[ "Collect", "statistics", "from", "a", "Nagios", "perfdata", "directory", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L99-L112
222,325
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector._fields_valid
def _fields_valid(self, d): """Verify that all necessary fields are present Determine whether the fields parsed represent a host or service perfdata. If the perfdata is unknown, return False. If the perfdata does not contain all fields required for that type, return False. Other...
python
def _fields_valid(self, d): """Verify that all necessary fields are present Determine whether the fields parsed represent a host or service perfdata. If the perfdata is unknown, return False. If the perfdata does not contain all fields required for that type, return False. Other...
[ "def", "_fields_valid", "(", "self", ",", "d", ")", ":", "if", "'DATATYPE'", "not", "in", "d", ":", "return", "False", "datatype", "=", "d", "[", "'DATATYPE'", "]", "if", "datatype", "==", "'HOSTPERFDATA'", ":", "fields", "=", "self", ".", "GENERIC_FIELD...
Verify that all necessary fields are present Determine whether the fields parsed represent a host or service perfdata. If the perfdata is unknown, return False. If the perfdata does not contain all fields required for that type, return False. Otherwise, return True.
[ "Verify", "that", "all", "necessary", "fields", "are", "present" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L127-L150
222,326
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector._normalize_to_unit
def _normalize_to_unit(self, value, unit): """Normalize the value to the unit returned. We use base-1000 for second-based units, and base-1024 for byte-based units. Sadly, the Nagios-Plugins specification doesn't disambiguate base-1000 (KB) and base-1024 (KiB). """ if un...
python
def _normalize_to_unit(self, value, unit): """Normalize the value to the unit returned. We use base-1000 for second-based units, and base-1024 for byte-based units. Sadly, the Nagios-Plugins specification doesn't disambiguate base-1000 (KB) and base-1024 (KiB). """ if un...
[ "def", "_normalize_to_unit", "(", "self", ",", "value", ",", "unit", ")", ":", "if", "unit", "==", "'ms'", ":", "return", "value", "/", "1000.0", "if", "unit", "==", "'us'", ":", "return", "value", "/", "1000000.0", "if", "unit", "==", "'KB'", ":", "...
Normalize the value to the unit returned. We use base-1000 for second-based units, and base-1024 for byte-based units. Sadly, the Nagios-Plugins specification doesn't disambiguate base-1000 (KB) and base-1024 (KiB).
[ "Normalize", "the", "value", "to", "the", "unit", "returned", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L152-L172
222,327
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector._parse_perfdata
def _parse_perfdata(self, s): """Parse performance data from a perfdata string """ metrics = [] counters = re.findall(self.TOKENIZER_RE, s) if counters is None: self.log.warning("Failed to parse performance data: {s}".format( s=s)) return m...
python
def _parse_perfdata(self, s): """Parse performance data from a perfdata string """ metrics = [] counters = re.findall(self.TOKENIZER_RE, s) if counters is None: self.log.warning("Failed to parse performance data: {s}".format( s=s)) return m...
[ "def", "_parse_perfdata", "(", "self", ",", "s", ")", ":", "metrics", "=", "[", "]", "counters", "=", "re", ".", "findall", "(", "self", ".", "TOKENIZER_RE", ",", "s", ")", "if", "counters", "is", "None", ":", "self", ".", "log", ".", "warning", "(...
Parse performance data from a perfdata string
[ "Parse", "performance", "data", "from", "a", "perfdata", "string" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L174-L193
222,328
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector._process_file
def _process_file(self, path): """Parse and submit the metrics from a file """ try: f = open(path) for line in f: self._process_line(line) os.remove(path) except IOError as ex: self.log.error("Could not open file `{path}': ...
python
def _process_file(self, path): """Parse and submit the metrics from a file """ try: f = open(path) for line in f: self._process_line(line) os.remove(path) except IOError as ex: self.log.error("Could not open file `{path}': ...
[ "def", "_process_file", "(", "self", ",", "path", ")", ":", "try", ":", "f", "=", "open", "(", "path", ")", "for", "line", "in", "f", ":", "self", ".", "_process_line", "(", "line", ")", "os", ".", "remove", "(", "path", ")", "except", "IOError", ...
Parse and submit the metrics from a file
[ "Parse", "and", "submit", "the", "metrics", "from", "a", "file" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L195-L206
222,329
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
NagiosPerfdataCollector._process_line
def _process_line(self, line): """Parse and submit the metrics from a line of perfdata output """ fields = self._extract_fields(line) if not self._fields_valid(fields): self.log.warning("Missing required fields for line: {line}".format( line=line)) me...
python
def _process_line(self, line): """Parse and submit the metrics from a line of perfdata output """ fields = self._extract_fields(line) if not self._fields_valid(fields): self.log.warning("Missing required fields for line: {line}".format( line=line)) me...
[ "def", "_process_line", "(", "self", ",", "line", ")", ":", "fields", "=", "self", ".", "_extract_fields", "(", "line", ")", "if", "not", "self", ".", "_fields_valid", "(", "fields", ")", ":", "self", ".", "log", ".", "warning", "(", "\"Missing required ...
Parse and submit the metrics from a line of perfdata output
[ "Parse", "and", "submit", "the", "metrics", "from", "a", "line", "of", "perfdata", "output" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L208-L244
222,330
python-diamond/Diamond
src/diamond/handler/rabbitmq_topic.py
rmqHandler._bind
def _bind(self): """ Create socket and bind """ credentials = pika.PlainCredentials(self.user, self.password) params = pika.ConnectionParameters(credentials=credentials, host=self.server, v...
python
def _bind(self): """ Create socket and bind """ credentials = pika.PlainCredentials(self.user, self.password) params = pika.ConnectionParameters(credentials=credentials, host=self.server, v...
[ "def", "_bind", "(", "self", ")", ":", "credentials", "=", "pika", ".", "PlainCredentials", "(", "self", ".", "user", ",", "self", ".", "password", ")", "params", "=", "pika", ".", "ConnectionParameters", "(", "credentials", "=", "credentials", ",", "host"...
Create socket and bind
[ "Create", "socket", "and", "bind" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_topic.py#L95-L112
222,331
python-diamond/Diamond
src/diamond/handler/rabbitmq_topic.py
rmqHandler.process
def process(self, metric): """ Process a metric and send it to RabbitMQ topic exchange """ # Send the data as ...... if not pika: return routingKeyDic = { 'metric': lambda: metric.path, 'custom': lambda: self.custom_routing_key, ...
python
def process(self, metric): """ Process a metric and send it to RabbitMQ topic exchange """ # Send the data as ...... if not pika: return routingKeyDic = { 'metric': lambda: metric.path, 'custom': lambda: self.custom_routing_key, ...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "# Send the data as ......", "if", "not", "pika", ":", "return", "routingKeyDic", "=", "{", "'metric'", ":", "lambda", ":", "metric", ".", "path", ",", "'custom'", ":", "lambda", ":", "self", ".", "...
Process a metric and send it to RabbitMQ topic exchange
[ "Process", "a", "metric", "and", "send", "it", "to", "RabbitMQ", "topic", "exchange" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_topic.py#L123-L155
222,332
python-diamond/Diamond
src/collectors/pgq/pgq.py
PgQCollector._collect_for_instance
def _collect_for_instance(self, instance, connection): """Collects metrics for a named connection.""" with connection.cursor() as cursor: for queue, metrics in self.get_queue_info(instance, cursor): for name, metric in metrics.items(): self.publish('.'.joi...
python
def _collect_for_instance(self, instance, connection): """Collects metrics for a named connection.""" with connection.cursor() as cursor: for queue, metrics in self.get_queue_info(instance, cursor): for name, metric in metrics.items(): self.publish('.'.joi...
[ "def", "_collect_for_instance", "(", "self", ",", "instance", ",", "connection", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "for", "queue", ",", "metrics", "in", "self", ".", "get_queue_info", "(", "instance", ",", "curso...
Collects metrics for a named connection.
[ "Collects", "metrics", "for", "a", "named", "connection", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L62-L74
222,333
python-diamond/Diamond
src/collectors/pgq/pgq.py
PgQCollector.get_queue_info
def get_queue_info(self, instance, cursor): """Collects metrics for all queues on the connected database.""" cursor.execute(self.QUEUE_INFO_STATEMENT) for queue_name, ticker_lag, ev_per_sec in cursor: yield queue_name, { 'ticker_lag': ticker_lag, 'ev_p...
python
def get_queue_info(self, instance, cursor): """Collects metrics for all queues on the connected database.""" cursor.execute(self.QUEUE_INFO_STATEMENT) for queue_name, ticker_lag, ev_per_sec in cursor: yield queue_name, { 'ticker_lag': ticker_lag, 'ev_p...
[ "def", "get_queue_info", "(", "self", ",", "instance", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "self", ".", "QUEUE_INFO_STATEMENT", ")", "for", "queue_name", ",", "ticker_lag", ",", "ev_per_sec", "in", "cursor", ":", "yield", "queue_name", ",...
Collects metrics for all queues on the connected database.
[ "Collects", "metrics", "for", "all", "queues", "on", "the", "connected", "database", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L84-L91
222,334
python-diamond/Diamond
src/collectors/pgq/pgq.py
PgQCollector.get_consumer_info
def get_consumer_info(self, instance, cursor): """Collects metrics for all consumers on the connected database.""" cursor.execute(self.CONSUMER_INFO_STATEMENT) for queue_name, consumer_name, lag, pending_events, last_seen in cursor: yield queue_name, consumer_name, { ...
python
def get_consumer_info(self, instance, cursor): """Collects metrics for all consumers on the connected database.""" cursor.execute(self.CONSUMER_INFO_STATEMENT) for queue_name, consumer_name, lag, pending_events, last_seen in cursor: yield queue_name, consumer_name, { ...
[ "def", "get_consumer_info", "(", "self", ",", "instance", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "self", ".", "CONSUMER_INFO_STATEMENT", ")", "for", "queue_name", ",", "consumer_name", ",", "lag", ",", "pending_events", ",", "last_seen", "in",...
Collects metrics for all consumers on the connected database.
[ "Collects", "metrics", "for", "all", "consumers", "on", "the", "connected", "database", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L103-L111
222,335
python-diamond/Diamond
src/collectors/mdstat/mdstat.py
MdStatCollector.collect
def collect(self): """Publish all mdstat metrics.""" def traverse(d, metric_name=''): """ Traverse the given nested dict using depth-first search. If a value is reached it will be published with a metric name consisting of the hierarchically concatenated ...
python
def collect(self): """Publish all mdstat metrics.""" def traverse(d, metric_name=''): """ Traverse the given nested dict using depth-first search. If a value is reached it will be published with a metric name consisting of the hierarchically concatenated ...
[ "def", "collect", "(", "self", ")", ":", "def", "traverse", "(", "d", ",", "metric_name", "=", "''", ")", ":", "\"\"\"\n Traverse the given nested dict using depth-first search.\n\n If a value is reached it will be published with a metric name\n consi...
Publish all mdstat metrics.
[ "Publish", "all", "mdstat", "metrics", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L70-L97
222,336
python-diamond/Diamond
src/collectors/mdstat/mdstat.py
MdStatCollector._parse_array_member_state
def _parse_array_member_state(self, block): """ Parse the state of the the md array members. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' ...
python
def _parse_array_member_state(self, block): """ Parse the state of the the md array members. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' ...
[ "def", "_parse_array_member_state", "(", "self", ",", "block", ")", ":", "members", "=", "block", ".", "split", "(", "'\\n'", ")", "[", "0", "]", ".", "split", "(", "' : '", ")", "[", "1", "]", ".", "split", "(", "' '", ")", "[", "2", ":", "]", ...
Parse the state of the the md array members. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>> print _parse_array_member_state(block) { ...
[ "Parse", "the", "state", "of", "the", "the", "md", "array", "members", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L176-L216
222,337
python-diamond/Diamond
src/collectors/mdstat/mdstat.py
MdStatCollector._parse_array_status
def _parse_array_status(self, block): """ Parse the status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>> print ...
python
def _parse_array_status(self, block): """ Parse the status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>> print ...
[ "def", "_parse_array_status", "(", "self", ",", "block", ")", ":", "array_status_regexp", "=", "re", ".", "compile", "(", "'^ *(?P<blocks>\\d*) blocks '", "'(?:super (?P<superblock_version>\\d\\.\\d) )?'", "'(?:level (?P<raid_level>\\d), '", "'(?P<chunk_size>\\d*)k chunk, '", "'a...
Parse the status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>> print _parse_array_status(block) { 'total_me...
[ "Parse", "the", "status", "of", "the", "md", "array", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L218-L268
222,338
python-diamond/Diamond
src/collectors/mdstat/mdstat.py
MdStatCollector._parse_array_bitmap
def _parse_array_bitmap(self, block): """ Parse the bitmap status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>>...
python
def _parse_array_bitmap(self, block): """ Parse the bitmap status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>>...
[ "def", "_parse_array_bitmap", "(", "self", ",", "block", ")", ":", "array_bitmap_regexp", "=", "re", ".", "compile", "(", "'^ *bitmap: (?P<allocated_pages>[0-9]*)/'", "'(?P<total_pages>[0-9]*) pages '", "'\\[(?P<page_size>[0-9]*)KB\\], '", "'(?P<chunk_size>[0-9]*)KB chunk.*$'", "...
Parse the bitmap status of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n' >>> print _parse_array_bitmap(block) { 't...
[ "Parse", "the", "bitmap", "status", "of", "the", "md", "array", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L270-L317
222,339
python-diamond/Diamond
src/collectors/mdstat/mdstat.py
MdStatCollector._parse_array_recovery
def _parse_array_recovery(self, block): """ Parse the recovery progress of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' [===================>.] recovery = 99.5% ' ...
python
def _parse_array_recovery(self, block): """ Parse the recovery progress of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' [===================>.] recovery = 99.5% ' ...
[ "def", "_parse_array_recovery", "(", "self", ",", "block", ")", ":", "array_recovery_regexp", "=", "re", ".", "compile", "(", "'^ *\\[.*\\] *recovery = (?P<percent>\\d*\\.?\\d*)%'", "' \\(\\d*/\\d*\\) finish=(?P<remaining_time>\\d*\\.?\\d*)min '", "'speed=(?P<speed>\\d*)K/sec$'", "...
Parse the recovery progress of the md array. >>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n' >>> ' 100171776 blocks super 1.2 [2/2] [UU]\n' >>> ' [===================>.] recovery = 99.5% ' >>> '(102272/102272) finish=13.37min speed=102272...
[ "Parse", "the", "recovery", "progress", "of", "the", "md", "array", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L319-L364
222,340
python-diamond/Diamond
src/collectors/passenger_stats/passenger_stats.py
PassengerCollector.get_passenger_memory_stats
def get_passenger_memory_stats(self): """ Execute passenger-memory-stats, parse its output, return dictionary with stats. """ command = [self.config["passenger_memory_stats_bin"]] if str_to_bool(self.config["use_sudo"]): command.insert(0, self.config["sudo_cmd...
python
def get_passenger_memory_stats(self): """ Execute passenger-memory-stats, parse its output, return dictionary with stats. """ command = [self.config["passenger_memory_stats_bin"]] if str_to_bool(self.config["use_sudo"]): command.insert(0, self.config["sudo_cmd...
[ "def", "get_passenger_memory_stats", "(", "self", ")", ":", "command", "=", "[", "self", ".", "config", "[", "\"passenger_memory_stats_bin\"", "]", "]", "if", "str_to_bool", "(", "self", ".", "config", "[", "\"use_sudo\"", "]", ")", ":", "command", ".", "ins...
Execute passenger-memory-stats, parse its output, return dictionary with stats.
[ "Execute", "passenger", "-", "memory", "-", "stats", "parse", "its", "output", "return", "dictionary", "with", "stats", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L69-L128
222,341
python-diamond/Diamond
src/collectors/passenger_stats/passenger_stats.py
PassengerCollector.get_passenger_cpu_usage
def get_passenger_cpu_usage(self, dict_stats): """ Execute % top; and return STDOUT. """ try: proc1 = subprocess.Popen( ["top", "-b", "-n", "2"], stdout=subprocess.PIPE) (std_out, std_err) = proc1.communicate() except OSErro...
python
def get_passenger_cpu_usage(self, dict_stats): """ Execute % top; and return STDOUT. """ try: proc1 = subprocess.Popen( ["top", "-b", "-n", "2"], stdout=subprocess.PIPE) (std_out, std_err) = proc1.communicate() except OSErro...
[ "def", "get_passenger_cpu_usage", "(", "self", ",", "dict_stats", ")", ":", "try", ":", "proc1", "=", "subprocess", ".", "Popen", "(", "[", "\"top\"", ",", "\"-b\"", ",", "\"-n\"", ",", "\"2\"", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", ...
Execute % top; and return STDOUT.
[ "Execute", "%", "top", ";", "and", "return", "STDOUT", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L130-L158
222,342
python-diamond/Diamond
src/collectors/passenger_stats/passenger_stats.py
PassengerCollector.get_passenger_queue_stats
def get_passenger_queue_stats(self): """ Execute passenger-stats, parse its output, returnand requests in queue """ queue_stats = { "top_level_queue_size": 0.0, "passenger_queue_size": 0.0, } command = [self.config["passenger_status_bin"]] ...
python
def get_passenger_queue_stats(self): """ Execute passenger-stats, parse its output, returnand requests in queue """ queue_stats = { "top_level_queue_size": 0.0, "passenger_queue_size": 0.0, } command = [self.config["passenger_status_bin"]] ...
[ "def", "get_passenger_queue_stats", "(", "self", ")", ":", "queue_stats", "=", "{", "\"top_level_queue_size\"", ":", "0.0", ",", "\"passenger_queue_size\"", ":", "0.0", ",", "}", "command", "=", "[", "self", ".", "config", "[", "\"passenger_status_bin\"", "]", "...
Execute passenger-stats, parse its output, returnand requests in queue
[ "Execute", "passenger", "-", "stats", "parse", "its", "output", "returnand", "requests", "in", "queue" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L160-L209
222,343
python-diamond/Diamond
src/collectors/passenger_stats/passenger_stats.py
PassengerCollector.collect
def collect(self): """ Collector Passenger stats """ if not os.access(self.config["bin"], os.X_OK): self.log.error("Path %s does not exist or is not executable", self.config["bin"]) return {} dict_stats = self.get_passenger_memo...
python
def collect(self): """ Collector Passenger stats """ if not os.access(self.config["bin"], os.X_OK): self.log.error("Path %s does not exist or is not executable", self.config["bin"]) return {} dict_stats = self.get_passenger_memo...
[ "def", "collect", "(", "self", ")", ":", "if", "not", "os", ".", "access", "(", "self", ".", "config", "[", "\"bin\"", "]", ",", "os", ".", "X_OK", ")", ":", "self", ".", "log", ".", "error", "(", "\"Path %s does not exist or is not executable\"", ",", ...
Collector Passenger stats
[ "Collector", "Passenger", "stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L211-L243
222,344
python-diamond/Diamond
src/collectors/haproxy/haproxy.py
HAProxyCollector._collect
def _collect(self, section=None): """ Collect HAProxy Stats """ if self.config['method'] == 'http': csv_data = self.http_get_csv_data(section) elif self.config['method'] == 'unix': csv_data = self.unix_get_csv_data() else: self.log.erro...
python
def _collect(self, section=None): """ Collect HAProxy Stats """ if self.config['method'] == 'http': csv_data = self.http_get_csv_data(section) elif self.config['method'] == 'unix': csv_data = self.unix_get_csv_data() else: self.log.erro...
[ "def", "_collect", "(", "self", ",", "section", "=", "None", ")", ":", "if", "self", ".", "config", "[", "'method'", "]", "==", "'http'", ":", "csv_data", "=", "self", ".", "http_get_csv_data", "(", "section", ")", "elif", "self", ".", "config", "[", ...
Collect HAProxy Stats
[ "Collect", "HAProxy", "Stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/haproxy/haproxy.py#L137-L170
222,345
python-diamond/Diamond
src/collectors/processresources/processresources.py
match_process
def match_process(pid, name, cmdline, exe, cfg): """ Decides whether a process matches with a given process descriptor :param pid: process pid :param exe: process executable :param name: process name :param cmdline: process cmdline :param cfg: the dictionary from processes that describes wi...
python
def match_process(pid, name, cmdline, exe, cfg): """ Decides whether a process matches with a given process descriptor :param pid: process pid :param exe: process executable :param name: process name :param cmdline: process cmdline :param cfg: the dictionary from processes that describes wi...
[ "def", "match_process", "(", "pid", ",", "name", ",", "cmdline", ",", "exe", ",", "cfg", ")", ":", "if", "cfg", "[", "'selfmon'", "]", "and", "pid", "==", "os", ".", "getpid", "(", ")", ":", "return", "True", "for", "exe_re", "in", "cfg", "[", "'...
Decides whether a process matches with a given process descriptor :param pid: process pid :param exe: process executable :param name: process name :param cmdline: process cmdline :param cfg: the dictionary from processes that describes with the process group we're testing for :return: T...
[ "Decides", "whether", "a", "process", "matches", "with", "a", "given", "process", "descriptor" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/processresources/processresources.py#L49-L73
222,346
python-diamond/Diamond
src/collectors/processresources/processresources.py
ProcessResourcesCollector.collect
def collect(self): """ Collects resources usage of each process defined under the `process` subsection of the config file """ if not psutil: self.log.error('Unable to import psutil') self.log.error('No process resource metrics retrieved') retur...
python
def collect(self): """ Collects resources usage of each process defined under the `process` subsection of the config file """ if not psutil: self.log.error('Unable to import psutil') self.log.error('No process resource metrics retrieved') retur...
[ "def", "collect", "(", "self", ")", ":", "if", "not", "psutil", ":", "self", ".", "log", ".", "error", "(", "'Unable to import psutil'", ")", "self", ".", "log", ".", "error", "(", "'No process resource metrics retrieved'", ")", "return", "None", "for", "pro...
Collects resources usage of each process defined under the `process` subsection of the config file
[ "Collects", "resources", "usage", "of", "each", "process", "defined", "under", "the", "process", "subsection", "of", "the", "config", "file" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/processresources/processresources.py#L187-L214
222,347
python-diamond/Diamond
src/diamond/metric.py
Metric.parse
def parse(cls, string): """ Parse a string and create a metric """ match = re.match(r'^(?P<name>[A-Za-z0-9\.\-_]+)\s+' + '(?P<value>[0-9\.]+)\s+' + '(?P<timestamp>[0-9\.]+)(\n?)$', string) try: ...
python
def parse(cls, string): """ Parse a string and create a metric """ match = re.match(r'^(?P<name>[A-Za-z0-9\.\-_]+)\s+' + '(?P<value>[0-9\.]+)\s+' + '(?P<timestamp>[0-9\.]+)(\n?)$', string) try: ...
[ "def", "parse", "(", "cls", ",", "string", ")", ":", "match", "=", "re", ".", "match", "(", "r'^(?P<name>[A-Za-z0-9\\.\\-_]+)\\s+'", "+", "'(?P<value>[0-9\\.]+)\\s+'", "+", "'(?P<timestamp>[0-9\\.]+)(\\n?)$'", ",", "string", ")", "try", ":", "groups", "=", "match"...
Parse a string and create a metric
[ "Parse", "a", "string", "and", "create", "a", "metric" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/metric.py#L100-L116
222,348
python-diamond/Diamond
src/diamond/metric.py
Metric.getPathPrefix
def getPathPrefix(self): """ Returns the path prefix path servers.host.cpu.total.idle return "servers" """ # If we don't have a host name, assume it's just the first part of the # metric path if self.host is None: return self.path.s...
python
def getPathPrefix(self): """ Returns the path prefix path servers.host.cpu.total.idle return "servers" """ # If we don't have a host name, assume it's just the first part of the # metric path if self.host is None: return self.path.s...
[ "def", "getPathPrefix", "(", "self", ")", ":", "# If we don't have a host name, assume it's just the first part of the", "# metric path", "if", "self", ".", "host", "is", "None", ":", "return", "self", ".", "path", ".", "split", "(", "'.'", ")", "[", "0", "]", "...
Returns the path prefix path servers.host.cpu.total.idle return "servers"
[ "Returns", "the", "path", "prefix", "path", "servers", ".", "host", ".", "cpu", ".", "total", ".", "idle", "return", "servers" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/metric.py#L118-L130
222,349
python-diamond/Diamond
src/diamond/metric.py
Metric.getCollectorPath
def getCollectorPath(self): """ Returns collector path servers.host.cpu.total.idle return "cpu" """ # If we don't have a host name, assume it's just the third part of the # metric path if self.host is None: return self.path.split('....
python
def getCollectorPath(self): """ Returns collector path servers.host.cpu.total.idle return "cpu" """ # If we don't have a host name, assume it's just the third part of the # metric path if self.host is None: return self.path.split('....
[ "def", "getCollectorPath", "(", "self", ")", ":", "# If we don't have a host name, assume it's just the third part of the", "# metric path", "if", "self", ".", "host", "is", "None", ":", "return", "self", ".", "path", ".", "split", "(", "'.'", ")", "[", "2", "]", ...
Returns collector path servers.host.cpu.total.idle return "cpu"
[ "Returns", "collector", "path", "servers", ".", "host", ".", "cpu", ".", "total", ".", "idle", "return", "cpu" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/metric.py#L132-L146
222,350
python-diamond/Diamond
src/diamond/metric.py
Metric.getMetricPath
def getMetricPath(self): """ Returns the metric path after the collector name servers.host.cpu.total.idle return "total.idle" """ # If we don't have a host name, assume it's just the fourth+ part of the # metric path if self.host is None: ...
python
def getMetricPath(self): """ Returns the metric path after the collector name servers.host.cpu.total.idle return "total.idle" """ # If we don't have a host name, assume it's just the fourth+ part of the # metric path if self.host is None: ...
[ "def", "getMetricPath", "(", "self", ")", ":", "# If we don't have a host name, assume it's just the fourth+ part of the", "# metric path", "if", "self", ".", "host", "is", "None", ":", "path", "=", "self", ".", "path", ".", "split", "(", "'.'", ")", "[", "3", "...
Returns the metric path after the collector name servers.host.cpu.total.idle return "total.idle"
[ "Returns", "the", "metric", "path", "after", "the", "collector", "name", "servers", ".", "host", ".", "cpu", ".", "total", ".", "idle", "return", "total", ".", "idle" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/metric.py#L148-L164
222,351
python-diamond/Diamond
src/diamond/handler/Handler.py
Handler._process
def _process(self, metric): """ Decorator for processing handlers with a lock, catching exceptions """ if not self.enabled: return try: try: self.lock.acquire() self.process(metric) except Exception: ...
python
def _process(self, metric): """ Decorator for processing handlers with a lock, catching exceptions """ if not self.enabled: return try: try: self.lock.acquire() self.process(metric) except Exception: ...
[ "def", "_process", "(", "self", ",", "metric", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "try", ":", "try", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "process", "(", "metric", ")", "except", "Exception", "...
Decorator for processing handlers with a lock, catching exceptions
[ "Decorator", "for", "processing", "handlers", "with", "a", "lock", "catching", "exceptions" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/Handler.py#L65-L79
222,352
python-diamond/Diamond
src/diamond/handler/Handler.py
Handler._flush
def _flush(self): """ Decorator for flushing handlers with an lock, catching exceptions """ if not self.enabled: return try: try: self.lock.acquire() self.flush() except Exception: self.log.error(...
python
def _flush(self): """ Decorator for flushing handlers with an lock, catching exceptions """ if not self.enabled: return try: try: self.lock.acquire() self.flush() except Exception: self.log.error(...
[ "def", "_flush", "(", "self", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "try", ":", "try", ":", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "flush", "(", ")", "except", "Exception", ":", "self", ".", "log", "."...
Decorator for flushing handlers with an lock, catching exceptions
[ "Decorator", "for", "flushing", "handlers", "with", "an", "lock", "catching", "exceptions" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/Handler.py#L89-L103
222,353
python-diamond/Diamond
src/diamond/handler/Handler.py
Handler._throttle_error
def _throttle_error(self, msg, *args, **kwargs): """ Avoids sending errors repeatedly. Waits at least `self.server_error_interval` seconds before sending the same error string to the error logging facility. If not enough time has passed, it calls `log.debug` instead Rece...
python
def _throttle_error(self, msg, *args, **kwargs): """ Avoids sending errors repeatedly. Waits at least `self.server_error_interval` seconds before sending the same error string to the error logging facility. If not enough time has passed, it calls `log.debug` instead Rece...
[ "def", "_throttle_error", "(", "self", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "msg", "in", "self", ".", "_errors", ":", "if", "(", "(", "now", "-", "self", ".", "_errors...
Avoids sending errors repeatedly. Waits at least `self.server_error_interval` seconds before sending the same error string to the error logging facility. If not enough time has passed, it calls `log.debug` instead Receives the same parameters as `Logger.error` an passes them on to the ...
[ "Avoids", "sending", "errors", "repeatedly", ".", "Waits", "at", "least", "self", ".", "server_error_interval", "seconds", "before", "sending", "the", "same", "error", "string", "to", "the", "error", "logging", "facility", ".", "If", "not", "enough", "time", "...
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/Handler.py#L113-L138
222,354
python-diamond/Diamond
src/diamond/handler/Handler.py
Handler._reset_errors
def _reset_errors(self, msg=None): """ Resets the logging throttle cache, so the next error is emitted regardless of the value in `self.server_error_interval` :param msg: if present, only this key is reset. Otherwise, the whole cache is cleaned. """ if msg is...
python
def _reset_errors(self, msg=None): """ Resets the logging throttle cache, so the next error is emitted regardless of the value in `self.server_error_interval` :param msg: if present, only this key is reset. Otherwise, the whole cache is cleaned. """ if msg is...
[ "def", "_reset_errors", "(", "self", ",", "msg", "=", "None", ")", ":", "if", "msg", "is", "not", "None", "and", "msg", "in", "self", ".", "_errors", ":", "del", "self", ".", "_errors", "[", "msg", "]", "else", ":", "self", ".", "_errors", "=", "...
Resets the logging throttle cache, so the next error is emitted regardless of the value in `self.server_error_interval` :param msg: if present, only this key is reset. Otherwise, the whole cache is cleaned.
[ "Resets", "the", "logging", "throttle", "cache", "so", "the", "next", "error", "is", "emitted", "regardless", "of", "the", "value", "in", "self", ".", "server_error_interval" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/Handler.py#L140-L151
222,355
python-diamond/Diamond
src/diamond/utils/signals.py
signal_to_exception
def signal_to_exception(signum, frame): """ Called by the timeout alarm during the collector run time """ if signum == signal.SIGALRM: raise SIGALRMException() if signum == signal.SIGHUP: raise SIGHUPException() if signum == signal.SIGUSR1: raise SIGUSR1Exception() if...
python
def signal_to_exception(signum, frame): """ Called by the timeout alarm during the collector run time """ if signum == signal.SIGALRM: raise SIGALRMException() if signum == signal.SIGHUP: raise SIGHUPException() if signum == signal.SIGUSR1: raise SIGUSR1Exception() if...
[ "def", "signal_to_exception", "(", "signum", ",", "frame", ")", ":", "if", "signum", "==", "signal", ".", "SIGALRM", ":", "raise", "SIGALRMException", "(", ")", "if", "signum", "==", "signal", ".", "SIGHUP", ":", "raise", "SIGHUPException", "(", ")", "if",...
Called by the timeout alarm during the collector run time
[ "Called", "by", "the", "timeout", "alarm", "during", "the", "collector", "run", "time" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/signals.py#L6-L18
222,356
python-diamond/Diamond
src/collectors/servertechpdu/servertechpdu.py
ServerTechPDUCollector.collect_snmp
def collect_snmp(self, device, host, port, community): """ Collect stats from device """ # Log self.log.info("Collecting ServerTech PDU statistics from: %s" % device) # Set timestamp timestamp = time.time() inputFeeds = {} # Collect PDU input ga...
python
def collect_snmp(self, device, host, port, community): """ Collect stats from device """ # Log self.log.info("Collecting ServerTech PDU statistics from: %s" % device) # Set timestamp timestamp = time.time() inputFeeds = {} # Collect PDU input ga...
[ "def", "collect_snmp", "(", "self", ",", "device", ",", "host", ",", "port", ",", "community", ")", ":", "# Log", "self", ".", "log", ".", "info", "(", "\"Collecting ServerTech PDU statistics from: %s\"", "%", "device", ")", "# Set timestamp", "timestamp", "=", ...
Collect stats from device
[ "Collect", "stats", "from", "device" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/servertechpdu/servertechpdu.py#L66-L129
222,357
python-diamond/Diamond
src/collectors/users/users.py
UsersCollector.get_default_config_help
def get_default_config_help(self): """ Returns the default collector help text """ config_help = super(UsersCollector, self).get_default_config_help() config_help.update({ }) return config_help
python
def get_default_config_help(self): """ Returns the default collector help text """ config_help = super(UsersCollector, self).get_default_config_help() config_help.update({ }) return config_help
[ "def", "get_default_config_help", "(", "self", ")", ":", "config_help", "=", "super", "(", "UsersCollector", ",", "self", ")", ".", "get_default_config_help", "(", ")", "config_help", ".", "update", "(", "{", "}", ")", "return", "config_help" ]
Returns the default collector help text
[ "Returns", "the", "default", "collector", "help", "text" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/users/users.py#L29-L36
222,358
python-diamond/Diamond
src/diamond/handler/stats_d.py
StatsdHandler._send
def _send(self): """ Send data to statsd. Fire and forget. Cross fingers and it'll arrive. """ if not statsd: return for metric in self.metrics: # Split the path into a prefix and a name # to work with the statsd module's view of the world. ...
python
def _send(self): """ Send data to statsd. Fire and forget. Cross fingers and it'll arrive. """ if not statsd: return for metric in self.metrics: # Split the path into a prefix and a name # to work with the statsd module's view of the world. ...
[ "def", "_send", "(", "self", ")", ":", "if", "not", "statsd", ":", "return", "for", "metric", "in", "self", ".", "metrics", ":", "# Split the path into a prefix and a name", "# to work with the statsd module's view of the world.", "# It will get re-joined by the python-statsd...
Send data to statsd. Fire and forget. Cross fingers and it'll arrive.
[ "Send", "data", "to", "statsd", ".", "Fire", "and", "forget", ".", "Cross", "fingers", "and", "it", "ll", "arrive", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/stats_d.py#L106-L145
222,359
python-diamond/Diamond
src/diamond/handler/stats_d.py
StatsdHandler._connect
def _connect(self): """ Connect to the statsd server """ if not statsd: return if hasattr(statsd, 'StatsClient'): self.connection = statsd.StatsClient( host=self.host, port=self.port ).pipeline() else: ...
python
def _connect(self): """ Connect to the statsd server """ if not statsd: return if hasattr(statsd, 'StatsClient'): self.connection = statsd.StatsClient( host=self.host, port=self.port ).pipeline() else: ...
[ "def", "_connect", "(", "self", ")", ":", "if", "not", "statsd", ":", "return", "if", "hasattr", "(", "statsd", ",", "'StatsClient'", ")", ":", "self", ".", "connection", "=", "statsd", ".", "StatsClient", "(", "host", "=", "self", ".", "host", ",", ...
Connect to the statsd server
[ "Connect", "to", "the", "statsd", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/stats_d.py#L151-L169
222,360
python-diamond/Diamond
src/diamond/handler/signalfx.py
SignalfxHandler._match_metric
def _match_metric(self, metric): """ matches the metric path, if the metrics are empty, it shorts to True """ if len(self._compiled_filters) == 0: return True for (collector, filter_regex) in self._compiled_filters: if collector != metric.getCollectorPath(...
python
def _match_metric(self, metric): """ matches the metric path, if the metrics are empty, it shorts to True """ if len(self._compiled_filters) == 0: return True for (collector, filter_regex) in self._compiled_filters: if collector != metric.getCollectorPath(...
[ "def", "_match_metric", "(", "self", ",", "metric", ")", ":", "if", "len", "(", "self", ".", "_compiled_filters", ")", "==", "0", ":", "return", "True", "for", "(", "collector", ",", "filter_regex", ")", "in", "self", ".", "_compiled_filters", ":", "if",...
matches the metric path, if the metrics are empty, it shorts to True
[ "matches", "the", "metric", "path", "if", "the", "metrics", "are", "empty", "it", "shorts", "to", "True" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/signalfx.py#L55-L66
222,361
python-diamond/Diamond
src/diamond/handler/signalfx.py
SignalfxHandler.process
def process(self, metric): """ Queue a metric. Flushing queue if batch size reached """ if self._match_metric(metric): self.metrics.append(metric) if self.should_flush(): self._send()
python
def process(self, metric): """ Queue a metric. Flushing queue if batch size reached """ if self._match_metric(metric): self.metrics.append(metric) if self.should_flush(): self._send()
[ "def", "process", "(", "self", ",", "metric", ")", ":", "if", "self", ".", "_match_metric", "(", "metric", ")", ":", "self", ".", "metrics", ".", "append", "(", "metric", ")", "if", "self", ".", "should_flush", "(", ")", ":", "self", ".", "_send", ...
Queue a metric. Flushing queue if batch size reached
[ "Queue", "a", "metric", ".", "Flushing", "queue", "if", "batch", "size", "reached" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/signalfx.py#L103-L110
222,362
python-diamond/Diamond
src/diamond/handler/signalfx.py
SignalfxHandler.into_signalfx_point
def into_signalfx_point(self, metric): """ Convert diamond metric into something signalfx can understand """ dims = { "collector": metric.getCollectorPath(), "prefix": metric.getPathPrefix(), } if metric.host is not None and metric.host != "": ...
python
def into_signalfx_point(self, metric): """ Convert diamond metric into something signalfx can understand """ dims = { "collector": metric.getCollectorPath(), "prefix": metric.getPathPrefix(), } if metric.host is not None and metric.host != "": ...
[ "def", "into_signalfx_point", "(", "self", ",", "metric", ")", ":", "dims", "=", "{", "\"collector\"", ":", "metric", ".", "getCollectorPath", "(", ")", ",", "\"prefix\"", ":", "metric", ".", "getPathPrefix", "(", ")", ",", "}", "if", "metric", ".", "hos...
Convert diamond metric into something signalfx can understand
[ "Convert", "diamond", "metric", "into", "something", "signalfx", "can", "understand" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/signalfx.py#L116-L133
222,363
python-diamond/Diamond
src/diamond/gmetric.py
gmetric_write
def gmetric_write(NAME, VAL, TYPE, UNITS, SLOPE, TMAX, DMAX, GROUP): """ Arguments are in all upper-case to match XML """ packer = Packer() HOSTNAME = "test" SPOOF = 0 # Meta data about a metric packer.pack_int(128) packer.pack_string(HOSTNAME) packer.pack_string(NAME) packer...
python
def gmetric_write(NAME, VAL, TYPE, UNITS, SLOPE, TMAX, DMAX, GROUP): """ Arguments are in all upper-case to match XML """ packer = Packer() HOSTNAME = "test" SPOOF = 0 # Meta data about a metric packer.pack_int(128) packer.pack_string(HOSTNAME) packer.pack_string(NAME) packer...
[ "def", "gmetric_write", "(", "NAME", ",", "VAL", ",", "TYPE", ",", "UNITS", ",", "SLOPE", ",", "TMAX", ",", "DMAX", ",", "GROUP", ")", ":", "packer", "=", "Packer", "(", ")", "HOSTNAME", "=", "\"test\"", "SPOOF", "=", "0", "# Meta data about a metric", ...
Arguments are in all upper-case to match XML
[ "Arguments", "are", "in", "all", "upper", "-", "case", "to", "match", "XML" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/gmetric.py#L103-L138
222,364
python-diamond/Diamond
src/collectors/disktemp/disktemp.py
DiskTemperatureCollector.collect
def collect(self): """ Collect and publish disk temperatures """ instances = {} # Support disks such as /dev/(sd.*) for device in os.listdir('/dev/'): instances.update(self.match_device(device, '/dev/')) # Support disk by id such as /dev/disk/by-id/w...
python
def collect(self): """ Collect and publish disk temperatures """ instances = {} # Support disks such as /dev/(sd.*) for device in os.listdir('/dev/'): instances.update(self.match_device(device, '/dev/')) # Support disk by id such as /dev/disk/by-id/w...
[ "def", "collect", "(", "self", ")", ":", "instances", "=", "{", "}", "# Support disks such as /dev/(sd.*)", "for", "device", "in", "os", ".", "listdir", "(", "'/dev/'", ")", ":", "instances", ".", "update", "(", "self", ".", "match_device", "(", "device", ...
Collect and publish disk temperatures
[ "Collect", "and", "publish", "disk", "temperatures" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/disktemp/disktemp.py#L76-L100
222,365
python-diamond/Diamond
src/collectors/elasticsearch/elasticsearch.py
ElasticSearchCollector._get
def _get(self, scheme, host, port, path, assert_key=None): """ Execute a ES API call. Convert response into JSON and optionally assert its structure. """ url = '%s://%s:%i/%s' % (scheme, host, port, path) try: request = urllib2.Request(url) if self...
python
def _get(self, scheme, host, port, path, assert_key=None): """ Execute a ES API call. Convert response into JSON and optionally assert its structure. """ url = '%s://%s:%i/%s' % (scheme, host, port, path) try: request = urllib2.Request(url) if self...
[ "def", "_get", "(", "self", ",", "scheme", ",", "host", ",", "port", ",", "path", ",", "assert_key", "=", "None", ")", ":", "url", "=", "'%s://%s:%i/%s'", "%", "(", "scheme", ",", "host", ",", "port", ",", "path", ")", "try", ":", "request", "=", ...
Execute a ES API call. Convert response into JSON and optionally assert its structure.
[ "Execute", "a", "ES", "API", "call", ".", "Convert", "response", "into", "JSON", "and", "optionally", "assert", "its", "structure", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/elasticsearch/elasticsearch.py#L107-L135
222,366
python-diamond/Diamond
src/collectors/elasticsearch/elasticsearch.py
ElasticSearchCollector._set_or_sum_metric
def _set_or_sum_metric(self, metrics, metric_path, value): """If we already have a datapoint for this metric, lets add the value. This is used when the logstash mode is enabled.""" if metric_path in metrics: metrics[metric_path] += value else: metrics[metric_path]...
python
def _set_or_sum_metric(self, metrics, metric_path, value): """If we already have a datapoint for this metric, lets add the value. This is used when the logstash mode is enabled.""" if metric_path in metrics: metrics[metric_path] += value else: metrics[metric_path]...
[ "def", "_set_or_sum_metric", "(", "self", ",", "metrics", ",", "metric_path", ",", "value", ")", ":", "if", "metric_path", "in", "metrics", ":", "metrics", "[", "metric_path", "]", "+=", "value", "else", ":", "metrics", "[", "metric_path", "]", "=", "value...
If we already have a datapoint for this metric, lets add the value. This is used when the logstash mode is enabled.
[ "If", "we", "already", "have", "a", "datapoint", "for", "this", "metric", "lets", "add", "the", "value", ".", "This", "is", "used", "when", "the", "logstash", "mode", "is", "enabled", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/elasticsearch/elasticsearch.py#L183-L189
222,367
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector._client
def _client(self, host, port, unix_socket, auth): """Return a redis client for the configuration. :param str host: redis host :param int port: redis port :rtype: redis.Redis """ db = int(self.config['db']) timeout = int(self.config['timeout']) try: cli = redis.Redis...
python
def _client(self, host, port, unix_socket, auth): """Return a redis client for the configuration. :param str host: redis host :param int port: redis port :rtype: redis.Redis """ db = int(self.config['db']) timeout = int(self.config['timeout']) try: cli = redis.Redis...
[ "def", "_client", "(", "self", ",", "host", ",", "port", ",", "unix_socket", ",", "auth", ")", ":", "db", "=", "int", "(", "self", ".", "config", "[", "'db'", "]", ")", "timeout", "=", "int", "(", "self", ".", "config", "[", "'timeout'", "]", ")"...
Return a redis client for the configuration. :param str host: redis host :param int port: redis port :rtype: redis.Redis
[ "Return", "a", "redis", "client", "for", "the", "configuration", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L209-L227
222,368
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector._precision
def _precision(self, value): """Return the precision of the number :param str value: The value to find the precision of :rtype: int """ value = str(value) decimal = value.rfind('.') if decimal == -1: return 0 return len(value) - decimal - 1
python
def _precision(self, value): """Return the precision of the number :param str value: The value to find the precision of :rtype: int """ value = str(value) decimal = value.rfind('.') if decimal == -1: return 0 return len(value) - decimal - 1
[ "def", "_precision", "(", "self", ",", "value", ")", ":", "value", "=", "str", "(", "value", ")", "decimal", "=", "value", ".", "rfind", "(", "'.'", ")", "if", "decimal", "==", "-", "1", ":", "return", "0", "return", "len", "(", "value", ")", "-"...
Return the precision of the number :param str value: The value to find the precision of :rtype: int
[ "Return", "the", "precision", "of", "the", "number" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L229-L240
222,369
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector._get_info
def _get_info(self, host, port, unix_socket, auth): """Return info dict from specified Redis instance :param str host: redis host :param int port: redis port :rtype: dict """ client = self._client(host, port, unix_socket, auth) if client is None: return None info ...
python
def _get_info(self, host, port, unix_socket, auth): """Return info dict from specified Redis instance :param str host: redis host :param int port: redis port :rtype: dict """ client = self._client(host, port, unix_socket, auth) if client is None: return None info ...
[ "def", "_get_info", "(", "self", ",", "host", ",", "port", ",", "unix_socket", ",", "auth", ")", ":", "client", "=", "self", ".", "_client", "(", "host", ",", "port", ",", "unix_socket", ",", "auth", ")", "if", "client", "is", "None", ":", "return", ...
Return info dict from specified Redis instance :param str host: redis host :param int port: redis port :rtype: dict
[ "Return", "info", "dict", "from", "specified", "Redis", "instance" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L252-L267
222,370
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector._get_config
def _get_config(self, host, port, unix_socket, auth, config_key): """Return config string from specified Redis instance and config key :param str host: redis host :param int port: redis port :param str host: redis config_key :rtype: str """ client = self._client(host, port, unix_socket, auth)...
python
def _get_config(self, host, port, unix_socket, auth, config_key): """Return config string from specified Redis instance and config key :param str host: redis host :param int port: redis port :param str host: redis config_key :rtype: str """ client = self._client(host, port, unix_socket, auth)...
[ "def", "_get_config", "(", "self", ",", "host", ",", "port", ",", "unix_socket", ",", "auth", ",", "config_key", ")", ":", "client", "=", "self", ".", "_client", "(", "host", ",", "port", ",", "unix_socket", ",", "auth", ")", "if", "client", "is", "N...
Return config string from specified Redis instance and config key :param str host: redis host :param int port: redis port :param str host: redis config_key :rtype: str
[ "Return", "config", "string", "from", "specified", "Redis", "instance", "and", "config", "key" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L269-L285
222,371
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector.collect_instance
def collect_instance(self, nick, host, port, unix_socket, auth): """Collect metrics from a single Redis instance :param str nick: nickname of redis instance :param str host: redis host :param int port: redis port :param str unix_socket: unix socket, if applicable :param str auth: authentication password ...
python
def collect_instance(self, nick, host, port, unix_socket, auth): """Collect metrics from a single Redis instance :param str nick: nickname of redis instance :param str host: redis host :param int port: redis port :param str unix_socket: unix socket, if applicable :param str auth: authentication password ...
[ "def", "collect_instance", "(", "self", ",", "nick", ",", "host", ",", "port", ",", "unix_socket", ",", "auth", ")", ":", "# Connect to redis and get the info", "info", "=", "self", ".", "_get_info", "(", "host", ",", "port", ",", "unix_socket", ",", "auth",...
Collect metrics from a single Redis instance :param str nick: nickname of redis instance :param str host: redis host :param int port: redis port :param str unix_socket: unix socket, if applicable :param str auth: authentication password
[ "Collect", "metrics", "from", "a", "single", "Redis", "instance" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L287-L363
222,372
python-diamond/Diamond
src/collectors/redisstat/redisstat.py
RedisCollector.collect
def collect(self): """Collect the stats from the redis instance and publish them. """ if redis is None: self.log.error('Unable to import module redis') return {} for nick in self.instances.keys(): (host, port, unix_socket, auth) = self.instances[nick...
python
def collect(self): """Collect the stats from the redis instance and publish them. """ if redis is None: self.log.error('Unable to import module redis') return {} for nick in self.instances.keys(): (host, port, unix_socket, auth) = self.instances[nick...
[ "def", "collect", "(", "self", ")", ":", "if", "redis", "is", "None", ":", "self", ".", "log", ".", "error", "(", "'Unable to import module redis'", ")", "return", "{", "}", "for", "nick", "in", "self", ".", "instances", ".", "keys", "(", ")", ":", "...
Collect the stats from the redis instance and publish them.
[ "Collect", "the", "stats", "from", "the", "redis", "instance", "and", "publish", "them", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/redisstat/redisstat.py#L365-L375
222,373
python-diamond/Diamond
src/collectors/xfs/xfs.py
XFSCollector.get_default_config
def get_default_config(self): """ Returns the xfs collector settings """ config = super(XFSCollector, self).get_default_config() config.update({ 'path': 'xfs' }) return config
python
def get_default_config(self): """ Returns the xfs collector settings """ config = super(XFSCollector, self).get_default_config() config.update({ 'path': 'xfs' }) return config
[ "def", "get_default_config", "(", "self", ")", ":", "config", "=", "super", "(", "XFSCollector", ",", "self", ")", ".", "get_default_config", "(", ")", "config", ".", "update", "(", "{", "'path'", ":", "'xfs'", "}", ")", "return", "config" ]
Returns the xfs collector settings
[ "Returns", "the", "xfs", "collector", "settings" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/xfs/xfs.py#L25-L33
222,374
python-diamond/Diamond
src/diamond/handler/cloudwatch.py
cloudwatchHandler._bind
def _bind(self): """ Create CloudWatch Connection """ self.log.debug( "CloudWatch: Attempting to connect to CloudWatch at Region: %s", self.region) try: self.connection = boto.ec2.cloudwatch.connect_to_region( self.region) ...
python
def _bind(self): """ Create CloudWatch Connection """ self.log.debug( "CloudWatch: Attempting to connect to CloudWatch at Region: %s", self.region) try: self.connection = boto.ec2.cloudwatch.connect_to_region( self.region) ...
[ "def", "_bind", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"CloudWatch: Attempting to connect to CloudWatch at Region: %s\"", ",", "self", ".", "region", ")", "try", ":", "self", ".", "connection", "=", "boto", ".", "ec2", ".", "cloudwatch...
Create CloudWatch Connection
[ "Create", "CloudWatch", "Connection" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/cloudwatch.py#L163-L178
222,375
python-diamond/Diamond
src/diamond/handler/cloudwatch.py
cloudwatchHandler.process
def process(self, metric): """ Process a metric and send it to CloudWatch """ if not boto: return collector = str(metric.getCollectorPath()) metricname = str(metric.getMetricPath()) # Send the data as ...... for rule in self.rules: ...
python
def process(self, metric): """ Process a metric and send it to CloudWatch """ if not boto: return collector = str(metric.getCollectorPath()) metricname = str(metric.getMetricPath()) # Send the data as ...... for rule in self.rules: ...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "if", "not", "boto", ":", "return", "collector", "=", "str", "(", "metric", ".", "getCollectorPath", "(", ")", ")", "metricname", "=", "str", "(", "metric", ".", "getMetricPath", "(", ")", ")", ...
Process a metric and send it to CloudWatch
[ "Process", "a", "metric", "and", "send", "it", "to", "CloudWatch" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/cloudwatch.py#L189-L224
222,376
python-diamond/Diamond
src/diamond/handler/cloudwatch.py
cloudwatchHandler.send_metrics_to_cloudwatch
def send_metrics_to_cloudwatch(self, rule, metric, dimensions): """ Send metrics to CloudWatch for the given dimensions """ timestamp = datetime.datetime.utcfromtimestamp(metric.timestamp) self.log.debug( "CloudWatch: Attempting to publish metric: %s to %s " ...
python
def send_metrics_to_cloudwatch(self, rule, metric, dimensions): """ Send metrics to CloudWatch for the given dimensions """ timestamp = datetime.datetime.utcfromtimestamp(metric.timestamp) self.log.debug( "CloudWatch: Attempting to publish metric: %s to %s " ...
[ "def", "send_metrics_to_cloudwatch", "(", "self", ",", "rule", ",", "metric", ",", "dimensions", ")", ":", "timestamp", "=", "datetime", ".", "datetime", ".", "utcfromtimestamp", "(", "metric", ".", "timestamp", ")", "self", ".", "log", ".", "debug", "(", ...
Send metrics to CloudWatch for the given dimensions
[ "Send", "metrics", "to", "CloudWatch", "for", "the", "given", "dimensions" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/cloudwatch.py#L226-L265
222,377
python-diamond/Diamond
src/collectors/mongodb/mongodb.py
MongoDBCollector._publish_replset
def _publish_replset(self, data, base_prefix): """ Given a response to replSetGetStatus, publishes all numeric values of the instance, aggregate stats of healthy nodes vs total nodes, and the observed statuses of all nodes in the replica set. """ prefix = base_prefix + ['...
python
def _publish_replset(self, data, base_prefix): """ Given a response to replSetGetStatus, publishes all numeric values of the instance, aggregate stats of healthy nodes vs total nodes, and the observed statuses of all nodes in the replica set. """ prefix = base_prefix + ['...
[ "def", "_publish_replset", "(", "self", ",", "data", ",", "base_prefix", ")", ":", "prefix", "=", "base_prefix", "+", "[", "'replset'", "]", "self", ".", "_publish_dict_with_prefix", "(", "data", ",", "prefix", ")", "total_nodes", "=", "len", "(", "data", ...
Given a response to replSetGetStatus, publishes all numeric values of the instance, aggregate stats of healthy nodes vs total nodes, and the observed statuses of all nodes in the replica set.
[ "Given", "a", "response", "to", "replSetGetStatus", "publishes", "all", "numeric", "values", "of", "the", "instance", "aggregate", "stats", "of", "healthy", "nodes", "vs", "total", "nodes", "and", "the", "observed", "statuses", "of", "all", "nodes", "in", "the...
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mongodb/mongodb.py#L230-L248
222,378
python-diamond/Diamond
src/diamond/handler/influxdbHandler.py
InfluxdbHandler._send
def _send(self): """ Send data to Influxdb. Data that can not be sent will be kept in queued. """ # Check to see if we have a valid socket. If not, try to connect. try: if self.influx is None: self.log.debug("InfluxdbHandler: Socket is not connected. "...
python
def _send(self): """ Send data to Influxdb. Data that can not be sent will be kept in queued. """ # Check to see if we have a valid socket. If not, try to connect. try: if self.influx is None: self.log.debug("InfluxdbHandler: Socket is not connected. "...
[ "def", "_send", "(", "self", ")", ":", "# Check to see if we have a valid socket. If not, try to connect.", "try", ":", "if", "self", ".", "influx", "is", "None", ":", "self", ".", "log", ".", "debug", "(", "\"InfluxdbHandler: Socket is not connected. \"", "\"Reconnecti...
Send data to Influxdb. Data that can not be sent will be kept in queued.
[ "Send", "data", "to", "Influxdb", ".", "Data", "that", "can", "not", "be", "sent", "will", "be", "kept", "in", "queued", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/influxdbHandler.py#L156-L194
222,379
python-diamond/Diamond
src/diamond/handler/influxdbHandler.py
InfluxdbHandler._connect
def _connect(self): """ Connect to the influxdb server """ try: # Open Connection self.influx = InfluxDBClient(self.hostname, self.port, self.username, self.password, self.database,...
python
def _connect(self): """ Connect to the influxdb server """ try: # Open Connection self.influx = InfluxDBClient(self.hostname, self.port, self.username, self.password, self.database,...
[ "def", "_connect", "(", "self", ")", ":", "try", ":", "# Open Connection", "self", ".", "influx", "=", "InfluxDBClient", "(", "self", ".", "hostname", ",", "self", ".", "port", ",", "self", ".", "username", ",", "self", ".", "password", ",", "self", "....
Connect to the influxdb server
[ "Connect", "to", "the", "influxdb", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/influxdbHandler.py#L196-L217
222,380
python-diamond/Diamond
src/diamond/handler/rabbitmq_pubsub.py
rmqHandler.get_config
def get_config(self): """ Get and set config options from config file """ if 'rmq_port' in self.config: self.rmq_port = int(self.config['rmq_port']) if 'rmq_user' in self.config: self.rmq_user = self.config['rmq_user'] if 'rmq_password' in self.config: ...
python
def get_config(self): """ Get and set config options from config file """ if 'rmq_port' in self.config: self.rmq_port = int(self.config['rmq_port']) if 'rmq_user' in self.config: self.rmq_user = self.config['rmq_user'] if 'rmq_password' in self.config: ...
[ "def", "get_config", "(", "self", ")", ":", "if", "'rmq_port'", "in", "self", ".", "config", ":", "self", ".", "rmq_port", "=", "int", "(", "self", ".", "config", "[", "'rmq_port'", "]", ")", "if", "'rmq_user'", "in", "self", ".", "config", ":", "sel...
Get and set config options from config file
[ "Get", "and", "set", "config", "options", "from", "config", "file" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_pubsub.py#L63-L85
222,381
python-diamond/Diamond
src/diamond/handler/rabbitmq_pubsub.py
rmqHandler._unbind
def _unbind(self, rmq_server=None): """ Close AMQP connection and unset channel """ try: self.connections[rmq_server].close() except AttributeError: pass self.connections[rmq_server] = None self.channels[rmq_server] = None
python
def _unbind(self, rmq_server=None): """ Close AMQP connection and unset channel """ try: self.connections[rmq_server].close() except AttributeError: pass self.connections[rmq_server] = None self.channels[rmq_server] = None
[ "def", "_unbind", "(", "self", ",", "rmq_server", "=", "None", ")", ":", "try", ":", "self", ".", "connections", "[", "rmq_server", "]", ".", "close", "(", ")", "except", "AttributeError", ":", "pass", "self", ".", "connections", "[", "rmq_server", "]", ...
Close AMQP connection and unset channel
[ "Close", "AMQP", "connection", "and", "unset", "channel" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_pubsub.py#L172-L180
222,382
python-diamond/Diamond
src/diamond/handler/rabbitmq_pubsub.py
rmqHandler.process
def process(self, metric): """ Process a metric and send it to RMQ pub socket """ for rmq_server in self.connections.keys(): try: if ((self.connections[rmq_server] is None or self.connections[rmq_server].is_open is False)): ...
python
def process(self, metric): """ Process a metric and send it to RMQ pub socket """ for rmq_server in self.connections.keys(): try: if ((self.connections[rmq_server] is None or self.connections[rmq_server].is_open is False)): ...
[ "def", "process", "(", "self", ",", "metric", ")", ":", "for", "rmq_server", "in", "self", ".", "connections", ".", "keys", "(", ")", ":", "try", ":", "if", "(", "(", "self", ".", "connections", "[", "rmq_server", "]", "is", "None", "or", "self", "...
Process a metric and send it to RMQ pub socket
[ "Process", "a", "metric", "and", "send", "it", "to", "RMQ", "pub", "socket" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_pubsub.py#L190-L209
222,383
python-diamond/Diamond
src/collectors/netstat/netstat.py
NetstatCollector._load
def _load(): """ Read the table of tcp connections & remove header """ with open(NetstatCollector.PROC_TCP, 'r') as f: content = f.readlines() content.pop(0) return content
python
def _load(): """ Read the table of tcp connections & remove header """ with open(NetstatCollector.PROC_TCP, 'r') as f: content = f.readlines() content.pop(0) return content
[ "def", "_load", "(", ")", ":", "with", "open", "(", "NetstatCollector", ".", "PROC_TCP", ",", "'r'", ")", "as", "f", ":", "content", "=", "f", ".", "readlines", "(", ")", "content", ".", "pop", "(", "0", ")", "return", "content" ]
Read the table of tcp connections & remove header
[ "Read", "the", "table", "of", "tcp", "connections", "&", "remove", "header" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netstat/netstat.py#L62-L67
222,384
python-diamond/Diamond
src/collectors/memory_lxc/memory_lxc.py
MemoryLxcCollector.get_default_config_help
def get_default_config_help(self): """ Return help text for collector configuration. """ config_help = super(MemoryLxcCollector, self).get_default_config_help() config_help.update({ "sys_path": "Defaults to '/sys/fs/cgroup/lxc'", }) return config_help
python
def get_default_config_help(self): """ Return help text for collector configuration. """ config_help = super(MemoryLxcCollector, self).get_default_config_help() config_help.update({ "sys_path": "Defaults to '/sys/fs/cgroup/lxc'", }) return config_help
[ "def", "get_default_config_help", "(", "self", ")", ":", "config_help", "=", "super", "(", "MemoryLxcCollector", ",", "self", ")", ".", "get_default_config_help", "(", ")", "config_help", ".", "update", "(", "{", "\"sys_path\"", ":", "\"Defaults to '/sys/fs/cgroup/l...
Return help text for collector configuration.
[ "Return", "help", "text", "for", "collector", "configuration", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memory_lxc/memory_lxc.py#L18-L26
222,385
python-diamond/Diamond
src/collectors/memory_lxc/memory_lxc.py
MemoryLxcCollector.get_default_config
def get_default_config(self): """ Returns default settings for collector. """ config = super(MemoryLxcCollector, self).get_default_config() config.update({ "path": "lxc", "sys_path": "/sys/fs/cgroup/lxc", }) return config
python
def get_default_config(self): """ Returns default settings for collector. """ config = super(MemoryLxcCollector, self).get_default_config() config.update({ "path": "lxc", "sys_path": "/sys/fs/cgroup/lxc", }) return config
[ "def", "get_default_config", "(", "self", ")", ":", "config", "=", "super", "(", "MemoryLxcCollector", ",", "self", ")", ".", "get_default_config", "(", ")", "config", ".", "update", "(", "{", "\"path\"", ":", "\"lxc\"", ",", "\"sys_path\"", ":", "\"/sys/fs/...
Returns default settings for collector.
[ "Returns", "default", "settings", "for", "collector", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memory_lxc/memory_lxc.py#L28-L37
222,386
python-diamond/Diamond
src/collectors/memory_lxc/memory_lxc.py
MemoryLxcCollector.collect
def collect(self): """ Collect memory stats of LXCs. """ lxc_metrics = ["memory.usage_in_bytes", "memory.limit_in_bytes"] if os.path.isdir(self.config["sys_path"]) is False: self.log.debug("sys_path '%s' isn't directory.", self.config["sys_p...
python
def collect(self): """ Collect memory stats of LXCs. """ lxc_metrics = ["memory.usage_in_bytes", "memory.limit_in_bytes"] if os.path.isdir(self.config["sys_path"]) is False: self.log.debug("sys_path '%s' isn't directory.", self.config["sys_p...
[ "def", "collect", "(", "self", ")", ":", "lxc_metrics", "=", "[", "\"memory.usage_in_bytes\"", ",", "\"memory.limit_in_bytes\"", "]", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "config", "[", "\"sys_path\"", "]", ")", "is", "False", ":", "sel...
Collect memory stats of LXCs.
[ "Collect", "memory", "stats", "of", "LXCs", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memory_lxc/memory_lxc.py#L39-L74
222,387
python-diamond/Diamond
src/collectors/memory_lxc/memory_lxc.py
MemoryLxcCollector._read_file
def _read_file(self, filename): """ Read contents of given file. """ try: with open(filename, "r") as fhandle: stats = float(fhandle.readline().rstrip("\n")) except Exception: stats = None return stats
python
def _read_file(self, filename): """ Read contents of given file. """ try: with open(filename, "r") as fhandle: stats = float(fhandle.readline().rstrip("\n")) except Exception: stats = None return stats
[ "def", "_read_file", "(", "self", ",", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "fhandle", ":", "stats", "=", "float", "(", "fhandle", ".", "readline", "(", ")", ".", "rstrip", "(", "\"\\n\"", ")", ...
Read contents of given file.
[ "Read", "contents", "of", "given", "file", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memory_lxc/memory_lxc.py#L76-L86
222,388
python-diamond/Diamond
src/diamond/util.py
load_modules_from_path
def load_modules_from_path(path): """ Import all modules from the given directory """ # Check and fix the path if path[-1:] != '/': path += '/' # Get a list of files in the directory, if the directory exists if not os.path.exists(path): raise OSError("Directory does not exis...
python
def load_modules_from_path(path): """ Import all modules from the given directory """ # Check and fix the path if path[-1:] != '/': path += '/' # Get a list of files in the directory, if the directory exists if not os.path.exists(path): raise OSError("Directory does not exis...
[ "def", "load_modules_from_path", "(", "path", ")", ":", "# Check and fix the path", "if", "path", "[", "-", "1", ":", "]", "!=", "'/'", ":", "path", "+=", "'/'", "# Get a list of files in the directory, if the directory exists", "if", "not", "os", ".", "path", "."...
Import all modules from the given directory
[ "Import", "all", "modules", "from", "the", "given", "directory" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/util.py#L16-L36
222,389
python-diamond/Diamond
src/diamond/handler/logentries_diamond.py
LogentriesDiamondHandler.process
def process(self, metric): """ Process metric by sending it to datadog api """ self.queue.append(metric) if len(self.queue) >= self.queue_size: logging.debug("Queue is full, sending logs to Logentries") self._send()
python
def process(self, metric): """ Process metric by sending it to datadog api """ self.queue.append(metric) if len(self.queue) >= self.queue_size: logging.debug("Queue is full, sending logs to Logentries") self._send()
[ "def", "process", "(", "self", ",", "metric", ")", ":", "self", ".", "queue", ".", "append", "(", "metric", ")", "if", "len", "(", "self", ".", "queue", ")", ">=", "self", ".", "queue_size", ":", "logging", ".", "debug", "(", "\"Queue is full, sending ...
Process metric by sending it to datadog api
[ "Process", "metric", "by", "sending", "it", "to", "datadog", "api" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/logentries_diamond.py#L60-L68
222,390
python-diamond/Diamond
src/diamond/handler/logentries_diamond.py
LogentriesDiamondHandler._send
def _send(self): """ Convert message to a json object and send to Lognetries """ while len(self.queue) > 0: metric = self.queue.popleft() topic, value, timestamp = str(metric).split() msg = json.dumps({"event": {topic: value}}) req = urllib...
python
def _send(self): """ Convert message to a json object and send to Lognetries """ while len(self.queue) > 0: metric = self.queue.popleft() topic, value, timestamp = str(metric).split() msg = json.dumps({"event": {topic: value}}) req = urllib...
[ "def", "_send", "(", "self", ")", ":", "while", "len", "(", "self", ".", "queue", ")", ">", "0", ":", "metric", "=", "self", ".", "queue", ".", "popleft", "(", ")", "topic", ",", "value", ",", "timestamp", "=", "str", "(", "metric", ")", ".", "...
Convert message to a json object and send to Lognetries
[ "Convert", "message", "to", "a", "json", "object", "and", "send", "to", "Lognetries" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/logentries_diamond.py#L70-L83
222,391
python-diamond/Diamond
src/collectors/smart/smart.py
SmartCollector.collect
def collect(self): """ Collect and publish S.M.A.R.T. attributes """ devices = re.compile(self.config['devices']) for device in os.listdir('/dev'): if devices.match(device): command = [self.config['bin'], "-A", os.path.join('/dev', ...
python
def collect(self): """ Collect and publish S.M.A.R.T. attributes """ devices = re.compile(self.config['devices']) for device in os.listdir('/dev'): if devices.match(device): command = [self.config['bin'], "-A", os.path.join('/dev', ...
[ "def", "collect", "(", "self", ")", ":", "devices", "=", "re", ".", "compile", "(", "self", ".", "config", "[", "'devices'", "]", ")", "for", "device", "in", "os", ".", "listdir", "(", "'/dev'", ")", ":", "if", "devices", ".", "match", "(", "device...
Collect and publish S.M.A.R.T. attributes
[ "Collect", "and", "publish", "S", ".", "M", ".", "A", ".", "R", ".", "T", ".", "attributes" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/smart/smart.py#L45-L99
222,392
python-diamond/Diamond
src/collectors/smart/smart.py
SmartCollector.find_attr_start_line
def find_attr_start_line(self, lines, min_line=4, max_line=9): """ Return line number of the first real attribute and value. The first line is 0. If the 'ATTRIBUTE_NAME' header is not found, return the index after max_line. """ for idx, line in enumerate(lines[min_line:m...
python
def find_attr_start_line(self, lines, min_line=4, max_line=9): """ Return line number of the first real attribute and value. The first line is 0. If the 'ATTRIBUTE_NAME' header is not found, return the index after max_line. """ for idx, line in enumerate(lines[min_line:m...
[ "def", "find_attr_start_line", "(", "self", ",", "lines", ",", "min_line", "=", "4", ",", "max_line", "=", "9", ")", ":", "for", "idx", ",", "line", "in", "enumerate", "(", "lines", "[", "min_line", ":", "max_line", "]", ")", ":", "col", "=", "line",...
Return line number of the first real attribute and value. The first line is 0. If the 'ATTRIBUTE_NAME' header is not found, return the index after max_line.
[ "Return", "line", "number", "of", "the", "first", "real", "attribute", "and", "value", ".", "The", "first", "line", "is", "0", ".", "If", "the", "ATTRIBUTE_NAME", "header", "is", "not", "found", "return", "the", "index", "after", "max_line", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/smart/smart.py#L101-L116
222,393
python-diamond/Diamond
src/collectors/diskspace/diskspace.py
DiskSpaceCollector.get_disk_labels
def get_disk_labels(self): """ Creates a mapping of device nodes to filesystem labels """ path = '/dev/disk/by-label/' labels = {} if not os.path.isdir(path): return labels for label in os.listdir(path): label = label.replace('\\x2f', '/')...
python
def get_disk_labels(self): """ Creates a mapping of device nodes to filesystem labels """ path = '/dev/disk/by-label/' labels = {} if not os.path.isdir(path): return labels for label in os.listdir(path): label = label.replace('\\x2f', '/')...
[ "def", "get_disk_labels", "(", "self", ")", ":", "path", "=", "'/dev/disk/by-label/'", "labels", "=", "{", "}", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "labels", "for", "label", "in", "os", ".", "listdir", "(", ...
Creates a mapping of device nodes to filesystem labels
[ "Creates", "a", "mapping", "of", "device", "nodes", "to", "filesystem", "labels" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/diskspace/diskspace.py#L96-L110
222,394
python-diamond/Diamond
src/collectors/diskspace/diskspace.py
DiskSpaceCollector.get_file_systems
def get_file_systems(self): """ Creates a map of mounted filesystems on the machine. iostat(1): Each sector has size of 512 bytes. Returns: st_dev -> FileSystem(device, mount_point) """ result = {} if os.access('/proc/mounts', os.R_OK): fil...
python
def get_file_systems(self): """ Creates a map of mounted filesystems on the machine. iostat(1): Each sector has size of 512 bytes. Returns: st_dev -> FileSystem(device, mount_point) """ result = {} if os.access('/proc/mounts', os.R_OK): fil...
[ "def", "get_file_systems", "(", "self", ")", ":", "result", "=", "{", "}", "if", "os", ".", "access", "(", "'/proc/mounts'", ",", "os", ".", "R_OK", ")", ":", "file", "=", "open", "(", "'/proc/mounts'", ")", "for", "line", "in", "file", ":", "try", ...
Creates a map of mounted filesystems on the machine. iostat(1): Each sector has size of 512 bytes. Returns: st_dev -> FileSystem(device, mount_point)
[ "Creates", "a", "map", "of", "mounted", "filesystems", "on", "the", "machine", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/diskspace/diskspace.py#L112-L181
222,395
python-diamond/Diamond
src/diamond/handler/libratohandler.py
LibratoHandler.process
def process(self, metric): """ Process a metric by sending it to Librato """ path = metric.getCollectorPath() path += '.' path += metric.getMetricPath() if self.config['apply_metric_prefix']: path = metric.getPathPrefix() + '.' + path if self....
python
def process(self, metric): """ Process a metric by sending it to Librato """ path = metric.getCollectorPath() path += '.' path += metric.getMetricPath() if self.config['apply_metric_prefix']: path = metric.getPathPrefix() + '.' + path if self....
[ "def", "process", "(", "self", ",", "metric", ")", ":", "path", "=", "metric", ".", "getCollectorPath", "(", ")", "path", "+=", "'.'", "path", "+=", "metric", ".", "getMetricPath", "(", ")", "if", "self", ".", "config", "[", "'apply_metric_prefix'", "]",...
Process a metric by sending it to Librato
[ "Process", "a", "metric", "by", "sending", "it", "to", "Librato" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/libratohandler.py#L98-L127
222,396
python-diamond/Diamond
src/diamond/handler/libratohandler.py
LibratoHandler._send
def _send(self): """ Send data to Librato. """ self.queue.submit() self.queue_max_timestamp = int(time.time() + self.queue_max_interval) self.current_n_measurements = 0
python
def _send(self): """ Send data to Librato. """ self.queue.submit() self.queue_max_timestamp = int(time.time() + self.queue_max_interval) self.current_n_measurements = 0
[ "def", "_send", "(", "self", ")", ":", "self", ".", "queue", ".", "submit", "(", ")", "self", ".", "queue_max_timestamp", "=", "int", "(", "time", ".", "time", "(", ")", "+", "self", ".", "queue_max_interval", ")", "self", ".", "current_n_measurements", ...
Send data to Librato.
[ "Send", "data", "to", "Librato", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/libratohandler.py#L133-L139
222,397
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.collect
def collect(self): """ Collect and publish metrics """ stats = self.parse_stats_file(self.config["status_path"]) if len(stats) == 0: return {} elif "info" not in stats.keys(): return {} elif "programstatus" not in stats.keys(): ...
python
def collect(self): """ Collect and publish metrics """ stats = self.parse_stats_file(self.config["status_path"]) if len(stats) == 0: return {} elif "info" not in stats.keys(): return {} elif "programstatus" not in stats.keys(): ...
[ "def", "collect", "(", "self", ")", ":", "stats", "=", "self", ".", "parse_stats_file", "(", "self", ".", "config", "[", "\"status_path\"", "]", ")", "if", "len", "(", "stats", ")", "==", "0", ":", "return", "{", "}", "elif", "\"info\"", "not", "in",...
Collect and publish metrics
[ "Collect", "and", "publish", "metrics" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L19-L44
222,398
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.get_default_config
def get_default_config(self): """ Returns default settings for collector """ config = super(IcingaStatsCollector, self).get_default_config() config.update({ "path": "icinga_stats", "status_path": "/var/lib/icinga/status.dat", }) return conf...
python
def get_default_config(self): """ Returns default settings for collector """ config = super(IcingaStatsCollector, self).get_default_config() config.update({ "path": "icinga_stats", "status_path": "/var/lib/icinga/status.dat", }) return conf...
[ "def", "get_default_config", "(", "self", ")", ":", "config", "=", "super", "(", "IcingaStatsCollector", ",", "self", ")", ".", "get_default_config", "(", ")", "config", ".", "update", "(", "{", "\"path\"", ":", "\"icinga_stats\"", ",", "\"status_path\"", ":",...
Returns default settings for collector
[ "Returns", "default", "settings", "for", "collector" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L57-L66
222,399
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.get_icinga_stats
def get_icinga_stats(self, app_stats): """ Extract metrics from 'programstatus' """ stats = {} stats = dict(stats.items() + self._get_active_stats(app_stats).items()) stats = dict(stats.items() + self._get_cached_stats(app_stats).items()) stats = dict( stats.items() +...
python
def get_icinga_stats(self, app_stats): """ Extract metrics from 'programstatus' """ stats = {} stats = dict(stats.items() + self._get_active_stats(app_stats).items()) stats = dict(stats.items() + self._get_cached_stats(app_stats).items()) stats = dict( stats.items() +...
[ "def", "get_icinga_stats", "(", "self", ",", "app_stats", ")", ":", "stats", "=", "{", "}", "stats", "=", "dict", "(", "stats", ".", "items", "(", ")", "+", "self", ".", "_get_active_stats", "(", "app_stats", ")", ".", "items", "(", ")", ")", "stats"...
Extract metrics from 'programstatus'
[ "Extract", "metrics", "from", "programstatus" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L68-L78