diff --git a/apache_status/README.mkdn b/apache_status/README.mkdn deleted file mode 100644 index 8f467e79..00000000 --- a/apache_status/README.mkdn +++ /dev/null @@ -1,34 +0,0 @@ -apache_status -=============== - -python module for ganglia 3.1. - -"apache_status" sends metrics on Apache process status refering to -server-status(mod_status.so). - -To use this you will need to enable mod_status in Apache. For example you -add following to your Apache config. - -Listen 8001 - - ServerName health.site - - SetHandler server-status - Order deny,allow - Deny from all - Allow from 127.0.0.1 - - - -Restart Apache. Now you should be able to hit - -http://localhost:8001/server-status - -on the box and get a web page with Apache status. - - -## AUTHOR - -HIROSE Masaaki - -Modified by Vladimir Vuksan \ No newline at end of file diff --git a/apache_status/conf.d/apache_status.pyconf b/apache_status/conf.d/apache_status.pyconf deleted file mode 100644 index a6ad007a..00000000 --- a/apache_status/conf.d/apache_status.pyconf +++ /dev/null @@ -1,113 +0,0 @@ -modules { - module { - name = "apache_status" - language = "python" - param url { - value = "http://localhost:7070/server-status" - } - - # Which metric group should these metrics be put into - param metric_group { - value = "apache" - } - - # Collecting SSL metrics under Apache 2.2 appears to cause a memory leak - # in mod_status. Watch Apache memory utilization if you enable them - param collect_ssl { - value = False - } - - - } -} - -collection_group { - collect_every = 30 - time_threshold = 90 - - metric { - name = "ap_busy_workers" - title = "Busy Threads" - value_threshold = 0 - } - metric { - name = "ap_idle_workers" - title = "Idle Threads" - value_threshold = 0 - } - metric { - name = "ap_logging" - title = "Logging" - value_threshold = 0 - } - metric { - name = "ap_open_slot" - title = "Open slot with no current process" - value_threshold = 0 - } - metric { - name = "ap_reading_request" - title = "Reading Request" - value_threshold = 0 - } - metric { - name = "ap_waiting" - title = "Waiting for Connection" - value_threshold = 0 - } - metric { - name = "ap_sending_reply" - title = "Sending Reply" - value_threshold = 0 - } - metric { - name = "ap_idle" - title = "Idle cleanup of worker" - value_threshold = 0 - } - metric { - name = "ap_dns_lookup" - title = "DNS Lookup" - value_threshold = 0 - } - metric { - name = "ap_closing" - title = "Closing connection" - value_threshold = 0 - } - metric { - name = "ap_starting" - title = "Starting up" - value_threshold = 0 - } - metric { - name = "ap_gracefully_fin" - title = "Gracefully finishing" - value_threshold = 0 - } - metric { - name = "ap_keepalive" - title = "Keepalive (read)" - value_threshold = 0 - } - - metric { - name = "ap_rps" - title = "Requests per second" - value_threshold = 0.0 - } - - metric { - name = "ap_cpuload" - title = "Pct of time CPU utilized" - value_threshold = 0.0 - } - -# Uncomment if you are collecting SSL metrics -# metric { -# name_match = "apssl_(.+)" -# value_threshold = 0.0 -# } - - -} diff --git a/apache_status/python_modules/apache_status.py b/apache_status/python_modules/apache_status.py deleted file mode 100755 index 960cfba3..00000000 --- a/apache_status/python_modules/apache_status.py +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import threading -import time -import urllib2 -import traceback -import re -import copy -import sys -import socket - -if sys.version_info < (2, 6): - socket.setdefaulttimeout(2) - -# global to store state for "total accesses" -METRICS = { - 'time' : 0, - 'data' : {} -} - -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - -#Metric prefix -NAME_PREFIX = "ap_" -SSL_NAME_PREFIX = "apssl_" - -SERVER_STATUS_URL = "" - -descriptors = list() -Desc_Skel = {} -Scoreboard = { - NAME_PREFIX + 'waiting' : { 'key': '_', 'desc': 'Waiting for Connection' }, - NAME_PREFIX + 'starting' : { 'key': 'S', 'desc': 'Starting up' }, - NAME_PREFIX + 'reading_request' : { 'key': 'R', 'desc': 'Reading Request' }, - NAME_PREFIX + 'sending_reply' : { 'key': 'W', 'desc': 'Sending Reply' }, - NAME_PREFIX + 'keepalive' : { 'key': 'K', 'desc': 'Keepalive (read)' }, - NAME_PREFIX + 'dns_lookup' : { 'key': 'D', 'desc': 'DNS Lookup' }, - NAME_PREFIX + 'closing' : { 'key': 'C', 'desc': 'Closing connection' }, - NAME_PREFIX + 'logging' : { 'key': 'L', 'desc': 'Logging' }, - NAME_PREFIX + 'gracefully_fin' : { 'key': 'G', 'desc': 'Gracefully finishing' }, - NAME_PREFIX + 'idle' : { 'key': 'I', 'desc': 'Idle cleanup of worker' }, - NAME_PREFIX + 'open_slot' : { 'key': '.', 'desc': 'Open slot with no current process' }, - } -Scoreboard_bykey = dict([(v["key"],k) for (k,v) in Scoreboard.iteritems()]) - -SSL_REGEX = re.compile('^(cache type:) (.*)()(?P[0-9]+)( bytes, current sessions: )(?P[0-9]+)(
subcaches: )(?P[0-9]+)(, indexes per subcache: )(?P[0-9]+)(
)(.*)(
index usage: )(?P[0-9]+)(%, cache usage: )(?P[0-9]+)(%
total sessions stored since starting: )(?P[0-9]+)(
total sessions expired since starting: )(?P[0-9]+)(
total \(pre-expiry\) sessions scrolled out of the cache: )(?P[0-9]+)(
total retrieves since starting: )(?P[0-9]+)( hit, )(?P[0-9]+)( miss
total removes since starting: )(?P[0-9]+)( hit, )(?P[0-9]+)') -# Good for Apache 2.2 -#SSL_REGEX = re.compile('^(cache type:) (.*)()(?P[0-9]+)( bytes, current sessions: )(?P[0-9]+)(
subcaches: )(?P[0-9]+)(, indexes per subcache: )(?P[0-9]+)(
index usage: )(?P[0-9]+)(%, cache usage: )(?P[0-9]+)(%
total sessions stored since starting: )(?P[0-9]+)(
total sessions expired since starting: )(?P[0-9]+)(
total \(pre-expiry\) sessions scrolled out of the cache: )(?P[0-9]+)(
total retrieves since starting: )(?P[0-9]+)( hit, )(?P[0-9]+)( miss
total removes since starting: )(?P[0-9]+)( hit, )(?P[0-9]+)') - - -Metric_Map = { - 'Uptime' : NAME_PREFIX + "uptime", - 'IdleWorkers' : NAME_PREFIX + "idle_workers", - 'BusyWorkers' : NAME_PREFIX + "busy_workers", - 'Total kBytes' : NAME_PREFIX + "bytes", - 'CPULoad' : NAME_PREFIX + "cpuload", - "Total Accesses" : NAME_PREFIX + "rps" -} - -def get_metrics(): - - global METRICS, LAST_METRICS, SERVER_STATUS_URL, COLLECT_SSL - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - metrics = dict( [(k, 0) for k in Scoreboard.keys()] ) - - # This is the short server-status. Lacks SSL metrics - try: - req = urllib2.Request(SERVER_STATUS_URL + "?auto") - - # Download the status file - if sys.version_info < (2, 6): - res = urllib2.urlopen(req) - else: - res = urllib2.urlopen(req, timeout=2) - - for line in res: - split_line = line.rstrip().split(": ") - long_metric_name = split_line[0] - if long_metric_name == "Scoreboard": - for sck in split_line[1]: - metrics[ Scoreboard_bykey[sck] ] += 1 - else: - if long_metric_name in Metric_Map: - metric_name = Metric_Map[long_metric_name] - else: - metric_name = long_metric_name - metrics[metric_name] = split_line[1] - - except urllib2.URLError: - traceback.print_exc() - - # If we are collecting SSL metrics we'll do - if COLLECT_SSL: - - try: - req2 = urllib2.Request(SERVER_STATUS_URL) - - # Download the status file - if sys.version_info < (2, 6): - res = urllib2.urlopen(req2) - else: - res = urllib2.urlopen(req2, timeout=2) - - for line in res: - regMatch = SSL_REGEX.match(line) - if regMatch: - linebits = regMatch.groupdict() - for key in linebits: - #print SSL_NAME_PREFIX + key + "=" + linebits[key] - metrics[SSL_NAME_PREFIX + key] = linebits[key] - - except urllib2.URLError: - traceback.print_exc() - - - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': metrics - } - - return [METRICS, LAST_METRICS] - - -def get_value(name): - """Return a value for the requested metric""" - - metrics = get_metrics()[0] - - try: - result = metrics['data'][name] - except StandardError: - result = 0 - - return result - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - # If it's ap_bytes metric multiply result by 1024 - if name == NAME_PREFIX + "bytes": - multiplier = 1024 - else: - multiplier = 1 - - try: - delta = multiplier * (float(curr_metrics['data'][name]) - float(last_metrics['data'][name])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - -def create_desc(prop): - d = Desc_Skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors, Desc_Skel, SERVER_STATUS_URL, COLLECT_SSL - - print '[apache_status] Received the following parameters' - print params - - if "metric_group" not in params: - params["metric_group"] = "apache" - - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : get_value, - 'time_max' : 60, - 'value_type' : 'uint', - 'units' : 'proc', - 'slope' : 'both', - 'format' : '%d', - 'description' : 'XXX', - 'groups' : params["metric_group"], - } - - if "refresh_rate" not in params: - params["refresh_rate"] = 15 - - if "url" not in params: - params["url"] = "http://localhost:7070/server-status" - - if "collect_ssl" not in params: - params["collect_ssl"] = False - - SERVER_STATUS_URL = params["url"] - COLLECT_SSL = params["collect_ssl"] - - # IP:HOSTNAME - if "spoof_host" in params: - Desc_Skel["spoof_host"] = params["spoof_host"] - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "rps", - "value_type" : "float", - "units" : "req/sec", - "call_back" : get_delta, - "format" : "%.3f", - "description": "request per second", - })) - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "bytes", - "value_type" : "float", - "units" : "bytes/sec", - "call_back" : get_delta, - "format" : "%.3f", - "description": "bytes transferred per second", - })) - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "cpuload", - "value_type" : "float", - "units" : "pct", - "format" : "%.6f", - "call_back" : get_value, - "description": "Pct of time CPU utilized", - })) - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "busy_workers", - "value_type" : "uint", - "units" : "threads", - "format" : "%u", - "call_back" : get_value, - "description": "Busy threads", - })) - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "idle_workers", - "value_type" : "uint", - "units" : "threads", - "format" : "%u", - "call_back" : get_value, - "description": "Idle threads", - })) - - descriptors.append(create_desc({ - "name" : NAME_PREFIX + "uptime", - "value_type" : "uint", - "units" : "seconds", - "format" : "%u", - "call_back" : get_value, - "description": "Uptime", - })) - - for k,v in Scoreboard.iteritems(): - descriptors.append(create_desc({ - "name" : k, - "call_back" : get_value, - "description" : v["desc"], - })) - - ########################################################################## - # SSL metrics - ########################################################################## - if params['collect_ssl']: - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "shared_mem", - "value_type" : "float", - "units" : "bytes", - "format" : "%.3f", - "call_back" : get_value, - "description": "Shared memory", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "current_sessions", - "value_type" : "uint", - "units" : "sessions", - "format" : "%u", - "call_back" : get_value, - "description": "Current sessions", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "num_subcaches", - "value_type" : "uint", - "units" : "subcaches", - "format" : "%u", - "call_back" : get_value, - "description": "Number of subcaches", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "indexes_per_subcache", - "value_type" : "float", - "units" : "indexes", - "format" : "%.3f", - "call_back" : get_value, - "description": "Subcaches", - })) - - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "index_usage", - "value_type" : "float", - "units" : "pct", - "format" : "%.3f", - "call_back" : get_value, - "description": "Index usage", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "cache_usage", - "value_type" : "float", - "units" : "pct", - "format" : "%.3f", - "call_back" : get_value, - "description": "Cache usage", - })) - - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "sessions_stored", - "value_type" : "float", - "units" : "sessions/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Sessions stored", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "sessions_expired", - "value_type" : "float", - "units" : "sessions/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Sessions expired", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "retrieves_hit", - "value_type" : "float", - "units" : "retrieves/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Retrieves Hit", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "retrieves_miss", - "value_type" : "float", - "units" : "retrieves/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Retrieves Miss", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "removes_hit", - "value_type" : "float", - "units" : "removes/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Removes Hit", - })) - - descriptors.append(create_desc({ - "name" : SSL_NAME_PREFIX + "removes_miss", - "value_type" : "float", - "units" : "removes/sec", - "format" : "%.3f", - "call_back" : get_delta, - "description": "Removes Miss", - })) - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - _Worker_Thread.shutdown() - -if __name__ == '__main__': - try: - params = { - 'url' : 'http://localhost:7070/server-status', - 'collect_ssl' : False - } - metric_init(params) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - if d['name'] == NAME_PREFIX + "rps": - print 'value for %s is %.4f' % (d['name'], v) - else: - print 'value for %s is %s' % (d['name'], v) - time.sleep(15) - except KeyboardInterrupt: - os._exit(1) diff --git a/diskfree/conf.d/diskfree.pyconf b/diskfree/conf.d/diskfree.pyconf deleted file mode 100644 index 0e7b01b8..00000000 --- a/diskfree/conf.d/diskfree.pyconf +++ /dev/null @@ -1,19 +0,0 @@ -modules { - module { - name = "diskfree" - language = "python" - param mounts { - value = '/proc/mounts' - } - } -} - -collection_group { - collect_every = 60 - time_threshold = 180 - metric { - name_match = "disk_free_(.+)" - } - -} - diff --git a/diskfree/python_modules/diskfree.py b/diskfree/python_modules/diskfree.py deleted file mode 100755 index 17c04301..00000000 --- a/diskfree/python_modules/diskfree.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Disk Free gmond module for Ganglia -# -# Copyright (C) 2011 by Michael T. Conigliaro . -# All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import re -import os - -# Minimum disk size -MIN_DISK_SIZE=1 - -NAME_PREFIX = 'disk_free_' -PARAMS = { - 'mounts' : '/proc/mounts' -} - - -def get_value(name): - """Return a value for the requested metric""" - - # parse unit type and path from name - name_parser = re.match("^%s(absolute|percent)_(.*)$" % NAME_PREFIX, name) - unit_type = name_parser.group(1) - if name_parser.group(2) == 'rootfs': - path = '/' - else: - path = '/' + name_parser.group(2).replace('_', '/') - - # get fs stats - try: - disk = os.statvfs(path) - if unit_type == 'percent': - result = (float(disk.f_bavail) / float(disk.f_blocks)) * 100 - else: - result = (disk.f_bavail * disk.f_frsize) / float(2**30) # GB - - except OSError: - result = 0 - - except ZeroDivisionError: - result = 0 - - return result - - -def metric_init(lparams): - """Initialize metric descriptors""" - - global PARAMS, MIN_DISK_SIZE - - # set parameters - for key in lparams: - PARAMS[key] = lparams[key] - - # read mounts file - try: - f = open(PARAMS['mounts']) - except IOError: - f = [] - - # parse mounts and create descriptors - descriptors = [] - for line in f: - # We only want local file systems - if line.startswith('/') or line.startswith('tmpfs'): - mount_info = line.split() - - # create key from path - if mount_info[1] == '/': - path_key = 'rootfs' - else: - path_key = mount_info[1][1:].replace('/', '_') - - # Calculate the size of the disk. We'll use it exclude small disks - disk = os.statvfs(mount_info[1]) - disk_size = (disk.f_blocks * disk.f_frsize) / float(2**30) - - if disk_size > MIN_DISK_SIZE and mount_info[1] != "/dev": - for unit_type in ['absolute', 'percent']: - if unit_type == 'percent': - units = '%' - else: - units = 'GB' - descriptors.append({ - 'name': NAME_PREFIX + unit_type + '_' + path_key, - 'call_back': get_value, - 'time_max': 60, - 'value_type': 'float', - 'units': units, - 'slope': 'both', - 'format': '%f', - 'description': "Disk space available (%s) on %s" % (units, mount_info[1]), - 'groups': 'disk' - }) - - return descriptors - - -def metric_cleanup(): - """Cleanup""" - - pass - - -# the following code is for debugging and testing -if __name__ == '__main__': - descriptors = metric_init(PARAMS) - for d in descriptors: - print (('%s = %s') % (d['name'], d['format'])) % (d['call_back'](d['name'])) diff --git a/diskstat/conf.d/diskstat.pyconf b/diskstat/conf.d/diskstat.pyconf deleted file mode 100644 index 2e9d884f..00000000 --- a/diskstat/conf.d/diskstat.pyconf +++ /dev/null @@ -1,28 +0,0 @@ -# - -modules { - module { - name = 'diskstat' - language = 'python' - - # Specify devices you want to monitor or if empty it will - # pick all devices - #param devices { - # value = '' - #} - - #param device-mapper { - # value = 'true' - #} - } -} - -collection_group { - collect_every = 30 - time_threshold = 30 - - metric { - name_match = "diskstat_(.+)" - } -} - diff --git a/diskstat/python_modules/diskstat.py b/diskstat/python_modules/diskstat.py deleted file mode 100644 index 7e277054..00000000 --- a/diskstat/python_modules/diskstat.py +++ /dev/null @@ -1,538 +0,0 @@ -#!/usr/bin/env python -# This script reports disk stat metrics to ganglia. -# -# Notes: -# This script exposes values in /proc/diskstats and calculates -# various statistics based on the Linux kernel 2.6. To find -# more information on these values, look in the Linux kernel -# documentation for "I/O statistics fields". -# -# By default, the script would monitor any entry listed under -# /proc/diskstats that is not containing a number. Override it by passing -# a list of devices in the 'devices' parameter. -# -# This script has the option of explicitly setting which devices -# to check using the "devices" option in your configuration. If -# you set this value, it will invalidate the MIN_DISK_SIZE and -# IGNORE_DEV options described below. This enables you to -# monitor specific partitions instead of the entire device. -# Example value: "sda1 sda2". -# Example value: "sda sdb sdc". -# -# This script also checks for a minimum disk size in order to -# only measure interesting devices by default. -# [Can be overriden if "devices" is set] -# -# This script looks for disks to check in /proc/partitions while -# ignoring any devices present in IGNORE_DEV by default. -# [Can be overriden if "devices" is set] -# -# Changelog: -# v1.0.1 - 2010-07-22 -# * Initial version -# -# v1.0.2 - 2010-08-03 -# * Modified reads_per_sec to not calculate per second delta. -# This enables us to generate a better graph by stacking -# reads/writes with reads/writes merged. -# - -# Copyright Jamie Isaacs. 2010 -# License to use, modify, and distribute under the GPL -# http://www.gnu.org/licenses/gpl.txt - -import logging -import os -import re -import stat -import time - -descriptors = [] - -logging.basicConfig(level=logging.ERROR, format="%(asctime)s - %(name)s - %(levelname)s\t Thread-%(thread)d - %(message)s") -logging.debug('starting up') - -last_update = 0 -cur_time = 0 -stats = {} -last_val = {} - -MAX_UPDATE_TIME = 15 -BYTES_PER_SECTOR = 512 - -# 5 GB -MIN_DISK_SIZE = 5242880 -# Set to None to trigger disk discovery under /proc/diskstats -# Pass a 'devices' parameter to explicitly list disks to monitor -DEVICES = None -IGNORE_DEV = 'dm-|loop|drbd' - -PARTITIONS_FILE = '/proc/partitions' -DISKSTATS_FILE = '/proc/diskstats' -DMDIR = '/dev/mapper' -device_mapper = '' - -PARTITIONS = [] -dmnames = [] -dm2pair = {} -pair2dm = {} -devnames = [] -dev2pair = {} -pair2dev = {} - - -def build_dmblock_major_minor_tables(): - """Returns - 1) a table of filenames that are all device mapper block special files - 2) a dict mapping each device mapper name to (major,minor) - 3) a dict mapping each (major,minor) pair to a table of devce mapper names""" - - names = [] - name2pair = {} - pair2name = {} - mapper_entries = [] - - mapper_entries = os.listdir(DMDIR) - for n in mapper_entries: - s = os.lstat(DMDIR + '/' + n) - if stat.S_ISBLK(s[stat.ST_MODE]): - names.append(n) - maj = str(os.major(s.st_rdev)) - min = str(os.minor(s.st_rdev)) - name2pair[n] = (maj, min) - pair2name[(maj, min)] = n - - logging.debug('grabbed dmsetup device info') - logging.debug('dmsetup devices: ' + str(name2pair)) - - return (names, name2pair, pair2name) - - -def build_block_major_minor_tables(): - """Returns - 1) a table of filenames that are all block special files - 2) a dict mapping each dev name to (major,minor) - 3) a dict mapping each (major,minor) pair to a table of dev names""" - dnames = [] - d2p = {} - p2d = {} - - # Get values from diskstats file - with open(DISKSTATS_FILE, 'r') as f: - lines = f.readlines() - logging.debug('grabbed diskstat device info') - logging.debug('diskstat devices: ' + '\n'.join(lines)) - - for line in lines: - if line: - # read the first three fields from each line - (maj, min, name) = line.split()[:3] - dnames.append(name) - d2p[name] = (maj, min) - p2d[(maj, min)] = name - - return (dnames, d2p, p2d) - - -def get_devname(dev): - """Returns device mapper name converted to dev name""" - - (maj, min) = dm2pair[dev] - name = pair2dev[(maj, min)] - return name - - -def list_dmnames(): - """Returns string of device names associated with device mapper names""" - - global dmnames - global dm2pair - global pair2dm - global devnames - global dev2pair - global pair2dev - devlist = '' - - dmnames, dm2pair, pair2dm = build_dmblock_major_minor_tables() - logging.debug('dmnames: ' + str(dmnames)) - - devnames, dev2pair, pair2dev = build_block_major_minor_tables() - logging.debug('devnames: ' + str(dmnames)) - - for d in dmnames: - devlist = devlist + ' ' + str(d) - - logging.debug('devlist: ' + str(devlist)) - - return devlist - - -def get_partitions(): - logging.debug('getting partitions') - global PARTITIONS - - # We need DEVICES != "" because on at least Centos 6 this evaluates to true - if DEVICES is not None and DEVICES != "" : - # Explicit device list has been set - logging.debug(' DEVICES has already been set') - out = DEVICES - - else: - # Load partitions - devices = [] - with open(PARTITIONS_FILE, 'r') as f: - # read /proc/partitions and remove the first two header lines - lines = f.readlines()[2:] - for line in lines: - device_name = line.split()[3] - device_ends_with_number = re.search('\d$', device_name) - if 'md' in device_name or not device_ends_with_number: - # only include md devices and base block devices - devices.append(device_name) - out = ' '.join(devices) - logging.debug(' result: ' + out) - - for dev in out.split(): - if DEVICES is not None: - # Explicit device list has been set - PARTITIONS.append(dev) - else: - # Load disk block size - with open('/sys/block/' + dev + '/size', 'r') as f: - c = f.read() - - # Make sure device is large enough to collect stats - if (int(c) * BYTES_PER_SECTOR / 1024) > MIN_DISK_SIZE: - PARTITIONS.append(dev) - else: - logging.debug(' ignoring ' + dev + ' due to size constraints') - - return 0 - - -########################################################################### -# This is the order of metrics in /proc/diskstats -# 0 major Major number -# 1 minor Minor number -# 2 blocks Blocks -# 3 name Name -# 4 reads This is the total number of reads completed successfully. -# 5 merge_read Reads and writes which are adjacent to each other may be merged for -# efficiency. Thus two 4K reads may become one 8K read before it is -# ultimately handed to the disk, and so it will be counted (and queued) -# as only one I/O. This field lets you know how often this was done. -# 6 s_read This is the total number of sectors read successfully. -# 7 ms_read This is the total number of milliseconds spent by all reads. -# 8 writes This is the total number of writes completed successfully. -# 9 merge_write Reads and writes which are adjacent to each other may be merged for -# efficiency. Thus two 4K reads may become one 8K read before it is -# ultimately handed to the disk, and so it will be counted (and queued) -# as only one I/O. This field lets you know how often this was done. -# 10 s_write This is the total number of sectors written successfully. -# 11 ms_write This is the total number of milliseconds spent by all writes. -# 12 ios The only field that should go to zero. Incremented as requests are -# given to appropriate request_queue_t and decremented as they finish. -# 13 ms_io This field is increases so long as field 9 is nonzero. -# 14 ms_weighted This field is incremented at each I/O start, I/O completion, I/O -########################################################################### - -def update_stats(): - logging.debug('updating stats') - global last_update, stats, last_val, cur_time - global MAX_UPDATE_TIME - - cur_time = time.time() - - if cur_time - last_update < MAX_UPDATE_TIME: - logging.debug(' wait ' + str(int(MAX_UPDATE_TIME - (cur_time - last_update))) + ' seconds') - return True - - # Update diskstats - stats = {} - - if not PARTITIONS: - part = get_partitions() - if part: - # Fail if return is non-zero - logging.warning('error getting partitions') - return False - - # Get values for each disk device - for dev in PARTITIONS: - logging.debug(" dev: " + dev) - - # Setup storage lists - if dev not in stats: - stats[dev] = {} - if dev not in last_val: - last_val[dev] = {} - - # Convert from dmname to devname - if device_mapper == 'true': - olddev = dev - dev = get_devname(dev) - - # Get values from diskstats file - with open(DISKSTATS_FILE, 'r') as f: - lines = f.readlines() - for line in lines: - if dev in line: - vals = line.split() - - logging.debug(' vals: ' + str(vals)) - - # Reset back to orignal dev name - if device_mapper == 'true': - dev = olddev - - get_diff(dev, 'reads', int(vals[3])) - get_diff(dev, 'writes', int(vals[7])) - - get_diff(dev, 'reads_merged', int(vals[4])) - get_diff(dev, 'writes_merged', int(vals[8])) - - get_delta(dev, 'read_bytes_per_sec', int(vals[5]), float(BYTES_PER_SECTOR)) - get_delta(dev, 'write_bytes_per_sec', int(vals[9]), float(BYTES_PER_SECTOR)) - - get_delta(dev, 'read_time', float(vals[6]), 0.001) - get_delta(dev, 'write_time', float(vals[10]), 0.001) - - get_diff(dev, 'io_time', float(vals[12]), 0.001) - get_percent_time(dev, 'percent_io_time', float(stats[dev]['io_time'])) - get_delta(dev, 'weighted_io_time', float(vals[13]), 0.001) - - logging.debug('success refreshing stats') - logging.debug('stats: ' + str(stats)) - logging.debug('last_val: ' + str(last_val)) - - last_update = cur_time - return True - - -def get_delta(dev, key, val, convert=1): - logging.debug(' get_delta for ' + dev + '_' + key) - global stats, last_val - - if convert == 0: - logging.warning(' convert is zero!') - - interval = cur_time - last_update - - if key in last_val[dev] and interval > 0: - - if val < last_val[dev][key]: - logging.debug(' fixing int32 wrap') - val += 4294967296 - - stats[dev][key] = (val - last_val[dev][key]) * float(convert) / float(interval) - else: - stats[dev][key] = 0 - - last_val[dev][key] = int(val) - - -def get_percent_time(dev, key, val): - logging.debug(' get_percent_time for ' + dev + '_' + key) - global stats, last_val - - interval = cur_time - last_update - - if interval > 0: - stats[dev][key] = (val / interval) * 100 - else: - stats[dev][key] = 0 - - -def get_diff(dev, key, val, convert=1): - logging.debug(' get_diff for ' + dev + '_' + key) - global stats, last_val - - if key in last_val[dev]: - stats[dev][key] = (val - last_val[dev][key]) * float(convert) - else: - stats[dev][key] = 0 - - # If for some reason we have a negative diff we should assume counters reset - # and should set it back to 0 - if stats[dev][key] < 0: - stats[dev][key] = 0 - - last_val[dev][key] = val - - -def get_stat(name): - logging.debug(' getting stat: ' + name) - global stats - - ret = update_stats() - - if ret: - if name.startswith('diskstat_'): - fir = name.find('_') - sec = name.find('_', fir + 1) - - dev = name[fir + 1:sec] - label = name[sec + 1:] - - try: - return stats[dev][label] - except: - logging.warning('failed to fetch [' + dev + '] ' + name) - return 0 - else: - label = name - - try: - return stats[label] - except: - logging.warning('failed to fetch ' + name) - return 0 - - else: - return 0 - - -def metric_init(params): - global descriptors, device_mapper - global MIN_DISK_SIZE, DEVICES, IGNORE_DEV - - # Use params.get here to assure function via gmond - if params.get('device-mapper') == 'true': - devices = list_dmnames() - DEVICES = devices - IGNORE_DEV = 'loop|drbd' - device_mapper = 'true' - logging.debug('dm block devices: ' + str(devices)) - else: - DEVICES = params.get('devices') - - logging.debug('init: ' + str(params)) - - time_max = 60 - - descriptions = dict( - reads={ - 'units': 'reads', - 'description': 'The number of reads completed'}, - - reads_merged={ - 'units': 'reads', - 'description': 'The number of reads merged. Reads which are adjacent to each other may be merged for efficiency. Multiple reads may become one before it is handed to the disk, and it will be counted (and queued) as only one I/O.'}, - - read_bytes_per_sec={ - 'units': 'bytes/sec', - 'description': 'The number of bytes read per second'}, - - read_time={ - 'units': 's', - 'description': 'The time in seconds spent reading'}, - - writes={ - 'units': 'writes', - 'description': 'The number of writes completed'}, - - writes_merged={ - 'units': 'writes', - 'description': 'The number of writes merged. Writes which are adjacent to each other may be merged for efficiency. Multiple writes may become one before it is handed to the disk, and it will be counted (and queued) as only one I/O.'}, - - write_bytes_per_sec={ - 'units': 'bytes/sec', - 'description': 'The number of bytes written per second'}, - - write_time={ - 'units': 's', - 'description': 'The time in seconds spent writing'}, - - io_time={ - 'units': 's', - 'description': 'The time in seconds spent in I/O operations'}, - - percent_io_time={ - 'units': 'percent', - 'value_type': 'float', - 'format': '%f', - 'description': 'The percent of disk time spent on I/O operations'}, - - weighted_io_time={ - 'units': 's', - 'description': 'The weighted time in seconds spend in I/O operations. This measures each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/O operations in progress times the number of seconds spent doing I/O.'} - ) - - update_stats() - - for label in descriptions: - for dev in PARTITIONS: - if label in stats[dev]: - - d = { - 'name': 'diskstat_' + dev + '_' + label, - 'call_back': get_stat, - 'time_max': time_max, - 'value_type': 'float', - 'units': '', - 'slope': 'both', - 'format': '%f', - 'description': label, - 'groups': 'diskstat' - } - - # Apply metric customizations from descriptions - d.update(descriptions[label]) - - descriptors.append(d) - else: - logging.error("skipped " + label) - - # For command line testing - # time.sleep(MAX_UPDATE_TIME) - # update_stats() - - return descriptors - - -def metric_cleanup(): - logging.shutdown() - # pass - -if __name__ == '__main__': - from optparse import OptionParser - import os - - logging.debug('running from cmd line') - parser = OptionParser() - parser.add_option('-d', '--devices', dest='devices', default=None, help='devices to explicitly check') - parser.add_option('-b', '--gmetric-bin', dest='gmetric_bin', default='/usr/bin/gmetric', help='path to gmetric binary') - parser.add_option('-c', '--gmond-conf', dest='gmond_conf', default='/etc/ganglia/gmond.conf', help='path to gmond.conf') - parser.add_option('-g', '--gmetric', dest='gmetric', action='store_true', default=False, help='submit via gmetric') - parser.add_option('-m', '--device-mapper', dest='device_mapper', action='store_true', default=False, help='utilize all device mapper devices if set') - parser.add_option('-q', '--quiet', dest='quiet', action='store_true', default=False) - - (options, args) = parser.parse_args() - - if options.device_mapper: - metric_init({ - 'device-mapper': 'true', - }) - else: - metric_init({ - 'devices': options.devices, - }) - - while True: - for d in descriptors: - v = d['call_back'](d['name']) - if not options.quiet: - print ' %s: %s %s [%s]' % (d['name'], v, d['units'], d['description']) - - if options.gmetric: - if d['value_type'] == 'uint': - value_type = 'uint32' - else: - value_type = d['value_type'] - - cmd = "%s --conf=%s --value='%s' --units='%s' --type='%s' --name='%s' --slope='%s'" % \ - (options.gmetric_bin, options.gmond_conf, v, d['units'], value_type, d['name'], d['slope']) - os.system(cmd) - - print 'Sleeping 15 seconds' - time.sleep(15) diff --git a/memcached/conf.d/memcached.conf b/memcached/conf.d/memcached.conf deleted file mode 100644 index 5573ba07..00000000 --- a/memcached/conf.d/memcached.conf +++ /dev/null @@ -1,114 +0,0 @@ -modules { - module { - name = "memcached" - language = "python" - - param host { - value = "localhost" - } - param port { - value = 11211 - } - param type { - value = "memcached" - } - - param refresh_rate { - value = 15 - } - - # param metrix_prefix { - # value = "mc" - # } - # param spoof_host { - # value = "__IPADDRESS__:__HOSTNAME__" - # } - } -} - -collection_group { - collect_every = 20 - time_threshold = 90 - - metric { - name = "mc_curr_items" - title = "Current number of items stored" - value_threshold = 0 - } - metric { - name = "mc_cmd_get" - title = "Cumulative number of retrieval reqs" - value_threshold = 0 - } - metric { - name = "mc_cmd_set" - title = "Cumulative number of storage reqs" - value_threshold = 0 - } - metric { - name = "mc_cmd_get_rate" - title = "Retrieval reqs/sec" - value_threshold = 0 - } - metric { - name = "mc_cmd_set_rate" - title = "Storage reqs/sec" - value_threshold = 0 - } - metric { - name = "mc_bytes_read" - title = "Total number of bytes read by this server from network" - value_threshold = 0 - } - metric { - name = "mc_bytes_written" - title = "Total number of bytes sent by this server to network" - value_threshold = 0 - } - metric { - name = "mc_bytes" - title = "Current number of bytes used to store items" - value_threshold = 0 - } - metric { - name = "mc_limit_maxbytes" - title = "Number of bytes this server is allowed to use for storage" - value_threshold = 0 - } - metric { - name = "mc_curr_connections" - title = "Number of open connections" - value_threshold = 0 - } - metric { - name = "mc_evictions" - title = "Number of valid items removed from cache to free memory for new items" - value_threshold = 0 - } - metric { - name = "mc_evictions_rate" - title = "Rate of valid items removed from cache to free memory for new items" - value_threshold = 0 - } - metric { - name = "mc_get_hits" - title = "Number of keys that have been requested and found present " - value_threshold = 0 - } - metric { - name = "mc_get_misses" - title = "Number of items that have been requested and not found" - value_threshold = 0 - } - metric { - name = "mc_get_hits_rate" - title = "Hits/sec" - value_threshold = 0 - } - metric { - name = "mc_get_misses_rate" - title = "Misses/sec" - value_threshold = 0 - } - -} diff --git a/memcached/python_modules/memcached.py b/memcached/python_modules/memcached.py deleted file mode 100755 index f6bcff08..00000000 --- a/memcached/python_modules/memcached.py +++ /dev/null @@ -1,394 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -import traceback -import os -import threading -import time -import socket -import select -import errno - -descriptors = list() -Desc_Skel = {} -_Worker_Thread = None -_Lock = threading.Lock() # synchronization lock -Debug = False - -def dprint(f, *v): - if Debug: - print >>sys.stderr, "DEBUG: "+f % v - -def floatable(str): - try: - float(str) - return True - except: - return False - -class UpdateMetricThread(threading.Thread): - - def __init__(self, params): - threading.Thread.__init__(self) - self.running = False - self.shuttingdown = False - self.refresh_rate = 15 - if "refresh_rate" in params: - self.refresh_rate = int(params["refresh_rate"]) - self.metric = {} - self.last_metric = {} - self.timeout = 2 - - self.host = "localhost" - self.port = 11211 - if "host" in params: - self.host = params["host"] - if "port" in params: - self.port = int(params["port"]) - self.type = params["type"] - self.mp = params["metrix_prefix"] - - def shutdown(self): - self.shuttingdown = True - if not self.running: - return - try: - self.join() - except: - pass - - def run(self): - self.running = True - - while not self.shuttingdown: - _Lock.acquire() - self.update_metric() - _Lock.release() - time.sleep(self.refresh_rate) - - self.running = False - - def update_metric(self): - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - msg = "" - self.last_metric = self.metric.copy() - try: - dprint("connect %s:%d", self.host, self.port) - sock.connect((self.host, self.port)) - sock.send("stats\r\n") - - while True: - try: - rfd, wfd, xfd = select.select([sock], [], [], self.timeout) - - if not rfd: - print >>sys.stderr, "ERROR: select timeout" - break - - for fd in rfd: - if fd == sock: - try: - data = fd.recv(8192) - msg += data - except (IOError, OSError), e: - if e.errno != errno.EINTR: - raise - - if msg.find("END"): - break - except select.error, e: - if e[0] != errno.EINTR: - raise - - sock.close() - except socket.error, e: - print >>sys.stderr, "ERROR: %s" % e - - for m in msg.split("\r\n"): - d = m.split(" ") - if len(d) == 3 and d[0] == "STAT" and floatable(d[2]): - self.metric[self.mp+"_"+d[1]] = float(d[2]) - - def metric_of(self, name): - val = 0 - mp = name.split("_")[0] - if name.rsplit("_",1)[1] == "rate" and name.rsplit("_",1)[0] in self.metric: - _Lock.acquire() - name = name.rsplit("_",1)[0] - if name in self.last_metric: - num = self.metric[name]-self.last_metric[name] - period = self.metric[mp+"_time"]-self.last_metric[mp+"_time"] - try: - val = num/period - except ZeroDivisionError: - val = 0 - _Lock.release() - elif name in self.metric: - _Lock.acquire() - val = self.metric[name] - _Lock.release() - # Value should never be negative. If it is counters wrapper due to e.g. memcached restart - if val < 0: - val = 0 - return val - -def metric_init(params): - global descriptors, Desc_Skel, _Worker_Thread, Debug - - print '[memcached] memcached protocol "stats"' - if "type" not in params: - params["type"] = "memcached" - - if "metrix_prefix" not in params: - if params["type"] == "memcached": - params["metrix_prefix"] = "mc" - elif params["type"] == "Tokyo Tyrant": - params["metrix_prefix"] = "tt" - - print params - - # initialize skeleton of descriptors - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : metric_of, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.0f', - 'units' : 'XXX', - 'slope' : 'XXX', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : params["type"], - } - - if "refresh_rate" not in params: - params["refresh_rate"] = 15 - if "debug" in params: - Debug = params["debug"] - dprint("%s", "Debug mode on") - - _Worker_Thread = UpdateMetricThread(params) - _Worker_Thread.start() - - # IP:HOSTNAME - if "spoof_host" in params: - Desc_Skel["spoof_host"] = params["spoof_host"] - - mp = params["metrix_prefix"] - - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_curr_items", - "units" : "items", - "slope" : "both", - "description": "Current number of items stored", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_get", - "units" : "commands", - "slope" : "positive", - "description": "Cumulative number of retrieval reqs", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_set", - "units" : "commands", - "slope" : "positive", - "description": "Cumulative number of storage reqs", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_bytes_read", - "units" : "bytes", - "slope" : "positive", - "description": "Total number of bytes read by this server from network", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_bytes_written", - "units" : "bytes", - "slope" : "positive", - "description": "Total number of bytes sent by this server to network", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_bytes", - "units" : "bytes", - "slope" : "both", - "description": "Current number of bytes used to store items", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_limit_maxbytes", - "units" : "bytes", - "slope" : "both", - "description": "Number of bytes this server is allowed to use for storage", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_curr_connections", - "units" : "connections", - "slope" : "both", - "description": "Number of open connections", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_decr_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been decremented and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_decr_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been decremented and not found", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_delete_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been deleted and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_delete_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been deleted and not found", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_evictions", - "units" : "items", - "slope" : "both", - "description": "Number of valid items removed from cache to free memory for new items", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_get_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been requested and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_get_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been requested and not found", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_get_hits_rate", - "units" : "items", - "slope" : "both", - "description": "Hits per second", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_get_misses_rate", - "units" : "items", - "slope" : "both", - "description": "Misses per second", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_incr_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been incremented and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_incr_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been incremented and not found", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_get_rate", - "units" : "commands", - "slope" : "both", - "description": "Gets per second", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_set_rate", - "units" : "commands", - "slope" : "both", - "description": "Sets per second", - })) - - # Tokyo Tyrant - if "type" in params and params["type"].lower().find("tokyo") == 0: - dtmp = descriptors[:] - for d in dtmp: - if d["name"] in [ - mp+"_bytes_read", - mp+"_bytes_written", - mp+"_limit_maxbytes", - mp+"_curr_connections", - mp+"_evictions", - ]: - descriptors.remove(d) - for d in descriptors: - if d["name"] == mp+"_get_hits": - d["name"] = mp+"_cmd_get_hits" - if d["name"] == mp+"_get_misses": - d["name"] = mp+"_cmd_get_misses" - - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_set_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been stored and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_set_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been stored and not found", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_delete", - "units" : "commands", - "slope" : "positive", - "description": "Cumulative number of delete reqs", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_delete_hits", - "units" : "items", - "slope" : "positive", - "description": "Number of keys that have been deleted and found present ", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_cmd_delete_misses", - "units" : "items", - "slope" : "positive", - "description": "Number of items that have been deleted and not found", - })) - - - return descriptors - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_of(name): - return _Worker_Thread.metric_of(name) - -def metric_cleanup(): - _Worker_Thread.shutdown() - -if __name__ == '__main__': - try: - params = { - "host" : "localhost", - "port" : 11211, - # "host" : "tt101", - # "port" : 1978, - # "type" : "Tokyo Tyrant", - # "metrix_prefix" : "tt101", - "debug" : True, - } - metric_init(params) - - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print ('value for %s is '+d['format']) % (d['name'], v) - time.sleep(5) - except KeyboardInterrupt: - time.sleep(0.2) - os._exit(1) - except: - traceback.print_exc() - os._exit(1) diff --git a/network/multi_interface/conf.d/multi_interface.pyconf b/network/multi_interface/conf.d/multi_interface.pyconf deleted file mode 100644 index 34aab5fa..00000000 --- a/network/multi_interface/conf.d/multi_interface.pyconf +++ /dev/null @@ -1,68 +0,0 @@ -modules { - module { - name = "multi_interface" - language = "python" - - # Leaving the interfaces value empty will result in all interfaces being - # used ie. anything you can see in /proc/net/dev. If you only want to - # monitor specific ones change value to space delimited list of - # network interfaces e.g. value = "eth0 eth1 bond0" - param interfaces { - value = "" - } - - # If set to true interfaces that are indicated above will be summed - # to produce bytes_out, bytes_in, pkts_out and pkts_in values - # This may be useful in situations where you don't care about internal - # interfaces ie. if machine is dual homed and really care about - # traffic going only externally - param send_aggregate_bytes_packets { - value = False - } - - # Alternatively leave the interfaces list at value = "" then exclude - # specific interfaces by name or regular expression e.g. dummy, lo, eth[0-9]+ etc. - param excluded_interfaces { - value = "lo vnet[0-9]+" - } - - - } -} - -collection_group { - collect_every = 15 - time_threshold = 45 - - metric { - name_match = "rx_(.+)" - value_threshold = 1.0 - } - metric { - name_match = "tx_(.+)" - value_threshold = 1.0 - } - -# Uncomment only if param send_aggregate_bytes_packets set to True -# metric { -# name = "bytes_out" -# value_threshold = 4096 -# title = "Bytes Sent" -# } -# metric { -# name = "bytes_in" -# value_threshold = 4096 -# title = "Bytes Received" -# } -# metric { -# name = "pkts_in" -# value_threshold = 256 -# title = "Packets Received" -# } -# metric { -# name = "pkts_out" -# value_threshold = 256 -# title = "Packets Sent" -# } - -} diff --git a/network/multi_interface/python_modules/multi_interface.py b/network/multi_interface/python_modules/multi_interface.py deleted file mode 100644 index 0955a498..00000000 --- a/network/multi_interface/python_modules/multi_interface.py +++ /dev/null @@ -1,282 +0,0 @@ -import re -import time -import sys -import os -import copy - -PARAMS = {} - -METRICS = { - 'time' : 0, - 'data' : {} -} -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - -INTERFACES = [] -descriptors = [] - -stats_tab = { - "rx_bytes" : 0, - "rx_pkts" : 1, - "rx_errs" : 2, - "rx_drops" : 3, - "tx_bytes" : 8, - "tx_pkts" : 9, - "tx_errs" : 10, - "tx_drops" : 11, -} - -# Where to get the stats from -net_stats_file = "/proc/net/dev" - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors - global INTERFACES - -# INTERFACES = params.get('interfaces') - watch_interfaces = params.get('interfaces') - excluded_interfaces = params.get('excluded_interfaces') - get_interfaces(watch_interfaces,excluded_interfaces) - -# print INTERFACES - time_max = 60 - - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : get_delta, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.0f', - 'units' : '/s', - 'slope' : 'both', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'network', - } - - - for dev in INTERFACES: - descriptors.append(create_desc(Desc_Skel, { - "name" : "rx_bytes_" + dev, - "units" : "bytes/sec", - "description" : "received bytes per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "rx_pkts_" + dev, - "units" : "pkts/sec", - "description" : "received packets per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "rx_errs_" + dev, - "units" : "pkts/sec", - "description" : "received error packets per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "rx_drops_" + dev, - "units" : "pkts/sec", - "description" : "receive packets dropped per sec", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "tx_bytes_" + dev, - "units" : "bytes/sec", - "description" : "transmitted bytes per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "tx_pkts_" + dev, - "units" : "pkts/sec", - "description" : "transmitted packets per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "tx_errs_" + dev, - "units" : "pkts/sec", - "description" : "transmitted error packets per sec", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "tx_drops_" + dev, - "units" : "pkts/sec", - "description" : "transmitted dropped packets per sec", - })) - - if params['send_aggregate_bytes_packets']: - descriptors.append(create_desc(Desc_Skel, { - "name" : "pkts_in", - "units" : "pkts/sec", - "call_back" : get_aggregates, - "description" : "Packets Received", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "pkts_out", - "units" : "pkts/sec", - "call_back" : get_aggregates, - "description" : "Packets Sent", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "bytes_in", - "units" : "bytes/sec", - "call_back" : get_aggregates, - "description" : "Bytes Received", - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : "bytes_out", - "units" : "bytes/sec", - "call_back" : get_aggregates, - "description" : "Bytes Sent", - })) - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -################################################################################### -# Build a list of interfaces -################################################################################### -def get_interfaces(watch_interfaces, excluded_interfaces): - global INTERFACES - if_excluded = 0 - - # check if particular interfaces have been specifieid. Watch only those - if watch_interfaces != "": - INTERFACES = watch_interfaces.split(" ") - else: - if excluded_interfaces != "": - excluded_if_list = excluded_interfaces.split(" ") - f = open(net_stats_file, "r") - for line in f: - # Find only lines with : - if re.search(":", line): - a = line.split(":") - dev_name = a[0].lstrip() - - # Determine if interface is excluded by name or regex - for ex in excluded_if_list: - if re.match(ex,dev_name): - if_excluded = 1 - - if not if_excluded: - INTERFACES.append(dev_name) - if_excluded = 0 - return 0 - - -################################################################################### -# Returns aggregate values for pkts and bytes sent and received. It should be -# used to override the default Ganglia mod_net module. It will generate bytes_in -# bytes_out, pkts_in and pkts_out. -################################################################################### -def get_aggregates(name): - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - # Determine the index of metric we need - if name == "bytes_in": - index = stats_tab["rx_bytes"] - elif name == "bytes_out": - index = stats_tab["tx_bytes"] - elif name == "pkts_out": - index = stats_tab["tx_pkts"] - elif name == "pkts_in": - index = stats_tab["rx_pkts"] - else: - return 0 - - sum = 0 - - # Loop through the list of interfaces we care for - for iface in INTERFACES: - - try: - delta = (float(curr_metrics['data'][iface][index]) - float(last_metrics['data'][iface][index])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - sum += delta - - return sum - - - -def get_metrics(): - """Return all metrics""" - - global METRICS, LAST_METRICS - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - try: - file = open(net_stats_file, 'r') - - except IOError: - return 0 - - # convert to dict - metrics = {} - for line in file: - if re.search(":", line): - a = line.split(":") - dev_name = a[0].lstrip() - metrics[dev_name] = re.split("\s+", a[1].lstrip()) - - # update cache - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': metrics - } - - return [METRICS, LAST_METRICS] - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - # Names will be in the format of tx/rx underscore metric_name underscore interface - # e.g. tx_bytes_eth0 - parts = name.split("_") - iface = parts[2] - name = parts[0] + "_" + parts[1] - - index = stats_tab[name] - - try: - delta = (float(curr_metrics['data'][iface][index]) - float(last_metrics['data'][iface][index])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - -if __name__ == '__main__': - try: - params = { - "interfaces": "", - "excluded_interfaces": "dummy", - "send_aggregate_bytes_packets": True, - "debug" : True, - } - metric_init(params) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print ('value for %s is '+d['format']) % (d['name'], v) - time.sleep(5) - except StandardError: - print sys.exc_info()[0] - os._exit(1) diff --git a/network/netstats/conf.d/netstats.pyconf b/network/netstats/conf.d/netstats.pyconf deleted file mode 100644 index d1abc76a..00000000 --- a/network/netstats/conf.d/netstats.pyconf +++ /dev/null @@ -1,38 +0,0 @@ -modules { - module { - name = "netstats" - language = "python" - } -} - -collection_group { - collect_every = 15 - time_threshold = 45 - - metric { - name_match = "tcpext_(.+)" - value_threshold = 1.0 - } - metric { - name_match = "tcp_(.+)" - value_threshold = 1.0 - } - metric { - name_match = "udp_(.+)" - value_threshold = 1.0 - } - metric { - name_match = "ip_(.+)" - value_threshold = 1.0 - } - metric { - name_match = "icmpmsg_(.+)" - value_threshold = 1.0 - } - - metric { - name_match = "icmp_(.+)" - value_threshold = 1.0 - } - -} diff --git a/network/netstats/python_modules/netstats.py b/network/netstats/python_modules/netstats.py deleted file mode 100644 index f437eb6b..00000000 --- a/network/netstats/python_modules/netstats.py +++ /dev/null @@ -1,246 +0,0 @@ -import sys -import re -import time -import copy -import string - -PARAMS = {} - -METRICS = { - 'time' : 0, - 'data' : {} -} - -stats_files = [ "/proc/net/netstat", "/proc/net/snmp" ] - -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - -stats_pos = {} - -def get_metrics(): - """Return all metrics""" - - global METRICS, LAST_METRICS - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - new_metrics = {} - - for file in stats_files: - try: - file = open(file, 'r') - - except IOError: - return 0 - - # convert to dict - metrics = {} - for line in file: - if re.match("(.*): [0-9]", line): - count = 0 - metrics = re.split("\s+", line) - metric_group = metrics[0].replace(":", "").lower() - new_metrics[metric_group] = dict() - for value in metrics: - # Skip first - if count > 0 and value >= 0 and count in stats_pos[metric_group]: - metric_name = stats_pos[metric_group][count] - new_metrics[metric_group][metric_name] = value - count += 1 - - file.close() - - # update cache - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': new_metrics - } - - return [METRICS, LAST_METRICS] - - -def get_value(name): - """Return a value for the requested metric""" - - metrics = get_metrics()[0] - - name = name[len(NAME_PREFIX):] # remove prefix from name - - try: - result = metrics['data'][name] - except StandardError: - result = 0 - - return result - - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - parts = name.split("_") - group = parts[0] - metric = "_".join(parts[1:]) - - try: - delta = (float(curr_metrics['data'][group][metric]) - float(last_metrics['data'][group][metric])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - -def get_tcploss_percentage(name): - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - try: - pct = 100 * (float(curr_metrics['data']['tcpext']["tcploss"]) - float(last_metrics["data"]['tcpext']["tcploss"])) / (float(curr_metrics['data']['tcp']['outsegs']) + float(curr_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['outsegs'])) - if pct < 0: - print name + " is less 0" - pct = 0 - except Exception: - pct = 0.0 - - return pct - -def get_tcpattemptfail_percentage(name): - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - try: - pct = 100 * (float(curr_metrics['data']['tcp']["attemptfails"]) - float(last_metrics["data"]['tcp']["attemptfails"])) / (float(curr_metrics['data']['tcp']['outsegs']) + float(curr_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['outsegs'])) - if pct < 0: - print name + " is less 0" - pct = 0 - except Exception: - pct = 0.0 - - return pct - - -def get_retrans_percentage(name): - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - try: - pct = 100 * (float(curr_metrics['data']['tcp']["retranssegs"]) - float(last_metrics['data']['tcp']["retranssegs"])) / (float(curr_metrics['data']['tcp']['outsegs']) + float(curr_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['outsegs'])) - if pct < 0: - print name + " is less 0" - pct = 0 - except Exception: - pct = 0.0 - - return pct - - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors, metric_map, Desc_Skel - - descriptors = [] - - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : get_delta, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.5f', - 'units' : 'count/s', - 'slope' : 'both', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'XXX', - } - - #################################################################################### - # Let's figure out what metrics are available - # - # Read /proc/net/netstat - #################################################################################### - for file in stats_files: - try: - file = open(file, 'r') - - except IOError: - return 0 - - # Find mapping - for line in file: - # Lines with - if not re.match("(.*): [0-9]", line): - count = 0 - mapping = re.split("\s+", line) - metric_group = mapping[0].replace(":", "").lower() - stats_pos[metric_group] = dict() - for metric in mapping: - # Skip first - if count > 0 and metric != "": - lowercase_metric = metric.lower() - stats_pos[metric_group][count] = lowercase_metric - count += 1 - - file.close() - - for group in stats_pos: - for item in stats_pos[group]: - descriptors.append(create_desc(Desc_Skel, { - "name" : group + "_" + stats_pos[group][item], - "description": stats_pos[group][item], - 'groups' : group - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "tcpext_tcploss_percentage", - "call_back" : get_tcploss_percentage, - "description": "TCP percentage loss, tcploss / insegs + outsegs", - "units" : "pct", - 'groups' : 'tcpext' - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "tcp_attemptfails_percentage", - "call_back" : get_tcpattemptfail_percentage, - "description": "TCP attemptfail percentage, tcpattemptfail / insegs + outsegs", - "units" : "pct", - 'groups' : 'tcp' - })) - - - descriptors.append(create_desc(Desc_Skel, { - "name" : "tcp_retrans_percentage", - "call_back" : get_retrans_percentage, - "description": "TCP retrans percentage, retranssegs / insegs + outsegs", - "units" : "pct", - 'groups' : 'tcp' - })) - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -#This code is for debugging and unit testing -if __name__ == '__main__': - descriptors = metric_init(PARAMS) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print '%s = %s' % (d['name'], v) - print 'Sleeping 15 seconds' - time.sleep(15) diff --git a/nfsstats/conf.d/nfsstats.pyconf b/nfsstats/conf.d/nfsstats.pyconf deleted file mode 100644 index e81c303d..00000000 --- a/nfsstats/conf.d/nfsstats.pyconf +++ /dev/null @@ -1,615 +0,0 @@ -modules { - module { - name = "nfsstats" - language = "python" - } -} - -collection_group { - collect_every = 60 - time_threshold = 120 - metric { - name = "nfs_v3_total" - title = "NFS v3 total" - } - metric { - name = "nfs_v3_getattr" - title = "NFS v3 getattr" - } - metric { - name = "nfs_v3_setattr" - title = "NFS v3 setattr" - } - metric { - name = "nfs_v3_lookup" - title = "NFS v3 lookup" - } - metric { - name = "nfs_v3_access" - title = "NFS v3 access" - } - metric { - name = "nfs_v3_readlink" - title = "NFS v3 readlink" - } - metric { - name = "nfs_v3_read" - title = "NFS v3 read" - } - metric { - name = "nfs_v3_write" - title = "NFS v3 write" - } - metric { - name = "nfs_v3_create" - title = "NFS v3 create" - } - metric { - name = "nfs_v3_mkdir" - title = "NFS v3 mkdir" - } - metric { - name = "nfs_v3_symlink" - title = "NFS v3 symlink" - } - metric { - name = "nfs_v3_mknod" - title = "NFS v3 mknod" - } - metric { - name = "nfs_v3_remove" - title = "NFS v3 remove" - } - metric { - name = "nfs_v3_rmdir" - title = "NFS v3 rmdir" - } - metric { - name = "nfs_v3_rename" - title = "NFS v3 rename" - } - metric { - name = "nfs_v3_link" - title = "NFS v3 link" - } - metric { - name = "nfs_v3_readdir" - title = "NFS v3 readdir" - } - metric { - name = "nfs_v3_readdirplus" - title = "NFS v3 readdirplus" - } - metric { - name = "nfs_v3_fsstat" - title = "NFS v3 fsstat" - } - metric { - name = "nfs_v3_fsinfo" - title = "NFS v3 fsinfo" - } - metric { - name = "nfs_v3_pathconf" - title = "NFS v3 pathconf" - } - metric { - name = "nfs_v3_commit" - title = "NFS v3 commit" - } - metric { - name = "nfsd_v3_total" - title = "NFSD v3 total" - } - metric { - name = "nfsd_v3_getattr" - title = "NFSD v3 getattr" - } - metric { - name = "nfsd_v3_setattr" - title = "NFSD v3 setattr" - } - metric { - name = "nfsd_v3_lookup" - title = "NFSD v3 lookup" - } - metric { - name = "nfsd_v3_access" - title = "NFSD v3 access" - } - metric { - name = "nfsd_v3_readlink" - title = "NFSD v3 readlink" - } - metric { - name = "nfsd_v3_read" - title = "NFSD v3 read" - } - metric { - name = "nfsd_v3_write" - title = "NFSD v3 write" - } - metric { - name = "nfsd_v3_create" - title = "NFSD v3 create" - } - metric { - name = "nfsd_v3_mkdir" - title = "NFSD v3 mkdir" - } - metric { - name = "nfsd_v3_symlink" - title = "NFSD v3 symlink" - } - metric { - name = "nfsd_v3_mknod" - title = "NFSD v3 mknod" - } - metric { - name = "nfsd_v3_remove" - title = "NFSD v3 remove" - } - metric { - name = "nfsd_v3_rmdir" - title = "NFSD v3 rmdir" - } - metric { - name = "nfsd_v3_rename" - title = "NFSD v3 rename" - } - metric { - name = "nfsd_v3_link" - title = "NFSD v3 link" - } - metric { - name = "nfsd_v3_readdir" - title = "NFSD v3 readdir" - } - metric { - name = "nfsd_v3_readdirplus" - title = "NFSD v3 readdirplus" - } - metric { - name = "nfsd_v3_fsstat" - title = "NFSD v3 fsstat" - } - metric { - name = "nfsd_v3_fsinfo" - title = "NFSD v3 fsinfo" - } - metric { - name = "nfsd_v3_pathconf" - title = "NFSD v3 pathconf" - } - metric { - name = "nfsd_v3_commit" - title = "NFSD v3 commit" - } - metric { - name = "nfs_v4_total" - title = "NFS v4 total" - } - metric { - name = "nfs_v4_read" - title = "NFS v4 read" - } - metric { - name = "nfs_v4_write" - title = "NFS v4 write" - } - metric { - name = "nfs_v4_commit" - title = "NFS v4 commit" - } - metric { - name = "nfs_v4_open" - title = "NFS v4 open" - } - metric { - name = "nfs_v4_open_conf" - title = "NFS v4 open_conf" - } - metric { - name = "nfs_v4_open_noat" - title = "NFS v4 open_noat" - } - metric { - name = "nfs_v4_open_dgrd" - title = "NFS v4 open_dgrd" - } - metric { - name = "nfs_v4_close" - title = "NFS v4 close" - } - metric { - name = "nfs_v4_setattr" - title = "NFS v4 setattr" - } - metric { - name = "nfs_v4_renew" - title = "NFS v4 renew" - } - metric { - name = "nfs_v4_setclntid" - title = "NFS v4 setclntid" - } - metric { - name = "nfs_v4_confirm" - title = "NFS v4 confirm" - } - metric { - name = "nfs_v4_lock" - title = "NFS v4 lock" - } - metric { - name = "nfs_v4_lockt" - title = "NFS v4 lockt" - } - metric { - name = "nfs_v4_locku" - title = "NFS v4 locku" - } - metric { - name = "nfs_v4_access" - title = "NFS v4 access" - } - metric { - name = "nfs_v4_getattr" - title = "NFS v4 getattr" - } - metric { - name = "nfs_v4_lookup" - title = "NFS v4 lookup" - } - metric { - name = "nfs_v4_lookup_root" - title = "NFS v4 lookup_root" - } - metric { - name = "nfs_v4_remove" - title = "NFS v4 remove" - } - metric { - name = "nfs_v4_rename" - title = "NFS v4 rename" - } - metric { - name = "nfs_v4_link" - title = "NFS v4 link" - } - metric { - name = "nfs_v4_symlink" - title = "NFS v4 symlink" - } - metric { - name = "nfs_v4_create" - title = "NFS v4 create" - } - metric { - name = "nfs_v4_pathconf" - title = "NFS v4 pathconf" - } - metric { - name = "nfs_v4_statfs" - title = "NFS v4 statfs" - } - metric { - name = "nfs_v4_readlink" - title = "NFS v4 readlink" - } - metric { - name = "nfs_v4_readdir" - title = "NFS v4 readdir" - } - metric { - name = "nfs_v4_server_caps" - title = "NFS v4 server_caps" - } - metric { - name = "nfs_v4_delegreturn" - title = "NFS v4 delegreturn" - } - metric { - name = "nfs_v4_getacl" - title = "NFS v4 getacl" - } - metric { - name = "nfs_v4_setacl" - title = "NFS v4 setacl" - } - metric { - name = "nfs_v4_fs_locations" - title = "NFS v4 fs_locations" - } - metric { - name = "nfs_v4_rel_lkowner" - title = "NFS v4 rel_lkowner" - } - metric { - name = "nfs_v4_secinfo" - title = "NFS v4 secinfo" - } - metric { - name = "nfs_v4_exchange_id" - title = "NFS v4 exchange_id" - } - metric { - name = "nfs_v4_create_ses" - title = "NFS v4 create_ses" - } - metric { - name = "nfs_v4_destroy_ses" - title = "NFS v4 destroy_ses" - } - metric { - name = "nfs_v4_sequence" - title = "NFS v4 sequence" - } - metric { - name = "nfs_v4_get_lease_t" - title = "NFS v4 get_lease_t" - } - metric { - name = "nfs_v4_reclaim_comp" - title = "NFS v4 reclaim_comp" - } - metric { - name = "nfs_v4_layoutget" - title = "NFS v4 layoutget" - } - metric { - name = "nfs_v4_getdevinfo" - title = "NFS v4 getdevinfo" - } - metric { - name = "nfs_v4_layoutcommit" - title = "NFS v4 layoutcommit" - } - metric { - name = "nfs_v4_layoutreturn" - title = "NFS v4 layoutreturn" - } - metric { - name = "nfs_v4_getdevlist" - title = "NFS v4 getdevlist" - } - metric { - name = "nfsd_v4_total" - title = "NFSD v4 total" - } - metric { - name = "nfsd_v4_op0-unused" - title = "NFSD v4 op0-unused" - } - metric { - name = "nfsd_v4_op1-unused" - title = "NFSD v4 op1-unused" - } - metric { - name = "nfsd_v4_op2-future" - title = "NFSD v4 op2-future" - } - metric { - name = "nfsd_v4_access" - title = "NFSD v4 access" - } - metric { - name = "nfsd_v4_close" - title = "NFSD v4 close" - } - metric { - name = "nfsd_v4_commit" - title = "NFSD v4 commit" - } - metric { - name = "nfsd_v4_create" - title = "NFSD v4 create" - } - metric { - name = "nfsd_v4_delegpurge" - title = "NFSD v4 delegpurge" - } - metric { - name = "nfsd_v4_delegreturn" - title = "NFSD v4 delegreturn" - } - metric { - name = "nfsd_v4_getattr" - title = "NFSD v4 getattr" - } - metric { - name = "nfsd_v4_getfh" - title = "NFSD v4 getfh" - } - metric { - name = "nfsd_v4_link" - title = "NFSD v4 link" - } - metric { - name = "nfsd_v4_lock" - title = "NFSD v4 lock" - } - metric { - name = "nfsd_v4_lockt" - title = "NFSD v4 lockt" - } - metric { - name = "nfsd_v4_locku" - title = "NFSD v4 locku" - } - metric { - name = "nfsd_v4_lookup" - title = "NFSD v4 lookup" - } - metric { - name = "nfsd_v4_lookup_root" - title = "NFSD v4 lookup_root" - } - metric { - name = "nfsd_v4_nverify" - title = "NFSD v4 nverify" - } - metric { - name = "nfsd_v4_open" - title = "NFSD v4 open" - } - metric { - name = "nfsd_v4_openattr" - title = "NFSD v4 openattr" - } - metric { - name = "nfsd_v4_open_conf" - title = "NFSD v4 open_conf" - } - metric { - name = "nfsd_v4_open_dgrd" - title = "NFSD v4 open_dgrd" - } - metric { - name = "nfsd_v4_putfh" - title = "NFSD v4 putfh" - } - metric { - name = "nfsd_v4_putpubfh" - title = "NFSD v4 putpubfh" - } - metric { - name = "nfsd_v4_putrootfh" - title = "NFSD v4 putrootfh" - } - metric { - name = "nfsd_v4_read" - title = "NFSD v4 read" - } - metric { - name = "nfsd_v4_readdir" - title = "NFSD v4 readdir" - } - metric { - name = "nfsd_v4_readlink" - title = "NFSD v4 readlink" - } - metric { - name = "nfsd_v4_remove" - title = "NFSD v4 remove" - } - metric { - name = "nfsd_v4_rename" - title = "NFSD v4 rename" - } - metric { - name = "nfsd_v4_renew" - title = "NFSD v4 renew" - } - metric { - name = "nfsd_v4_restorefh" - title = "NFSD v4 restorefh" - } - metric { - name = "nfsd_v4_savefh" - title = "NFSD v4 savefh" - } - metric { - name = "nfsd_v4_secinfo" - title = "NFSD v4 secinfo" - } - metric { - name = "nfsd_v4_setattr" - title = "NFSD v4 setattr" - } - metric { - name = "nfsd_v4_setcltid" - title = "NFSD v4 setcltid" - } - metric { - name = "nfsd_v4_setcltidconf" - title = "NFSD v4 setcltidconf" - } - metric { - name = "nfsd_v4_verify" - title = "NFSD v4 verify" - } - metric { - name = "nfsd_v4_write" - title = "NFSD v4 write" - } - metric { - name = "nfsd_v4_rellockowner" - title = "NFSD v4 rellockowner" - } - metric { - name = "nfsd_v4_bc_ctl" - title = "NFSD v4 bc_ctl" - } - metric { - name = "nfsd_v4_bind_conn" - title = "NFSD v4 bind_conn" - } - metric { - name = "nfsd_v4_exchange_id" - title = "NFSD v4 exchange_id" - } - metric { - name = "nfsd_v4_create_ses" - title = "NFSD v4 create_ses" - } - metric { - name = "nfsd_v4_destroy_ses" - title = "NFSD v4 destroy_ses" - } - metric { - name = "nfsd_v4_free_stateid" - title = "NFSD v4 free_stateid" - } - metric { - name = "nfsd_v4_getdirdeleg" - title = "NFSD v4 getdirdeleg" - } - metric { - name = "nfsd_v4_getdevinfo" - title = "NFSD v4 getdevinfo" - } - metric { - name = "nfsd_v4_getdevlist" - title = "NFSD v4 getdevlist" - } - metric { - name = "nfsd_v4_layoutcommit" - title = "NFSD v4 layoutcommit" - } - metric { - name = "nfsd_v4_layoutget" - title = "NFSD v4 layoutget" - } - metric { - name = "nfsd_v4_layoutreturn" - title = "NFSD v4 layoutreturn" - } - metric { - name = "nfsd_v4_secinfononam" - title = "NFSD v4 secinfononam" - } - metric { - name = "nfsd_v4_sequence" - title = "NFSD v4 sequence" - } - metric { - name = "nfsd_v4_set_ssv" - title = "NFSD v4 set_ssv" - } - metric { - name = "nfsd_v4_test_stateid" - title = "NFSD v4 test_stateid" - } - metric { - name = "nfsd_v4_want_deleg" - title = "NFSD v4 want_deleg" - } - metric { - name = "nfsd_v4_destroy_clid" - title = "NFSD v4 destroy_clid" - } - metric { - name = "nfsd_v4_reclaim_comp" - title = "NFSD v4 reclaim_comp" - } -} diff --git a/nfsstats/python_modules/nfsstats.py b/nfsstats/python_modules/nfsstats.py deleted file mode 100644 index 5c228c77..00000000 --- a/nfsstats/python_modules/nfsstats.py +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/bin/python - -import os -import stat -import re -import time -import syslog -import sys -import string - -def test_proc( p_file, p_string ): - global p_match - """ - Check if contains keyword e.g. proc3, proc4 - """ - - p_fd = open( p_file ) - - p_contents = p_fd.read() - - p_fd.close() - - p_match = re.search(".*" + p_string + "\s.*", p_contents, flags=re.MULTILINE) - - if not p_match: - return False - else: - return True - -verboselevel = 0 -descriptors = [ ] -old_values = { } -# What we want ganglia to monitor, where to find it, how to extract it, ... -configtable = [ - { - 'group': 'nfs_client', - 'tests': [ 'stat.S_ISREG(os.stat("/proc/net/rpc/nfs").st_mode)', 'test_proc("/proc/net/rpc/nfs", "proc3")' ], - 'prefix': 'nfs_v3_', - # The next 4 lines can be at the 'group' level or the 'name' level - 'file': '/proc/net/rpc/nfs', - 'value_type': 'float', - 'units': 'calls/sec', - 'format': '%f', - 'names': { - 'total': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\d+.*\d)\n" }, - 'getattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\S*)" }, - 'setattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){3}(\S*)" }, - 'lookup': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){4}(\S*)" }, - 'access': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){5}(\S*)" }, - 'readlink': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){6}(\S*)" }, - 'read': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){7}(\S*)" }, - 'write': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){8}(\S*)" }, - 'create': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){9}(\S*)" }, - 'mkdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){10}(\S*)" }, - 'symlink': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){11}(\S*)" }, - 'mknod': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){12}(\S*)" }, - 'remove': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){13}(\S*)" }, - 'rmdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){14}(\S*)" }, - 'rename': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){15}(\S*)" }, - 'link': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){16}(\S*)" }, - 'readdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){17}(\S*)" }, - 'readdirplus': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){18}(\S*)" }, - 'fsstat': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){19}(\S*)" }, - 'fsinfo': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){20}(\S*)" }, - 'pathconf': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){21}(\S*)" }, - 'commit': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){22}(\S*)" } - } - }, - { - 'group': 'nfs_client_v4', - 'tests': [ 'stat.S_ISREG(os.stat("/proc/net/rpc/nfs").st_mode)', 'test_proc("/proc/net/rpc/nfs", "proc4")' ], - 'prefix': 'nfs_v4_', - # The next 4 lines can be at the 'group' level or the 'name' level - 'file': '/proc/net/rpc/nfs', - 'value_type': 'float', - 'units': 'calls/sec', - 'format': '%f', - 'names': { - 'total': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){2}(\d+.*\d)\n" }, - 'read': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){2}(\S*)" }, - 'write': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){3}(\S*)" }, - 'commit': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){4}(\S*)" }, - 'open': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){5}(\S*)" }, - 'open_conf': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){6}(\S*)" }, - 'open_noat': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){7}(\S*)" }, - 'open_dgrd': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){8}(\S*)" }, - 'close': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){9}(\S*)" }, - 'setattr': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){10}(\S*)" }, - 'renew': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){11}(\S*)" }, - 'setclntid': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){12}(\S*)" }, - 'confirm': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){13}(\S*)" }, - 'lock': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){14}(\S*)" }, - 'lockt': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){15}(\S*)" }, - 'locku': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){16}(\S*)" }, - 'access': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){17}(\S*)" }, - 'getattr': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){18}(\S*)" }, - 'lookup': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){19}(\S*)" }, - 'lookup_root': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){20}(\S*)" }, - 'remove': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){21}(\S*)" }, - 'rename': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){22}(\S*)" }, - 'link': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){23}(\S*)" }, - 'symlink': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){24}(\S*)" }, - 'create': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){25}(\S*)" }, - 'pathconf': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){26}(\S*)" }, - 'statfs': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){27}(\S*)" }, - 'readlink': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){28}(\S*)" }, - 'readdir': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){29}(\S*)" }, - 'server_caps': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){30}(\S*)" }, - 'delegreturn': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){31}(\S*)" }, - 'getacl': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){32}(\S*)" }, - 'setacl': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){33}(\S*)" }, - 'fs_locations': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){34}(\S*)" }, - 'rel_lkowner': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){35}(\S*)" }, - 'secinfo': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){36}(\S*)" }, - 'exchange_id': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){37}(\S*)" }, - 'create_ses': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){38}(\S*)" }, - 'destroy_ses': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){39}(\S*)" }, - 'sequence': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){40}(\S*)" }, - 'get_lease_t': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){41}(\S*)" }, - 'reclaim_comp': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){42}(\S*)" }, - 'layoutget': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){43}(\S*)" }, - 'getdevinfo': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){44}(\S*)" }, - 'layoutcommit': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){45}(\S*)" }, - 'layoutreturn': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){46}(\S*)" }, - 'getdevlist': { 'description':'dummy description', 're': ".*proc4 (?:\S*\s){47}(\S*)" } - } - }, - { - 'group': 'nfs_server', - 'tests': [ 'stat.S_ISREG(os.stat("/proc/net/rpc/nfsd").st_mode)', 'test_proc("/proc/net/rpc/nfsd", "proc3")' ], - 'prefix': 'nfsd_v3_', - # The next 4 lines can be at the 'group' level or the 'name' level - 'file': '/proc/net/rpc/nfsd', - 'value_type': 'float', - 'units': 'calls/sec', - 'format': '%f', - 'names': { - 'total': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\d+.*\d)\n" }, - 'getattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\S*)" }, - 'setattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){3}(\S*)" }, - 'lookup': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){4}(\S*)" }, - 'access': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){5}(\S*)" }, - 'readlink': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){6}(\S*)" }, - 'read': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){7}(\S*)" }, - 'write': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){8}(\S*)" }, - 'create': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){9}(\S*)" }, - 'mkdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){10}(\S*)" }, - 'symlink': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){11}(\S*)" }, - 'mknod': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){12}(\S*)" }, - 'remove': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){13}(\S*)" }, - 'rmdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){14}(\S*)" }, - 'rename': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){15}(\S*)" }, - 'link': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){16}(\S*)" }, - 'readdir': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){17}(\S*)" }, - 'readdirplus': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){18}(\S*)" }, - 'fsstat': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){19}(\S*)" }, - 'fsinfo': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){20}(\S*)" }, - 'pathconf': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){21}(\S*)" }, - 'commit': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){22}(\S*)" } - }, - }, - { - 'group': 'nfs_server_v4', - 'tests': [ 'stat.S_ISREG(os.stat("/proc/net/rpc/nfsd").st_mode)', 'test_proc("/proc/net/rpc/nfsd", "proc4ops")' ], - 'prefix': 'nfsd_v4_', - # The next 4 lines can be at the 'group' level or the 'name' level - 'file': '/proc/net/rpc/nfsd', - 'value_type': 'float', - 'units': 'calls/sec', - 'format': '%f', - 'names': { - 'total': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){2}(\d+.*\d)\n" }, - 'op0-unused': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){1}(\S*)" }, - 'op1-unused': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){2}(\S*)" }, - 'op2-future': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){3}(\S*)" }, - 'access': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){4}(\S*)" }, - 'close': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){5}(\S*)" }, - 'commit': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){6}(\S*)" }, - 'create': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){7}(\S*)" }, - 'delegpurge': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){8}(\S*)" }, - 'delegreturn': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){9}(\S*)" }, - 'getattr': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){10}(\S*)" }, - 'getfh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){11}(\S*)" }, - 'link': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){12}(\S*)" }, - 'lock': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){13}(\S*)" }, - 'lockt': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){14}(\S*)" }, - 'locku': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){15}(\S*)" }, - 'lookup': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){16}(\S*)" }, - 'lookup_root': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){17}(\S*)" }, - 'nverify': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){18}(\S*)" }, - 'open': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){19}(\S*)" }, - 'openattr': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){20}(\S*)" }, - 'open_conf': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){21}(\S*)" }, - 'open_dgrd': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){22}(\S*)" }, - 'putfh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){23}(\S*)" }, - 'putpubfh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){24}(\S*)" }, - 'putrootfh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){25}(\S*)" }, - 'read': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){26}(\S*)" }, - 'readdir': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){27}(\S*)" }, - 'readlink': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){28}(\S*)" }, - 'remove': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){29}(\S*)" }, - 'rename': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){30}(\S*)" }, - 'renew': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){31}(\S*)" }, - 'restorefh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){32}(\S*)" }, - 'savefh': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){33}(\S*)" }, - 'secinfo': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){34}(\S*)" }, - 'setattr': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){35}(\S*)" }, - 'setcltid': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){36}(\S*)" }, - 'setcltidconf': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){37}(\S*)" }, - 'verify': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){38}(\S*)" }, - 'write': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){39}(\S*)" }, - 'rellockowner': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){40}(\S*)" }, - 'bc_ctl': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){41}(\S*)" }, - 'bind_conn': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){42}(\S*)" }, - 'exchange_id': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){43}(\S*)" }, - 'create_ses': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){44}(\S*)" }, - 'destroy_ses': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){45}(\S*)" }, - 'free_stateid': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){46}(\S*)" }, - 'getdirdeleg': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){47}(\S*)" }, - 'getdevinfo': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){48}(\S*)" }, - 'getdevlist': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){49}(\S*)" }, - 'layoutcommit': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){50}(\S*)" }, - 'layoutget': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){51}(\S*)" }, - 'layoutreturn': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){52}(\S*)" }, - 'secinfononam': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){53}(\S*)" }, - 'sequence': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){54}(\S*)" }, - 'set_ssv': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){55}(\S*)" }, - 'test_stateid': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){56}(\S*)" }, - 'want_deleg': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){57}(\S*)" }, - 'destroy_clid': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){58}(\S*)" }, - 'reclaim_comp': { 'description':'dummy description', 're': ".*proc4ops (?:\S*\s){59}(\S*)" } - }, - } -] - -# Ganglia will call metric_init(), which should return a dictionary for each thing that it -# should monitor, including the name of the callback function to get the current value. -def metric_init(params): - global descriptors - global old_values - global configtable - - for i in range(0, len(configtable)): - # Don't set up dictionary for any group member if group applicability tests fail. - tests_passed = True - for j in range(0, len(configtable[i]['tests'])): - try: - if eval(configtable[i]['tests'][j]): - pass - else: - tests_passed = False - break - except: - tests_passed = False - break - if not tests_passed: - continue - - # 2nd param defines number of params that will follow (differs between NFS versions) - max_plimit = re.split("\W+", p_match.group())[1] - - # Parse our defined params list in order to ensure list will not exceed max_plimit - n = 0 - names_keys = configtable[i]['names'].keys() - keys_to_remove = [] - for _tmpkey in names_keys: - _tmplist = names_keys - param_pos = re.split("{(\d+)\}", configtable[i]['names'][_tmpkey].values()[0])[1] - if int(param_pos) > int(max_plimit): - keys_to_remove.append(_tmpkey) - n += 1 - - if len(keys_to_remove) > 0: - for key in keys_to_remove: - names_keys.remove(key) - - # For each name in the group ... - for name in names_keys: - # ... set up dictionary ... - if 'format' in configtable[i]['names'][name]: - format_str = configtable[i]['names'][name]['format'] - else: - format_str = configtable[i]['format'] - if 'units' in configtable[i]['names'][name]: - unit_str = configtable[i]['names'][name]['units'] - else: - unit_str = configtable[i]['units'] - if 'value_type' in configtable[i]['names'][name]: - value_type_str = configtable[i]['names'][name]['value_type'] - else: - value_type_str = configtable[i]['value_type'] - if 'file' in configtable[i]['names'][name]: - file_str = configtable[i]['names'][name]['file'] - else: - file_str = configtable[i]['file'] - - - descriptors.append({ - 'name': configtable[i]['prefix'] + name, - 'call_back': call_back, - 'time_max': 90, - 'format': format_str, - 'units': unit_str, - 'value_type': value_type_str, - 'slope': 'both', - 'description': configtable[i]['names'][name]['description'], - 'groups': configtable[i]['group'], - # The following are module-private data stored in a public variable - 'file': file_str, - 're': configtable[i]['names'][name]['re'] - }) - # And get current value cached as previous value, for future comparisons. - (ts, value) = get_value(configtable[i]['prefix'] + name) - old_values[configtable[i]['prefix'] + name] = { - 'time':ts, - 'value':value - } - - # Pass ganglia the complete list of dictionaries. - return descriptors - -# Ganglia will call metric_cleanup() when it exits. -def metric_cleanup(): - pass - -# metric_init() registered this as the callback function. -def call_back(name): - global old_values - - # Get new value - (new_time, new_value) = get_value(name) - - # Calculate rate of change - try: - rate = (new_value - old_values[name]['value'])/(new_time - old_values[name]['time']) - except ZeroDivisionError: - rate = 0.0 - - # Stash values for comparison next time round. - old_values[name]['value'] = new_value - old_values[name]['time'] = new_time - return rate - -def get_value(name): - global descriptors - - # Search descriptors array for this name's file and extractor RE - for i in range(0, len(descriptors)): - if descriptors[i]['name'] == name: - break - contents = file(descriptors[i]['file']).read() - m = re.search(descriptors[i]['re'], contents, flags=re.MULTILINE) - - m_value = m.group(1) - - #RB: multiple (space seperated) values: calculate sum - if string.count( m_value, ' ' ) > 0: - m_fields = string.split( m_value, ' ' ) - - sum_value = 0 - - for f in m_fields: - sum_value = sum_value + int(f) - - m_value = sum_value - - # Return time and value. - ts = time.time() - return (ts, int(m_value)) - -def debug(level, text): - global verboselevel - if level > verboselevel: - return - if sys.stderr.isatty(): - print text - else: - syslog.syslog(text) - -#This code is for debugging and unit testing -if __name__ == '__main__': - metric_init(None) - # wait some time time for some real data - time.sleep(5) - for d in descriptors: - v = d['call_back'](d['name']) - debug(10, ('__main__: value for %s is %s' % (d['name'], d['format'])) % (v)) diff --git a/procstat/conf.d/procstat.pyconf b/procstat/conf.d/procstat.pyconf deleted file mode 100644 index 68c83047..00000000 --- a/procstat/conf.d/procstat.pyconf +++ /dev/null @@ -1,38 +0,0 @@ -# - -modules { - module { - name = 'procstat' - language = 'python' - - param httpd { - value = '/var/run/httpd.pid' - } - - param mysqld { - value = '/\/usr\/libexec\/mysqld/' - } - - param splunk { - value = '/splunkd.*start/' - } - - param splunk-web { - value = '/twistd.*SplunkWeb/' - } - } -} - -collection_group { - collect_every = 30 - time_threshold = 30 - - metric { - name_match = "procstat_(.+)_cpu" - } - - metric { - name_match = "procstat_(.+)_mem" - } -} - diff --git a/procstat/python_modules/procstat.py b/procstat/python_modules/procstat.py deleted file mode 100644 index e4054d16..00000000 --- a/procstat/python_modules/procstat.py +++ /dev/null @@ -1,509 +0,0 @@ -### This script reports process metrics to ganglia. -### -### Notes: -### This script exposes values for CPU and memory utilization -### for running processes. You can retrieve the process ID from -### either providing a pidfile or an awk regular expression. -### Using a pidfile is the most efficient and direct method. -### -### When using a regular expression, keep in mind that there is -### a chance for a false positive. This script will help to avoid -### these by only returning parent processes. This means that -### the results are limited to processes where ppid = 1. -### -### This script also comes with the ability to test your regular -### expressions via command line arguments "-t". -### -### Testing: -### -- This is a correct examples of how to monitor apache. -### -### $ python procstat.py -p httpd -v '/var/run/httpd.pid' -t -### Testing httpd: /var/run/httpd.pid -### Processes in this group: -### PID, ARGS -### 11058 /usr/sbin/httpd -### 8817 /usr/sbin/httpd -### 9000 /usr/sbin/httpd -### 9001 /usr/sbin/httpd -### -### waiting 2 seconds -### procstat_httpd_mem: 202076 KB [The total memory utilization] -### procstat_httpd_cpu: 0.3 percent [The total percent CPU utilization] -### -### -- This example shows a regex that returns no processes with a -### ppid of 1. -### -### $ python procstat.py -p test -v 'wrong' -t -### Testing test: wrong -### failed getting pgid: no process returned -### ps -Ao pid,ppid,pgid,args | awk 'wrong && $2 == 1 && !/awk/ && !/procstat\.py/ {print $0}' -### -### -- This example shows a regex that returns more than one process -### with a ppid of 1. -### -### $ python procstat.py -p test -v '/mingetty/' -t -### Testing test: /mingetty/ -### failed getting pgid: more than 1 result returned -### ps -Ao pid,ppid,pgid,args | awk '/mingetty/ && $2 == 1 && !/awk/ && !/procstat\.py/ {print $0}' -### 7313 1 7313 /sbin/mingetty tty1 -### 7314 1 7314 /sbin/mingetty tty2 -### 7315 1 7315 /sbin/mingetty tty3 -### 7316 1 7316 /sbin/mingetty tty4 -### 7317 1 7317 /sbin/mingetty tty5 -### 7318 1 7318 /sbin/mingetty tty6 -### -### Command Line Example: -### $ python procstat.py -p httpd,opennms,splunk,splunk-web \ -### -v '/var/run/httpd.pid','/opt/opennms/logs/daemon/opennms.pid','/splunkd.*start/','/twistd.*SplunkWeb/' -### -### procstat_httpd_mem: 202068 KB [The total memory utilization] -### procstat_splunk_mem: 497848 KB [The total memory utilization] -### procstat_splunk-web_mem: 32636 KB [The total memory utilization] -### procstat_opennms_mem: 623112 KB [The total memory utilization] -### procstat_httpd_cpu: 0.3 percent [The total percent CPU utilization] -### procstat_splunk_cpu: 0.6 percent [The total percent CPU utilization] -### procstat_splunk-web_cpu: 0.1 percent [The total percent CPU utilization] -### procstat_opennms_cpu: 7.1 percent [The total percent CPU utilization] -### -### Example Values: -### httpd: /var/run/httpd.pid or \/usr\/sbin\/httpd -### mysqld: /var/run/mysqld/mysqld.pid or /\/usr\/bin\/mysqld_safe/ -### postgresql: /var/run/postmaster.[port].pid or /\/usr\/bin\/postmaster.*[port]/ -### splunk: /splunkd.*start/ -### splunk-web: /twistd.*SplunkWeb/ -### opennms: /opt/opennms/logs/daemon/opennms.pid or java.*Dopennms -### netflow: /java.*NetFlow/ -### postfix: /var/spool/postfix/pid/master.pid or /\/usr\/libexec\/postfix\/master/ -### -### Error Tests: -### python procstat.py -p test-more,test-none,test-pidfail -v '/java/','/javaw/','java.pid' -t -### -### Changelog: -### v1.0.1 - 2010-07-23 -### * Initial version -### -### v1.1.0 - 2010-07-28 -### * Modified the process regex search to find the parent -### process and then find all processes with the same process -### group ID (pgid). "ps" is only used for regex searching on -### the initial lookup for the parent pid (ppid). Now all -### subsequent calls use /proc/[pid]/stat for CPU jiffies, and -### /proc/[pid]/statm for memory rss. -### * Added testing switch "-t" to help troubleshoot a regex -### * Added display switches "-s" and "-m" to format the output -### of /proc/[pid]/stat and /proc/[pid]/statm -### - -### Copyright Jamie Isaacs. 2010 -### License to use, modify, and distribute under the GPL -### http://www.gnu.org/licenses/gpl.txt - -import time -import subprocess -import traceback, sys -import os.path -import glob -import logging - -descriptors = [] - -logging.basicConfig(level=logging.ERROR, format="%(asctime)s - %(name)s - %(levelname)s\t Thread-%(thread)d - %(message)s", filename='/tmp/gmond.log', filemode='w') -logging.debug('starting up') - -last_update = 0 -stats = {} -last_val = {} -pgid_list = {} - -MAX_UPDATE_TIME = 15 - -# clock ticks per second... jiffies (HZ) -JIFFIES_PER_SEC = os.sysconf('SC_CLK_TCK') - -PAGE_SIZE=os.sysconf('SC_PAGE_SIZE') - -PROCESSES = {} - -def readCpu(pid): - try: - stat = file('/proc/' + pid + '/stat', 'rt').readline().split() - #logging.debug(' stat (' + pid + '): ' + str(stat)) - utime = int(stat[13]) - stime = int(stat[14]) - cutime = int(stat[15]) - cstime = int(stat[16]) - return (utime + stime + cutime + cstime) - except: - logging.warning('failed to get (' + str(pid) + ') stats') - return 0 - -def get_pgid(proc): - logging.debug('getting pgid for process: ' + proc) - ERROR = 0 - - if pgid_list.has_key(proc) and os.path.exists('/proc/' + pgid_list[proc][0]): - return pgid_list[proc] - - val = PROCESSES[proc] - # Is this a pidfile? Last 4 chars are .pid - if '.pid' in val[-4:]: - if os.path.exists(val): - logging.debug(' pidfile found') - ppid = file(val, 'rt').readline().strip() - pgid = file('/proc/' + ppid + '/stat', 'rt').readline().split()[4] - else: - raise Exception('pidfile (' + val + ') does not exist') - - else: - # This is a regex, lets search for it - regex = PROCESSES[proc] - cmd = "ps -Ao pid,ppid,pgid,args | awk '" + regex + " && $2 == 1 && !/awk/ && !/procstat\.py/ {print $0}'" - p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - - if p.returncode: - raise Exception('failed executing ps\n' + cmd + '\n' + err) - - result = out.strip().split('\n') - logging.debug(' result: ' + str(result)) - - if len(result) > 1: - raise Exception('more than 1 result returned\n' + cmd + '\n' + out.strip()) - - if result[0] in '': - raise Exception('no process returned\n' + cmd) - - res = result[0].split() - ppid = res[0] - pgid = res[2] - - if os.path.exists('/proc/' + ppid): - logging.debug(' ppid: ' + ppid + ' pgid: ' + pgid) - return (ppid, pgid) - else: - return ERROR - -def get_pgroup(ppid, pgid): - '''Return a list of pids having the same pgid, with the first in the list being the parent pid.''' - logging.debug('getting pids for ppid/pgid: ' + ppid + '/' + pgid) - - try: - # Get all processes in this group - p_list = [] - for stat_file in glob.glob('/proc/[1-9]*/stat'): - stat = file(stat_file, 'rt').readline().split() - if stat[4] == pgid: - p_list.append(stat[0]) - - # place pid at the top of the list - p_list.remove(ppid) - p_list.insert(0, ppid) - - logging.debug('p_list: ' + str(p_list)) - - return p_list - - except: - logging.warning('failed getting pids') - -def get_rss(pids): - logging.debug('getting rss for pids') - - rss = 0 - for p in pids: - try: - statm = open('/proc/' + p + '/statm', 'rt').readline().split() - #logging.debug(' statm (' + p + '): ' + str(statm)) - except: - # Process finished, ignore this mem usage - logging.warning(' failed getting statm for pid: ' + p) - continue - - rss += int(statm[1]) - - rss *= PAGE_SIZE - return rss - -def test(params): - global PROCESSES, MAX_UPDATE_TIME - - MAX_UPDATE_TIME = 2 - - logging.debug('testing processes: ' + str(params)) - - PROCESSES = params - - for proc,val in PROCESSES.items(): - print('') - print(' Testing ' + proc + ': ' + val) - - try: - (ppid, pgid) = get_pgid(proc) - except Exception, e: - print(' failed getting pgid: ' + str(e)) - continue - - pids = get_pgroup(ppid, pgid) - - print(' Processes in this group: ') - print(' PID, ARGS') - for pid in pids: - # Read from binary file containing command line arguments - args = file('/proc/' + pid + '/cmdline', 'rt').readline().replace('\0', ' ') - print(' ' + pid + ' ' + args) - - logging.debug('success testing') - -def update_stats(): - logging.debug('updating stats') - global last_update, stats, last_val - - cur_time = time.time() - - if cur_time - last_update < MAX_UPDATE_TIME: - logging.debug(' wait ' + str(int(MAX_UPDATE_TIME - (cur_time - last_update))) + ' seconds') - return True - else: - last_update = cur_time - - for proc,val in PROCESSES.items(): - logging.debug(' updating for ' + proc) - - # setup storage lists - if not proc in stats: - stats[proc] = {} - if not proc in last_val: - last_val[proc] = {} - - ##### - # Update CPU utilization - try: - (ppid, pgid) = get_pgid(proc) - except Exception, e: - logging.warning(' failed getting pgid: ' + str(e)) - stats[proc]['cpu'] = 0.0 - stats[proc]['mem'] = 0 - continue - - # save for later - pgid_list[proc] = (ppid, pgid) - - pids = get_pgroup(ppid, pgid) - - cpu_time = time.time() - proc_time = 0 - for p in pids: - proc_time += readCpu(p) - - logging.debug(' proc_time: ' + str(proc_time) + ' cpu_time: ' + str(cpu_time)) - - # do we have an old value to calculate with? - if 'cpu_time' in last_val[proc]: - logging.debug(' last_val: ' + str(last_val[proc])) - logging.debug(' calc: 100 * ' + str(proc_time - last_val[proc]['proc_time']) + ' / ' + str(cpu_time - last_val[proc]['cpu_time']) + ' * ' + str(JIFFIES_PER_SEC)) - stats[proc]['cpu'] = 100 * (proc_time - last_val[proc]['proc_time']) / float((cpu_time - last_val[proc]['cpu_time']) * JIFFIES_PER_SEC) - - logging.debug(' calc: ' + str(stats[proc]['cpu'])) - else: - stats[proc]['cpu'] = 0.0 - - last_val[proc]['cpu_time'] = cpu_time - last_val[proc]['proc_time'] = proc_time - - ##### - # Update Mem utilization - rss = get_rss(pids) - stats[proc]['mem'] = rss - - logging.debug('success refreshing stats') - logging.debug('stats: ' + str(stats)) - - return True - -def get_stat(name): - logging.debug('getting stat: ' + name) - - ret = update_stats() - - if ret: - if name.startswith('procstat_'): - fir = name.find('_') - sec = name.find('_', fir + 1) - - proc = name[fir+1:sec] - label = name[sec+1:] - - try: - return stats[proc][label] - except: - logging.warning('failed to fetch [' + proc + '] ' + name) - return 0 - else: - label = name - - try: - return stats[label] - except: - logging.warning('failed to fetch ' + name) - return 0 - else: - return 0 - -def metric_init(params): - global descriptors - global PROCESSES - - logging.debug('init: ' + str(params)) - - PROCESSES = params - - #for proc,regex in PROCESSES.items(): - - update_stats() - - descriptions = dict( - cpu = { - 'units': 'percent', - 'value_type': 'float', - 'format': '%.1f', - 'description': 'The total percent CPU utilization'}, - - mem = { - 'units': 'B', - 'description': 'The total memory utilization'} - ) - - time_max = 60 - for label in descriptions: - for proc in PROCESSES: - if stats[proc].has_key(label): - - d = { - 'name': 'procstat_' + proc + '_' + label, - 'call_back': get_stat, - 'time_max': time_max, - 'value_type': 'uint', - 'units': '', - 'slope': 'both', - 'format': '%u', - 'description': label, - 'groups': 'procstat' - } - - # Apply metric customizations from descriptions - d.update(descriptions[label]) - - descriptors.append(d) - - else: - logging.error("skipped " + proc + '_' + label) - - #logging.debug('descriptors: ' + str(descriptors)) - - return descriptors - -def display_proc_stat(pid): - try: - stat = file('/proc/' + pid + '/stat', 'rt').readline().split() - - fields = [ - 'pid', 'comm', 'state', 'ppid', 'pgrp', 'session', - 'tty_nr', 'tty_pgrp', 'flags', 'min_flt', 'cmin_flt', 'maj_flt', - 'cmaj_flt', 'utime', 'stime', 'cutime', 'cstime', 'priority', - 'nice', 'num_threads', 'it_real_value', 'start_time', 'vsize', 'rss', - 'rlim', 'start_code', 'end_code', 'start_stack', 'esp', 'eip', - 'pending', 'blocked', 'sigign', 'sigcatch', 'wchan', 'nswap', - 'cnswap', 'exit_signal', 'processor', 'rt_priority', 'policy' - ] - - # Display them - i = 0 - for f in fields: - print '%15s: %s' % (f, stat[i]) - i += 1 - - except: - print('failed to get /proc/' + pid + '/stat') - print(traceback.print_exc(file=sys.stdout)) - -def display_proc_statm(pid): - try: - statm = file('/proc/' + pid + '/statm', 'rt').readline().split() - - fields = [ - 'size', 'rss', 'share', 'trs', 'drs', 'lrs' ,'dt' - ] - - # Display them - i = 0 - for f in fields: - print '%15s: %s' % (f, statm[i]) - i += 1 - - except: - print('failed to get /proc/' + pid + '/statm') - print(traceback.print_exc(file=sys.stdout)) - -def metric_cleanup(): - logging.shutdown() - # pass - -if __name__ == '__main__': - from optparse import OptionParser - import os - - logging.debug('running from cmd line') - parser = OptionParser() - parser.add_option('-p', '--processes', dest='processes', default='', help='processes to explicitly check') - parser.add_option('-v', '--value', dest='value', default='', help='regex or pidfile for each processes') - parser.add_option('-s', '--stat', dest='stat', default='', help='display the /proc/[pid]/stat file for this pid') - parser.add_option('-m', '--statm', dest='statm', default='', help='display the /proc/[pid]/statm file for this pid') - parser.add_option('-b', '--gmetric-bin', dest='gmetric_bin', default='/usr/bin/gmetric', help='path to gmetric binary') - parser.add_option('-c', '--gmond-conf', dest='gmond_conf', default='/etc/ganglia/gmond.conf', help='path to gmond.conf') - parser.add_option('-g', '--gmetric', dest='gmetric', action='store_true', default=False, help='submit via gmetric') - parser.add_option('-q', '--quiet', dest='quiet', action='store_true', default=False) - parser.add_option('-t', '--test', dest='test', action='store_true', default=False, help='test the regex list') - - (options, args) = parser.parse_args() - - if options.stat != '': - display_proc_stat(options.stat) - sys.exit(0) - elif options.statm != '': - display_proc_statm(options.statm) - sys.exit(0) - - _procs = options.processes.split(',') - _val = options.value.split(',') - params = {} - i = 0 - for proc in _procs: - params[proc] = _val[i] - i += 1 - - if options.test: - test(params) - update_stats() - - print('') - print(' waiting ' + str(MAX_UPDATE_TIME) + ' seconds') - time.sleep(MAX_UPDATE_TIME) - - metric_init(params) - - for d in descriptors: - v = d['call_back'](d['name']) - if not options.quiet: - print ' %s: %s %s [%s]' % (d['name'], d['format'] % v, d['units'], d['description']) - - if options.gmetric: - if d['value_type'] == 'uint': - value_type = 'uint32' - else: - value_type = d['value_type'] - - cmd = "%s --conf=%s --value='%s' --units='%s' --type='%s' --name='%s' --slope='%s'" % \ - (options.gmetric_bin, options.gmond_conf, v, d['units'], value_type, d['name'], d['slope']) - os.system(cmd) - - diff --git a/redis-gmond/conf.d/redis-gmond.pyconf b/redis-gmond/conf.d/redis-gmond.pyconf deleted file mode 100644 index 0c2bb7d5..00000000 --- a/redis-gmond/conf.d/redis-gmond.pyconf +++ /dev/null @@ -1,31 +0,0 @@ -modules { - module { - name = "redis-gmond" - language = "python" - param host { value = "127.0.0.1" } - param port { value = 6379 } - /* param auth { value = "passwordhere" } */ - } -} -collection_group { - collect_every = 10 - time_threshold = 60 - metric { name = "connected_clients" } - metric { name = "connected_slaves" } - metric { name = "blocked_clients" } - metric { name = "used_memory" } - metric { name = "rdb_changes_since_last_save" } - metric { name = "rdb_bgsave_in_progress" } - metric { name = "master_sync_in_progress" } - metric { name = "master_link_status" } - metric { name = "total_connections_received" } - metric { name = "instantaneous_ops_per_sec" } - metric { name = "total_commands_processed" } - metric { name = "expired_keys" } - metric { name = "pubsub_channels" } - metric { name = "pubsub_patterns" } - metric { name = "master_last_io_seconds_ago" } - metric { name = "db0" } -} - - diff --git a/redis-gmond/python_modules/redis-gmond.py b/redis-gmond/python_modules/redis-gmond.py deleted file mode 100644 index 76aaf8ad..00000000 --- a/redis-gmond/python_modules/redis-gmond.py +++ /dev/null @@ -1,120 +0,0 @@ -import socket -import time -#import logging - -#logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s\t Thread-%(thread)d - %(message)s", filename='/tmp/gmond.log', filemode='w') -#logging.debug('starting up') - -def metric_handler(name): - - # Update from Redis. Don't thrash. - if 15 < time.time() - metric_handler.timestamp: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((metric_handler.host, metric_handler.port)) - if metric_handler.auth is not None: - s.send("*2\r\n$4\r\nAUTH\r\n$%d\r\n%s\r\n" % (len(metric_handler.auth), metric_handler.auth)) - result = s.recv(100) - if not 'OK' in result: - return 0 - s.send("*1\r\n$4\r\nINFO\r\n") - #logging.debug("sent INFO") - info = s.recv(4096) - #logging.debug("rcvd INFO") - if "$" != info[0]: - return 0 - msglen = int(info[1:info.find("\n")]) - if 4096 < msglen: - info += s.recv(msglen - 4096) - metric_handler.info = {} - try: - for line in info.splitlines()[1:]: - #logging.debug("line is %s done" % line) - if "" == line: - continue - if "#" == line[0]: - continue - n, v = line.split(":") - if n in metric_handler.descriptors: - if n == "master_sync_status": - v = 1 if v == 'up' else 0 - if n == "db0": - v = v.split('=')[1].split(',')[0] - if n == "used_memory": - v = int(int(v) / 1000) - if n == "total_connections_received": - # first run, zero out and record total connections - if metric_handler.prev_total_connections == 0: - metric_handler.prev_total_connections = int(v) - v = 0 - else: - # calculate connections per second - cps = (int(v) - metric_handler.prev_total_connections) / (time.time() - metric_handler.timestamp) - metric_handler.prev_total_connections = int(v) - v = cps - if n == "total_commands_processed": - # first run, zero out and record total commands - if metric_handler.prev_total_commands == 0: - metric_handler.prev_total_commands = int(v) - v = 0 - else: - # calculate commands per second - cps = (int(v) - metric_handler.prev_total_commands) / (time.time() - metric_handler.timestamp) - metric_handler.prev_total_commands = int(v) - v = cps - #logging.debug("submittincg metric %s is %s" % (n, int(v))) - metric_handler.info[n] = int(v) # TODO Use value_type. - except Exception, e: - #logging.debug("caught exception %s" % e) - pass - s.close() - metric_handler.timestamp = time.time() - - #logging.debug("returning metric_handl: %s %s %s" % (metric_handler.info.get(name, 0), metric_handler.info, metric_handler)) - return metric_handler.info.get(name, 0) - -def metric_init(params={}): - metric_handler.host = params.get("host", "127.0.0.1") - metric_handler.port = int(params.get("port", 6379)) - metric_handler.auth = params.get("auth", None) - metric_handler.timestamp = 0 - metric_handler.prev_total_commands = 0 - metric_handler.prev_total_connections = 0 - metrics = { - "connected_clients": {"units": "clients"}, - "connected_slaves": {"units": "slaves"}, - "blocked_clients": {"units": "clients"}, - "used_memory": {"units": "KB"}, - "rdb_changes_since_last_save": {"units": "changes"}, - "rdb_bgsave_in_progress": {"units": "yes/no"}, - "master_sync_in_progress": {"units": "yes/no"}, - "master_link_status": {"units": "yes/no"}, - #"aof_bgrewriteaof_in_progress": {"units": "yes/no"}, - "total_connections_received": { "units": "connections/sec" }, - "instantaneous_ops_per_sec": {"units": "ops"}, - "total_commands_processed": { "units": "commands/sec" }, - "expired_keys": {"units": "keys"}, - "pubsub_channels": {"units": "channels"}, - "pubsub_patterns": {"units": "patterns"}, - #"vm_enabled": {"units": "yes/no"}, - "master_last_io_seconds_ago": {"units": "seconds ago"}, - "db0": {"units": "keys"}, - } - metric_handler.descriptors = {} - for name, updates in metrics.iteritems(): - descriptor = { - "name": name, - "call_back": metric_handler, - "time_max": 90, - "value_type": "int", - "units": "", - "slope": "both", - "format": "%d", - "description": "http://code.google.com/p/redis/wiki/InfoCommand", - "groups": "redis", - } - descriptor.update(updates) - metric_handler.descriptors[name] = descriptor - return metric_handler.descriptors.values() - -def metric_cleanup(): - pass diff --git a/riak/riak.conf b/riak/riak.conf deleted file mode 100644 index 844811f6..00000000 --- a/riak/riak.conf +++ /dev/null @@ -1,804 +0,0 @@ - modules { - - module { - - name = "riak" - language = "python" - param url { - - value = "http://localhost:8098/stats" - } - } -} - -collection_group { - - collect_every = 20 - time_threshold = 90 - - metric { - name = "riak_ignored_gossip_total" - title = "Total number of ignored gossip messages since node was started" - value_threshold = 0 -} - - metric { - name = "riak_mem_total" - title = "Total available system memory" - value_threshold = 0 -} - - metric { - name = "riak_memory_atom" - title = "Total amount of memory currently allocated for atom storage" - value_threshold = 0 -} - - metric { - name = "riak_memory_binary" - title = "Total amount of memory used for binaries" - value_threshold = 0 -} - - metric { - name = "riak_memory_code" - title = "Total amount of memory allocated for Erlang code" - value_threshold = 0 -} - - metric { - name = "riak_memory_processes" - title = "Total amount of memory allocated for Erlang processes" - value_threshold = 0 -} - - metric { - name = "riak_memory_processes_used" - title = "Total amount of memory used by Erlang processes" - value_threshold = 0 -} - - metric { - name = "riak_memory_system" - title = "Total allocated memory that is not directly related to an Erlang process" - value_threshold = 0 -} - - metric { - name = "riak_memory_total" - title = "Total allocated memory (sum of processes and system)" - value_threshold = 0 -} - - metric { - name = "riak_node_gets_total" - title = "Total number of GETs coordinated by this node, including GETs to non-local vnodes" - value_threshold = 0 -} - - metric { - name = "riak_node_puts_total" - title = "Total number of PUTs coordinated by this node, including PUTs to non-local vnodes" - value_threshold = 0 -} - - metric { - name = "riak_pbc_connects_total" - title = "Total number of Protocol Buffers connections made" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs_total" - title = "Total number of Read Repairs this node has coordinated" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodeq_total" - title = "Total queue size of all local Riak KV virtual nodes in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodeq_total" - title = "Total queue size of all local Riak Pipe virtual nodes in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodeq_max" - title = "Maximum number of unprocessed messages all virtual node (vnode) message queues in the Riak Search subsystem have received on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodeq_mean" - title = "Mean number of unprocessed messages all vnode message queues in the Riak Search subsystem have received on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodeq_median" - title = "Median number of unprocessed messages all vnode message queues in the Riak Search subsystem have received on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodeq_min" - title = "Minimum number of unprocessed messages all vnode message queues in the Riak Search subsystem have received on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodeq_total" - title = "Total number of unprocessed messages all vnode message queues in the Riak Search subsystem have received on this node since it was started" - value_threshold = 0 -} - - metric { - name = "riak_riak_search_vnodes_running" - title = "Total number of vnodes currently running in the Riak Search subsystem" - value_threshold = 0 -} - - metric { - name = "riak_rings_reconciled_total" - title = "Total rings_reconciled" - value_threshold = 0 -} - - metric { - name = "riak_sys_smp_support" - title = "Boolean value representing whether symmetric multi-processing (SMP) is available" - value_threshold = 0 -} - - metric { - name = "riak_sys_threads_enabled" - title = "Boolean value representing whether threads are enabled" - value_threshold = 0 -} - - metric { - name = "riak_vnode_gets_total" - title = "Total number of GETs coordinated by local vnodes" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_deletes_postings_total" - title = "Total number of individual secondary index values deleted" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_deletes_total" - title = "Total number of local replicas participating in secondary index deletes" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_reads_total" - title = "Total number of local replicas participating in secondary index reads" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_writes_postings_total" - title = "Total number of individual secondary index values written" - value_threshold = 0 -} - - metric { - name = "riak_vnode_puts_total" - title = "Total number of PUTS coordinated by local vnodes" - value_threshold = 0 -} - - metric { - name = "riak_converge_delay_last" - title = "Last observed histogram value in milliseconds describing time taken for the ring to converge after ring changes" - value_threshold = 0 -} - - metric { - name = "riak_converge_delay_max" - title = "Maximum time in milliseconds describing time taken for the ring to converge after ring changes" - value_threshold = 0 -} - - metric { - name = "riak_converge_delay_mean" - title = "Mean time in milliseconds describing time taken for the ring to converge after ring changes" - value_threshold = 0 -} - - metric { - name = "riak_converge_delay_min" - title = "Minimum time in milliseconds describing time taken for the ring to converge after ring changes" - value_threshold = 0 -} - - metric { - name = "riak_cpu_avg1" - title = "The average number of active processes for the last 1 minute (equivalent to top(1) command\u2019s load average when divided by 256())" - value_threshold = 0 -} - - metric { - name = "riak_cpu_avg15" - title = "The average number of active processes for the last 15 minutes (equivalent to top(1) command\u2019s load average when divided by 256())" - value_threshold = 0 -} - - metric { - name = "riak_cpu_avg5" - title = "The average number of active processes for the last 5 minutes (equivalent to top(1) command\u2019s load average when divided by 256())" - value_threshold = 0 -} - - metric { - name = "riak_cpu_nprocs" - title = "Number of operating system processes" - value_threshold = 0 -} - - metric { - name = "riak_executing_mappers" - title = "Mean for executing_mappers" - value_threshold = 0 -} - - metric { - name = "riak_gossip_received" - title = "Number of gossip messages received in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_handoff_timeouts" - title = "Total number of handoff timeouts encountered by this node since it was started" - value_threshold = 0 -} - - metric { - name = "riak_index_fsm_active" - title = "Number of active Secondary Index FSMs" - value_threshold = 0 -} - - metric { - name = "riak_index_fsm_create" - title = "Number of Secondary Index query FSMs created in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_index_fsm_create_error" - title = "Number of Secondary Index query FSM creation errors in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_list_fsm_active" - title = "Number of active Keylisting FSMs" - value_threshold = 0 -} - - metric { - name = "riak_list_fsm_create" - title = "Number of Keylisting FSMs created in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_list_fsm_create_error" - title = "Number of Keylisting FSM creation errors in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_mem_allocated" - title = "Total memory allocated for this node" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_active" - title = "Number of active GET FSMs" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_active_60s" - title = "Number of GET FSMs active in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_in_rate" - title = "Average number of GET FSMs enqueued by Sidejob" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_objsize_100" - title = "100th percentile object size encountered by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_objsize_95" - title = "95th percentile object size encountered by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_objsize_99" - title = "99th percentile object size encountered by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_objsize_mean" - title = "Mean object size encountered by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_objsize_median" - title = "Median object size encountered by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_out_rate" - title = "Average number of GET FSMs dequeued by Sidejob" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_rejected" - title = "Number of GET FSMs actively being rejected by Sidejob's overload protection" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_rejected_60s" - title = "Number of GET FSMs rejected by Sidejob's overload protection in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_siblings_100" - title = "100th percentile of siblings encountered during all GET operations by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_siblings_95" - title = "95th percentile of siblings encountered during all GET operations by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_siblings_99" - title = "99th percentile of siblings encountered during all GET operations by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_siblings_mean" - title = "Mean number of siblings encountered during all GET operations by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_siblings_median" - title = "Median number of siblings encountered during all GET operations by this node within the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_time_100" - title = "100th percentile time between reception of client GET request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_time_95" - title = "95th percentile time between reception of client GET request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_time_99" - title = "99th percentile time between reception of client GET request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_time_mean" - title = "Mean time between reception of client GET request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_get_fsm_time_median" - title = "Median time between reception of client GET request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_gets" - title = "Number of GETs coordinated by this node, including GETs to non-local vnodes in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_active" - title = "Number of active PUT FSMs" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_active_60s" - title = "Number of PUT FSMs active in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_in_rate" - title = "Average number of PUT FSMs enqueued by Sidejob" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_out_rate" - title = "Average number of PUT FSMs dequeued by Sidejob" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_rejected" - title = "Number of PUT FSMs actively being rejected by Sidejob's overload protection" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_rejected_60s" - title = "Number of PUT FSMs rejected by Sidejob's overload protection in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_time_100" - title = "100th percentile time between reception of client PUT request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_time_95" - title = "95th percentile time between reception of client PUT request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_time_99" - title = "99th percentile time between reception of client PUT request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_time_mean" - title = "Mean time between reception of client PUT request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_put_fsm_time_median" - title = "Median time between reception of client PUT request and subsequent response to client" - value_threshold = 0 -} - - metric { - name = "riak_node_puts" - title = "Number of PUTs coordinated by this node, where a PUT is sent to a local vnode in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_pbc_active" - title = "Number of active Protocol Buffers connections" - value_threshold = 0 -} - - metric { - name = "riak_pbc_connects" - title = "Number of Protocol Buffers connections made in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_pipeline_active" - title = "The number of pipelines active in the last 60 seconds" - value_threshold = 0 -} - - metric { - name = "riak_pipeline_create_count" - title = "The total number of pipelines created since the node was started" - value_threshold = 0 -} - - metric { - name = "riak_pipeline_create_error_count" - title = "The total number of pipeline creation errors since the node was started" - value_threshold = 0 -} - - metric { - name = "riak_pipeline_create_error_one" - title = "The number of pipeline creation errors in the last 60 seconds" - value_threshold = 0 -} - - metric { - name = "riak_pipeline_create_one" - title = "The number of pipelines created in the last 60 seconds" - value_threshold = 0 -} - - metric { - name = "riak_postcommit_fail" - title = "Total number of post-commit hook failures" - value_threshold = 0 -} - - metric { - name = "riak_precommit_fail" - title = "Total number of pre-commit hook failures" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs" - title = "Number of read repair operations this node has coordinated in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs_primary_notfound_count" - title = "Total number of read repair operations performed on primary vnodes due to missing replicas" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs_primary_notfound_one" - title = "Number of read repair operations performed on primary vnodes in the last minute due to missing replicas" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs_primary_outofdate_count" - title = "Total number of read repair operations performed on primary vnodes due to stale replicas" - value_threshold = 0 -} - - metric { - name = "riak_read_repairs_primary_outofdate_one" - title = "Number of read repair operations performed on primary vnodes in the last minute due to stale replicas" - value_threshold = 0 -} - - metric { - name = "riak_rebalance_delay_last" - title = "Mean for rebalance_delay_last" - value_threshold = 0 -} - - metric { - name = "riak_rebalance_delay_max" - title = "Mean for rebalance_delay_max" - value_threshold = 0 -} - - metric { - name = "riak_rebalance_delay_mean" - title = "Mean for rebalance_delay_mean" - value_threshold = 0 -} - - metric { - name = "riak_rebalance_delay_min" - title = "Mean for rebalance_delay_min" - value_threshold = 0 -} - - metric { - name = "riak_rejected_handoffs" - title = "Mean for rejected_handoffs" - value_threshold = 0 -} - - metric { - name = "riak_riak_core_stat_ts" - title = "Mean for riak_core_stat_ts" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_stat_ts" - title = "The last time Riak KV stats were generated." - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodeq_max" - title = "Mean for riak_kv_vnodeq_max" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodeq_mean" - title = "Mean for riak_kv_vnodeq_mean" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodeq_median" - title = "Mean for riak_kv_vnodeq_median" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodeq_min" - title = "Mean for riak_kv_vnodeq_min" - value_threshold = 0 -} - - metric { - name = "riak_riak_kv_vnodes_running" - title = "Mean for riak_kv_vnodes_running" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_stat_ts" - title = "The last time Riak Pipe stats were generated." - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodeq_max" - title = "Mean for riak_pipe_vnodeq_max" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodeq_mean" - title = "Mean for riak_pipe_vnodeq_mean" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodeq_median" - title = "Mean for riak_pipe_vnodeq_median" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodeq_min" - title = "Mean for riak_pipe_vnodeq_min" - value_threshold = 0 -} - - metric { - name = "riak_riak_pipe_vnodes_running" - title = "Mean for riak_pipe_vnodes_running" - value_threshold = 0 -} - - metric { - name = "riak_ring_creation_size" - title = "Ring size this cluster was created with" - value_threshold = 0 -} - - metric { - name = "riak_ring_num_partitions" - title = "The number of partitions in the ring" - value_threshold = 0 -} - - metric { - name = "riak_rings_reconciled" - title = "Mean for rings_reconciled" - value_threshold = 0 -} - - metric { - name = "riak_sys_global_heaps_size" - title = "Current size of the shared global heap" - value_threshold = 0 -} - - metric { - name = "riak_sys_logical_processors" - title = "Number of logical processors available on the system" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_deletes_postings" - title = "Number of individual secondary index values deleted in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_reads" - title = "Number of local replicas participating in secondary index reads in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_writes" - title = "Number of local replicas participating in secondary index writes in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_writes_postings" - title = "Number of individual secondary index values written in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_puts" - title = "Number of PUT operations coordinated by local vnodes on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_sys_process_count" - title = "Number of processes currently running in the Erlang VM" - value_threshold = 0 -} - - metric { - name = "riak_sys_thread_pool_size" - title = "Number of threads in the asynchronous thread pool" - value_threshold = 0 -} - - metric { - name = "riak_sys_wordsize" - title = "Size of Erlang term words in bytes as an integer, for examples, on 32-bit architectures 4 is returned and on 64-bit architectures 8 is returned" - value_threshold = 0 -} - - metric { - name = "riak_vnode_gets" - title = "Number of GET operations coordinated by local vnodes on this node in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_deletes" - title = "Number of local replicas participating in secondary index deletes in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_vnode_index_refreshes" - title = "Number of secondary indexes refreshed on this node during secondary index anti-entropy in the last minute" - value_threshold = 0 -} - - metric { - name = "riak_coord_redirs_total" - title = "Total number of requests this node has redirected to other nodes for coordination" - value_threshold = 0 -} -} diff --git a/riak/riak.py b/riak/riak.py deleted file mode 100644 index 22fbfc44..00000000 --- a/riak/riak.py +++ /dev/null @@ -1,1041 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -import threading -import time -import urllib2 -import traceback -import json - -descriptors = list() -Desc_Skel = {} -_Worker_Thread = None -_Lock = threading.Lock() # synchronization lock -Debug = False - -def dprint(f, *v): - if Debug: - print >>sys.stderr, "DEBUG: "+f % v - -def floatable(str): - try: - float(str) - return True - except: - return False - -class UpdateMetricThread(threading.Thread): - - def __init__(self, params): - threading.Thread.__init__(self) - self.running = False - self.shuttingdown = False - self.refresh_rate = 30 - if "refresh_rate" in params: - self.refresh_rate = int(params["refresh_rate"]) - self.metric = {} - self.timeout = 10 - - self.url = "http://localhost:8098/stats" - if "url" in params: - self.url = params["url"] - self.mp = params["metrix_prefix"] - - def shutdown(self): - self.shuttingdown = True - if not self.running: - return - self.join() - - def run(self): - self.running = True - - while not self.shuttingdown: - _Lock.acquire() - self.update_metric() - _Lock.release() - time.sleep(self.refresh_rate) - - self.running = False - - def update_metric(self): - try: - req = urllib2.Request(url = self.url) - res = urllib2.urlopen(req) - stats = res.read() - dprint("%s", stats) - json_stats = json.loads(stats) - for (key, value) in json_stats.iteritems(): - dprint("%s = %s", key, value) - if value == 'undefined': - self.metric[self.mp+'_'+key] = 0 - else: - self.metric[self.mp+'_'+key] = value - except urllib2.URLError: - traceback.print_exc() - else: - res.close() - - def metric_of(self, name): - val = 0 - mp = name.split("_")[0] - if name in self.metric: - _Lock.acquire() - val = self.metric[name] - _Lock.release() - return val - -def metric_init(params): - global descriptors, Desc_Skel, _Worker_Thread, Debug - - if "metrix_prefix" not in params: - params["metrix_prefix"] = "riak" - - print params - - # initialize skeleton of descriptors - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : metric_of, - 'time_max' : 60, - 'value_type' : 'uint', - 'format' : '%u', - 'units' : 'XXX', - 'slope' : 'XXX', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'riak', - } - - if "refresh_rate" not in params: - params["refresh_rate"] = 15 - if "debug" in params: - Debug = params["debug"] - dprint("%s", "Debug mode on") - - _Worker_Thread = UpdateMetricThread(params) - _Worker_Thread.start() - - # IP:HOSTNAME - if "spoof_host" in params: - Desc_Skel["spoof_host"] = params["spoof_host"] - - mp = params["metrix_prefix"] - - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_node_get_fsm_siblings_100", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_node_get_fsm_siblings_95", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_node_get_fsm_siblings_99", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_node_get_fsm_siblings_mean", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_node_get_fsm_siblings_median", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_executing_mappers", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_active", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_active_60s", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_in_rate", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_active_60s", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_in_rate", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_out_rate", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pipeline_active", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pipeline_create_count", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pipeline_create_error_count", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pipeline_create_error_one", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pipeline_create_one", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_index_fsm_active", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_index_fsm_create", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_index_fsm_create_error", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_list_fsm_active", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_list_fsm_create", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_list_fsm_create_error", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_out_rate", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_rejected", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_rejected_60s", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_siblings_100", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_active", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_rejected", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_rejected_60s", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_read_repairs_primary_notfound_count", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_read_repairs_primary_notfound_one", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_read_repairs_primary_outofdate_count", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_read_repairs_primary_outofdate_one", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rebalance_delay_mean", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rejected_handoffs", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_core_stat_ts", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_stat_ts", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_stat_ts", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_vnodeq_mean", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rings_reconciled", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_refreshes", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_puts", - "units": "puts", - "description": mp+"_node_puts" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_logical_processors", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_logical_processors" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_ignored_gossip_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_ignored_gossip_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_gets", - "units": "gets", - "description": mp+"_vnode_gets" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_objsize_100", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_objsize_100" - })) - descriptors.append(create_desc(Desc_Skel, { - "name" : mp+"_node_put_fsm_time_mean", - "units" : "microseconds", - "slope" : "both", - "description": mp+"_node_put_fsm_time_mean", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_node_puts_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_puts_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_vnodeq_mean", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodeq_mean" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_vnodes_running", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_pipe_vnodes_running" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_writes_postings", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_writes_postings" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_index_deletes_postings_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_deletes_postings_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_read_repairs_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_read_repairs_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_precommit_fail", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_precommit_fail" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rebalance_delay_max", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_rebalance_delay_max" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_converge_delay_mean", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_converge_delay_mean" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_time_95", - "units": "microseconds", - "description": mp+"_node_get_fsm_time_95" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_vnodeq_median", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_pipe_vnodeq_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_time_99", - "value_type": "uint", - "units": "microseconds", - "description": mp+"_node_get_fsm_time_99" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_code", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_code" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_smp_support", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_smp_support" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_processes_used", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_processes_used" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pbc_active", - "units": "connections", - "description": mp+"_pbc_active" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_index_writes_postings_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_writes_postings_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_gets_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_gets_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_process_count", - "units": "processes", - "description": "Erlang processes" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_read_repairs", - "units": "repairs", - "description": mp+"_read_repairs" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_puts", - "units": "puts", - "description": mp+"_vnode_puts" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_search_vnodes_running", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodes_running" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_vnodeq_min", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_pipe_vnodeq_min" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_objsize_mean", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_objsize_mean" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_cpu_nprocs", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_cpu_nprocs" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_time_100", - "units": "microseconds", - "description": mp+"_node_put_fsm_time_100" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_mem_total", - "format": "%.1f", - "value_type": "float", - "units": "bytes", - "description": mp+"_mem_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_search_vnodeq_mean", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodeq_mean" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_siblings_median", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_siblings_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_search_vnodeq_max", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodeq_max" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_threads_enabled", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_threads_enabled" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_writes", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_writes" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_memory_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_pipe_vnodeq_max", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_pipe_vnodeq_max" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_deletes_postings", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_deletes_postings" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_time_mean", - "units": "microseconds", - "description": "Mean for riak_kv_get_fsm calls" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_ring_num_partitions", - "units": "vnodes", - "description": mp+"_ring_num_partitions" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_search_vnodeq_min", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodeq_min" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_index_reads_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_reads_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_siblings_99", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_siblings_99" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_mem_allocated", - "format": "%.1f", - "value_type": "float", - "units": "bytes", - "description": mp+"_mem_allocated" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_siblings_95", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_siblings_95" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_objsize_95", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_objsize_95" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_time_median", - "units": "microseconds", - "description": mp+"_node_put_fsm_time_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_processes", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_processes" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_riak_search_vnodeq_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodeq_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_objsize_99", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_objsize_99" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_system", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_system" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_global_heaps_size", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_global_heaps_size" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_gossip_received", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_gossip_received" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_time_median", - "units": "microseconds", - "description": mp+"_node_get_fsm_time_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_index_deletes_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_deletes_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_vnodeq_max", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodeq_max" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_vnodeq_min", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodeq_min" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_gets", - "units": "gets", - "description": mp+"_node_gets" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_vnodeq_median", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodeq_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_postcommit_fail", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_postcommit_fail" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_search_vnodeq_median", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_search_vnodeq_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_wordsize", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_wordsize" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_riak_kv_vnodes_running", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodes_running" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_time_95", - "units": "microseconds", - "description": mp+"_node_put_fsm_time_95", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_rings_reconciled_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_rings_reconciled_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rebalance_delay_min", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_rebalance_delay_min" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_put_fsm_time_99", - "units": "microseconds", - "description": mp+"_node_put_fsm_time_99", - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_ring_creation_size", - "units": "vnodes", - "description": mp+"_ring_creation_size" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_cpu_avg1", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_cpu_avg1" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_cpu_avg5", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_cpu_avg5" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_pbc_connects_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_pbc_connects_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_binary", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_binary" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_coord_redirs_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_coord_redirs_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_riak_pipe_vnodeq_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_pipe_vnodeq_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_node_gets_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_gets_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_vnode_puts_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_puts_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_memory_atom", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_memory_atom" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_cpu_avg15", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_cpu_avg15" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_objsize_median", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_objsize_median" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_siblings_mean", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_node_get_fsm_siblings_mean" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_converge_delay_min", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_converge_delay_min" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_node_get_fsm_time_100", - "units": "microseconds", - "description": mp+"_node_get_fsm_time_100" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_converge_delay_max", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_converge_delay_max" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_converge_delay_last", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_converge_delay_last" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_rebalance_delay_last", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_rebalance_delay_last" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_deletes", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_deletes" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "positive", - "name": mp+"_riak_kv_vnodeq_total", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_riak_kv_vnodeq_total" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_handoff_timeouts", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_handoff_timeouts" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_vnode_index_reads", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_vnode_index_reads" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_sys_thread_pool_size", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_sys_thread_pool_size" - })) - descriptors.append(create_desc(Desc_Skel, { - "slope": "both", - "name": mp+"_pbc_connects", - "format": "%u", - "value_type": "uint", - "units": "N", - "description": mp+"_pbc_connects" - })) - - - return descriptors - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_of(name): - return _Worker_Thread.metric_of(name) - -def metric_cleanup(): - _Worker_Thread.shutdown() - -if __name__ == '__main__': - try: - params = { - "debug" : True, - } - metric_init(params) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print ('value for %s is '+d['format']) % (d['name'], v) - time.sleep(5) - except KeyboardInterrupt: - time.sleep(0.2) - os._exit(1) - except: - traceback.print_exc() - os._exit(1) diff --git a/ssl/entropy/conf.d/entropy.pyconf b/ssl/entropy/conf.d/entropy.pyconf deleted file mode 100644 index f9a56029..00000000 --- a/ssl/entropy/conf.d/entropy.pyconf +++ /dev/null @@ -1,17 +0,0 @@ -modules { - module { - name = "entropy" - language = "python" - } -} - -collection_group { - collect_every = 15 - time_threshold = 50 - - metric { - name = "entropy_avail" - title = "Entropy Available" - } - -} \ No newline at end of file diff --git a/ssl/entropy/python_modules/entropy.py b/ssl/entropy/python_modules/entropy.py deleted file mode 100644 index 414053fe..00000000 --- a/ssl/entropy/python_modules/entropy.py +++ /dev/null @@ -1,44 +0,0 @@ -import sys - - -entropy_file = "/proc/sys/kernel/random/entropy_avail" - -def metrics_handler(name): - try: - f = open(entropy_file, 'r') - - except IOError: - return 0 - - for l in f: - line = l - - return int(line) - -def metric_init(params): - global descriptors, node_id - - dict = {'name': 'entropy_avail', - 'call_back': metrics_handler, - 'time_max': 90, - 'value_type': 'uint', - 'units': 'bits', - 'slope': 'both', - 'format': '%u', - 'description': 'Entropy Available', - 'groups': 'ssl'} - - descriptors = [dict] - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -#This code is for debugging and unit testing -if __name__ == '__main__': - metric_init({}) - for d in descriptors: - v = d['call_back'](d['name']) - print 'value for %s is %u' % (d['name'], v) \ No newline at end of file diff --git a/system/cpu_stats/conf.d/cpu_stats.pyconf b/system/cpu_stats/conf.d/cpu_stats.pyconf deleted file mode 100644 index a59a2787..00000000 --- a/system/cpu_stats/conf.d/cpu_stats.pyconf +++ /dev/null @@ -1,35 +0,0 @@ -modules { - module { - name = "cpu_stats" - language = "python" - } -} - -collection_group { - collect_every = 10 - time_threshold = 45 - metric { - name = "procs_blocked" - title = "Processes blocked" - value_threshold = 0.0 - } - - metric { - name = "procs_created" - title = "Processes/Threads created" - value_threshold = 0.0 - } - - metric { - name_match = "softirq_(.+)" - value_threshold = 1.0 - } - - metric { - name_match = "cpu_(.+)" - value_threshold = 1.0 - } - - - -} diff --git a/system/cpu_stats/python_modules/cpu_stats.py b/system/cpu_stats/python_modules/cpu_stats.py deleted file mode 100644 index b34aa028..00000000 --- a/system/cpu_stats/python_modules/cpu_stats.py +++ /dev/null @@ -1,280 +0,0 @@ -import sys -import traceback -import os -import re -import time -import copy - -METRICS = { - 'time' : 0, - 'data' : {} -} - -# Got these from /proc/softirqs -softirq_pos = { - 'hi' : 1, - 'timer' : 2, - 'nettx' : 3, - 'netrx' : 4, - 'block' : 5, - 'blockiopoll' : 6, - 'tasklet' : 7, - 'sched' : 8, - 'hrtimer' : 9, - 'rcu' : 10 -} - -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - - - -stat_file = "/proc/stat" - -############################################################################### -# -############################################################################### -def get_metrics(): - """Return all metrics""" - - global METRICS, LAST_METRICS - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - try: - file = open(stat_file, 'r') - - except IOError: - return 0 - - # convert to dict - metrics = {} - for line in file: - parts = re.split("\s+", line) - metrics[parts[0]] = list(parts[1:]) - - # update cache - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': metrics - } - - return [METRICS, LAST_METRICS] - - -def get_value(name): - """Return a value for the requested metric""" - - metrics = get_metrics()[0] - - NAME_PREFIX="cpu_" - - name = name.replace(NAME_PREFIX,"") # remove prefix from name - - try: - result = metrics['data'][name][0] - except StandardError: - result = 0 - - return result - - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - NAME_PREFIX="cpu_" - - name = name.replace(NAME_PREFIX,"") # remove prefix from name - - if name == "procs_created": - name = "processes" - - try: - delta = (float(curr_metrics['data'][name][0]) - float(last_metrics['data'][name][0])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - -############################################################################## -# SoftIRQ has multiple values which are defined in a dictionary at the top -############################################################################## -def get_softirq_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - NAME_PREFIX="softirq_" - - name = name[len(NAME_PREFIX):] # remove prefix from name - - index = softirq_pos[name] - - try: - delta = (float(curr_metrics['data']['softirq'][index]) - float(last_metrics['data']['softirq'][index])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors, metric_map, Desc_Skel - - descriptors = [] - - Desc_Skel = { - 'name' : 'XXX', - 'orig_name' : 'XXX', - 'call_back' : get_delta, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.0f', - 'units' : 'XXX', - 'slope' : 'both', # zero|positive|negative|both - 'description' : '', - 'groups' : 'cpu', - } - - descriptors.append(create_desc(Desc_Skel, { - "name" : "cpu_ctxt", - "units" : "ctxs/sec", - "description": "Context Switches", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "procs_created", - "units" : "proc/sec", - "description": "Number of processes and threads created", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "cpu_intr", - "units" : "intr/sec", - "description": "Interrupts serviced", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "procs_blocked", - "units" : "processes", - "call_back" : get_value, - "description": "Processes blocked", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq", - "units" : "ops/s", - "description": "Soft IRQs", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_hi", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_timer", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_nettx", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_netrx", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_block", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_blockiopoll", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_tasklet", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_sched", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_hrtimer", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "softirq_rcu", - "units" : "ops/s", - 'groups' : 'softirq', - "call_back" : get_softirq_delta - })) - - - # We need a metric_map that maps metric_name to the index in /proc/meminfo - metric_map = {} - - for d in descriptors: - metric_name = d['name'] - metric_map[metric_name] = { "name": d['orig_name'], "units": d['units'] } - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -#This code is for debugging and unit testing -if __name__ == '__main__': - metric_init({}) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print '%s = %s' % (d['name'], v) - print 'Sleeping 15 seconds' - time.sleep(5) diff --git a/system/mem_stats/conf.d/mem_stats.pyconf b/system/mem_stats/conf.d/mem_stats.pyconf deleted file mode 100644 index 12f9483c..00000000 --- a/system/mem_stats/conf.d/mem_stats.pyconf +++ /dev/null @@ -1,40 +0,0 @@ -modules { - module { - name = "mem_stats" - language = "python" - } -} - -collection_group { - collect_every = 30 - time_threshold = 45 - metric { - name = "mem_writeback" - title = "Mem actively being written to disk" - value_threshold = 1.0 - } - metric { - name = "mem_dirty" - title = "Mem waiting to be written to disk" - value_threshold = 1.0 - } - - metric { - name = "mem_anonpages" - title = "AnonPages" - value_threshold = 1.0 - } - - metric { - name = "mem_mapped" - title = "Memory Mapped" - value_threshold = 1.0 - } - - metric { - name = "mem_hardware_corrupted" - title = "Memory HardwareCorrupted" - value_threshold = 1.0 - } - -} diff --git a/system/mem_stats/python_modules/mem_stats.py b/system/mem_stats/python_modules/mem_stats.py deleted file mode 100644 index eb30c41c..00000000 --- a/system/mem_stats/python_modules/mem_stats.py +++ /dev/null @@ -1,368 +0,0 @@ -import sys -import traceback -import os -import re - - -############################################################################### -# Explanation of metrics in /proc/meminfo can be found here -# -# http://www.redhat.com/advice/tips/meminfo.html -# and -# http://unixfoo.blogspot.com/2008/02/know-about-procmeminfo.html -# and -# http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-meminfo.html -############################################################################### - -meminfo_file = "/proc/meminfo" - -def metrics_handler(name): - try: - file = open(meminfo_file, 'r') - - except IOError: - return 0 - - value = 0 - for line in file: - parts = re.split("\s+", line) - if parts[0] == metric_map[name]['name'] + ":" : - # All of the measurements are in kBytes. We want to change them over - # to Bytes - if metric_map[name]['units'] == "Bytes": - value = float(parts[1]) * 1024 - else: - value = parts[1] - - return float(value) - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors, metric_map, Desc_Skel - - descriptors = [] - - Desc_Skel = { - 'name' : 'XXX', - 'orig_name' : 'XXX', - 'call_back' : metrics_handler, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.0f', - 'units' : 'XXX', - 'slope' : 'both', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'memory', - } - - descriptors.append( create_desc(Desc_Skel, { - "name" : "mem_total", - "orig_name" : "MemTotal", - "units" : "Bytes", - "description": "Total usable ram", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_free", - "orig_name" : "MemFree", - "units" : "Bytes", - "description": "The amount of physical RAM left unused by the system. ", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_buffers", - "orig_name" : "Buffers", - "units" : "Bytes", - "description": "Buffers used", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_cached", - "orig_name" : "Cached", - "units" : "Bytes", - "description": "Cached Memory", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_swap_cached", - "orig_name" : "SwapCached", - "units" : "Bytes", - "description": "Amount of Swap used as cache memory. Memory that once was swapped out, is swapped back in, but is still in the swapfile", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_active", - "orig_name" : "Active", - "units" : "Bytes", - "description": "Memory that has been used more recently and usually not reclaimed unless absolutely necessary.", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_inactive", - "orig_name" : "Inactive", - "units" : "Bytes", - "description": "The total amount of buffer or page cache memory that are free and available", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_total_anon", - "orig_name" : "Active(anon)", - "units" : "Bytes", - "description": "Active(anon)", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_inactive_anon", - "orig_name" : "Inactive(anon)", - "units" : "Bytes", - "description": "Inactive(anon)", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_active_file", - "orig_name" : "Active(file)", - "units" : "Bytes", - "description": "Active(file)", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_inactive_file", - "orig_name" : "Inactive(file)", - "units" : "Bytes", - "description": "Inactive(file)", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_unevictable", - "orig_name" : "Unevictable", - "units" : "Bytes", - "description": "Unevictable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_mlocked", - "orig_name" : "Mlocked", - "units" : "Bytes", - "description": "Mlocked", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_swap_total", - "orig_name" : "SwapTotal", - "units" : "Bytes", - "description": "Total amount of physical swap memory", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_swap_free", - "orig_name" : "SwapFree", - "units" : "Bytes", - "description": "Total amount of swap memory free", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_dirty", - "orig_name" : "Dirty", - "units" : "Bytes", - "description": "The total amount of memory waiting to be written back to the disk. ", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_writeback", - "orig_name" : "Writeback", - "units" : "Bytes", - "description": "The total amount of memory actively being written back to the disk.", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_anonpages", - "orig_name" : "AnonPages", - "units" : "Bytes", - "description": "AnonPages", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_mapped", - "orig_name" : "Mapped", - "units" : "Bytes", - "description": "Mapped", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_shmem", - "orig_name" : "Shmem", - "units" : "Bytes", - "description": "Shmem", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_slab", - "orig_name" : "Slab", - "units" : "Bytes", - "description": "Slab", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_s_reclaimable", - "orig_name" : "SReclaimable", - "units" : "Bytes", - "description": "SReclaimable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_s_unreclaimable", - "orig_name" : "SUnreclaim", - "units" : "Bytes", - "description": "SUnreclaim", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_kernel_stack", - "orig_name" : "KernelStack", - "units" : "Bytes", - "description": "KernelStack", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_page_tables", - "orig_name" : "PageTables", - "units" : "Bytes", - "description": "PageTables", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_nfs_unstable", - "orig_name" : "NFS_Unstable", - "units" : "Bytes", - "description": "NFS_Unstable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_bounce", - "orig_name" : "Bounce", - "units" : "Bytes", - "description": "Bounce", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_writeback_tmp", - "orig_name" : "WritebackTmp", - "units" : "Bytes", - "description": "WritebackTmp", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_commit_limit", - "orig_name" : "CommitLimit", - "units" : "Bytes", - "description": "CommitLimit", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_committed_as", - "orig_name" : "Committed_AS", - "units" : "Bytes", - "description": "Committed_AS", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_vmalloc_total", - "orig_name" : "VmallocTotal", - "units" : "Bytes", - "description": "VmallocTotal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_vmalloc_used", - "orig_name" : "VmallocUsed", - "units" : "Bytes", - "description": "VmallocUsed", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_vmalloc_chunk", - "orig_name" : "VmallocChunk", - "units" : "Bytes", - "description": "VmallocChunk", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hardware_corrupted", - "orig_name" : "HardwareCorrupted", - "units" : "Bytes", - "description": "HardwareCorrupted", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hugepages_total", - "orig_name" : "HugePages_Total", - "units" : "pages", - "description": "HugePages_Total", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hugepages_free", - "orig_name" : "HugePages_Free", - "units" : "pages", - "description": "HugePages_Free", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hugepage_rsvd", - "orig_name" : "HugePages_Rsvd", - "units" : "pages", - "description": "HugePages_Rsvd", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hugepages_surp", - "orig_name" : "HugePages_Surp", - "units" : "pages", - "description": "HugePages_Surp", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_hugepage_size", - "orig_name" : "Hugepagesize", - "units" : "Bytes", - "description": "Hugepagesize", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_directmap_4k", - "orig_name" : "DirectMap4k", - "units" : "Bytes", - "description": "DirectMap4k", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : "mem_directmap_2M", - "orig_name" : "DirectMap2M", - "units" : "Bytes", - "description": "DirectMap2M", - })) - - # We need a metric_map that maps metric_name to the index in /proc/meminfo - metric_map = {} - - for d in descriptors: - metric_name = d['name'] - metric_map[metric_name] = { "name": d['orig_name'], "units": d['units'] } - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -#This code is for debugging and unit testing -if __name__ == '__main__': - metric_init({}) - for d in descriptors: - v = d['call_back'](d['name']) - print 'value for %s is %f' % (d['name'], v) diff --git a/system/vm_stats/conf.d/vm_stats.basic.pyconf b/system/vm_stats/conf.d/vm_stats.basic.pyconf deleted file mode 100644 index 2ee248a2..00000000 --- a/system/vm_stats/conf.d/vm_stats.basic.pyconf +++ /dev/null @@ -1,38 +0,0 @@ -modules { - module { - name = "vm_stats" - language = "python" - } -} - -collection_group { - collect_every = 30 - time_threshold = 45 - - metric { - name = "vm_vmeff" - value_threshold = 1.0 - } - - metric { - name = "vm_pgmajfault" - value_threshold = 1.0 - } - - metric { - name = "vm_pgpgin" - value_threshold = 1.0 - } - - metric { - name = "vm_pgpgout" - value_threshold = 1.0 - } - - metric { - name = "vm_nr_written" - value_threshold = 1.0 - } - - -} diff --git a/system/vm_stats/python_modules/vm_stats.py b/system/vm_stats/python_modules/vm_stats.py deleted file mode 100644 index 3e0595b0..00000000 --- a/system/vm_stats/python_modules/vm_stats.py +++ /dev/null @@ -1,731 +0,0 @@ -import sys -import re -import time -import copy - -PARAMS = {} - -NAME_PREFIX = 'vm_' - -METRICS = { - 'time' : 0, - 'data' : {} -} -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - -############################################################################### -# Explanation of metrics in /proc/meminfo can be found here -# -# http://www.redhat.com/advice/tips/meminfo.html -# and -# http://unixfoo.blogspot.com/2008/02/know-about-procmeminfo.html -# and -# http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-meminfo.html -############################################################################### -vminfo_file = "/proc/vmstat" - - -def get_metrics(): - """Return all metrics""" - - global METRICS, LAST_METRICS - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - try: - file = open(vminfo_file, 'r') - - except IOError: - return 0 - - # convert to dict - metrics = {} - for line in file: - parts = re.split("\s+", line) - metrics[parts[0]] = parts[1] - - # update cache - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': metrics - } - - return [METRICS, LAST_METRICS] - -def get_value(name): - """Return a value for the requested metric""" - - metrics = get_metrics()[0] - - name = name[len(NAME_PREFIX):] # remove prefix from name - - try: - result = metrics['data'][name] - except StandardError: - result = 0 - - return result - - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - name = name[len(NAME_PREFIX):] # remove prefix from name - - try: - delta = (float(curr_metrics['data'][name]) - float(last_metrics['data'][name])) /(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - -# Calculate VM efficiency -# Works similar like sar -B 1 -# Calculated as pgsteal / pgscan, this is a metric of the efficiency of page reclaim. If it is near 100% then -# almost every page coming off the tail of the inactive list is being reaped. If it gets too low (e.g. less than 30%) -# then the virtual memory is having some difficulty. This field is displayed as zero if no pages have been -# scanned during the interval of time -def get_vmeff(name): - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - try: - pgscan_diff = float(curr_metrics['data']['pgscan_kswapd_normal']) - float(last_metrics['data']['pgscan_kswapd_normal']) - # To avoid division by 0 errors check whether pgscan is 0 - if pgscan_diff == 0: - return 0.0 - - delta = 100 * (float(curr_metrics['data']['pgsteal_normal']) - float(last_metrics['data']['pgsteal_normal'])) / pgscan_diff - if delta < 0: - print name + " is less 0" - delta = 0 - except KeyError: - delta = 0.0 - - return delta - - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - -def metric_init(params): - global descriptors, metric_map, Desc_Skel - - descriptors = [] - - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : get_value, - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%.4f', - 'units' : 'count', - 'slope' : 'both', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'memory_vm', - } - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_inactive_anon", - "description": "nr_inactive_anon", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_active_anon", - "description": "nr_active_anon", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_inactive_file", - "description": "nr_inactive_file", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_active_file", - "description": "nr_active_file", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_unevictable", - "description": "nr_unevictable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_mlock", - "description": "nr_mlock", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_anon_pages", - "description": "nr_anon_pages", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_mapped", - "description": "nr_mapped", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_file_pages", - "description": "nr_file_pages", - })) - - # - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_dirty", - "description": "nr_dirty", - })) - - # - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_writeback", - "description": "nr_writeback", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_slab_reclaimable", - "description": "nr_slab_reclaimable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_slab_unreclaimable", - "description": "nr_slab_unreclaimable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_page_table_pages", - "description": "nr_page_table_pages", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_kernel_stack", - "description": "nr_kernel_stack", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_unstable", - "description": "nr_unstable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_bounce", - "call_back" : get_delta, - "units" : "ops/s", - "description": "nr_bounce", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_vmscan_write", - "call_back" : get_delta, - "units" : "ops/s", - "description": "nr_vmscan_write", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_writeback_temp", - "units" : "ops/s", - "description": "nr_writeback_temp", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_isolated_anon", - "units" : "ops/s", - "description": "nr_isolated_anon", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_isolated_file", - "units" : "ops/s", - "description": "nr_isolated_file", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_shmem", - "units" : "ops/s", - "description": "nr_shmem", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_hit", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_hit", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_miss", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_miss", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_foreign", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_foreign", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_interleave", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_interleave", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_local", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_local", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "numa_other", - "call_back" : get_delta, - "units" : "ops/s", - "description": "numa_other", - })) - - # - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgpgin", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgpgin", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgpgout", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgpgout", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pswpin", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pswpin", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pswpout", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pswpout", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgalloc_dma", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgalloc_dma", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgalloc_dma32", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgalloc_dma32", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgalloc_normal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgalloc_normal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgalloc_movable", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgalloc_movable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgfree", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgfree", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgactivate", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgactivate", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgdeactivate", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgdeactivate", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgfault", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgfault", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgmajfault", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgmajfault", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgrefill_dma", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgrefill_dma", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgrefill_dma32", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgrefill_dma32", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgrefill_normal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgrefill_normal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgrefill_movable", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgrefill_movable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgsteal_dma", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgsteal_dma", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgsteal_dma32", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgsteal_dma32", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgsteal_normal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgsteal_normal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgsteal_movable", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgsteal_movable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_kswapd_dma", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_kswapd_dma", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_kswapd_dma32", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_kswapd_dma32", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_kswapd_normal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_kswapd_normal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_kswapd_movable", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_kswapd_movable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_direct_dma", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_direct_dma", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_direct_dma32", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_direct_dma32", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_direct_normal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_direct_normal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgscan_direct_movable", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgscan_direct_movable", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "zone_reclaim_failed", - "call_back" : get_delta, - "units" : "ops/s", - "description": "zone_reclaim_failed", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pginodesteal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pginodesteal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "slabs_scanned", - "call_back" : get_delta, - "units" : "ops/s", - "description": "slabs_scanned", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "kswapd_steal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "kswapd_steal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "kswapd_inodesteal", - "call_back" : get_delta, - "units" : "ops/s", - "description": "kswapd_inodesteal", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "kswapd_low_wmark_hit_quickly", - "call_back" : get_delta, - "units" : "ops/s", - "description": "kswapd_low_wmark_hit_quickly", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "kswapd_high_wmark_hit_quickly", - "call_back" : get_delta, - "units" : "ops/s", - "description": "kswapd_high_wmark_hit_quickly", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "kswapd_skip_congestion_wait", - "call_back" : get_delta, - "units" : "ops/s", - "description": "kswapd_skip_congestion_wait", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pageoutrun", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pageoutrun", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "allocstall", - "call_back" : get_delta, - "units" : "ops/s", - "description": "allocstall", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "pgrotated", - "call_back" : get_delta, - "units" : "ops/s", - "description": "pgrotated", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_culled", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_culled", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_scanned", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_scanned", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_rescued", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_rescued", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_mlocked", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_mlocked", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_munlocked", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_munlocked", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_cleared", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_cleared", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_stranded", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_stranded", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "unevictable_pgs_mlockfreed", - "call_back" : get_delta, - "units" : "ops/s", - "description": "unevictable_pgs_mlockfreed", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_dirtied", - "call_back" : get_delta, - "units" : "ops/s", - "description": "nr_dirtied", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_written", - "call_back" : get_delta, - "units" : "ops/s", - "description": "nr_written", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_anon_transparent_hugepages", - "description": "nr_anon_transparent_hugepages", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_dirty_threshold", - "description": "nr_dirty_threshold", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "nr_dirty_background_threshold", - "description": "nr_dirty_background_threshold", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_blocks_moved", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_blocks_moved", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_pages_moved", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_pages_moved", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_pagemigrate_failed", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_pagemigrate_failed", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_stall", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_stall", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_fail", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_fail", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "compact_success", - "call_back" : get_delta, - "units" : "ops/s", - "description": "compact_success", - })) - - descriptors.append(create_desc(Desc_Skel, { - "name" : NAME_PREFIX + "vmeff", - "description": "VM efficiency", - 'call_back' : get_vmeff, - 'units' : 'pct', - })) - - return descriptors - -def metric_cleanup(): - '''Clean up the metric module.''' - pass - -#This code is for debugging and unit testing -if __name__ == '__main__': - descriptors = metric_init(PARAMS) - while True: - for d in descriptors: - v = d['call_back'](d['name']) - print '%s = %s' % (d['name'], v) - print 'Sleeping 15 seconds' - time.sleep(15) diff --git a/varnish/conf.d/varnish.pyconf b/varnish/conf.d/varnish.pyconf deleted file mode 100644 index cac0ca35..00000000 --- a/varnish/conf.d/varnish.pyconf +++ /dev/null @@ -1,57 +0,0 @@ -modules { - module { - name = "varnish" - language = "python" - param stats_command { - value = "varnishstat -1" - } - } -} - -collection_group { - collect_every = 30 - time_threshold = 60 - -# If you want all of metrics kept track by varnishstat ie. all 100 of them -# you can simply uncomment line below and comment out all the other ones -# metric { -# name_match = "varnish_(.+)" -# } - - metric { - name = "varnish_client_req" - title = "Client Requests" - } - - metric { - name = "varnish_backend_req" - title = "Backend Requests" - } - metric { - name = "varnish_backend_unhealthy" - title = "Backend conn. not attempted" - } - metric { - name = "varnish_backend_busy" - title = "Backend conn. too many" - } - metric { - name = "varnish_cache_hit_ratio" - title = "Cache Hit Ratio" - } - metric { - name = "varnish_n_object" - title = "Objects in Cache" - } - metric { - name = "varnish_sm_balloc" - title = "Allocated Storage" - } - metric { - name = "varnish_n_wrk" - title = "Worker Threads" - } - - - -} diff --git a/varnish/python_modules/varnish.py b/varnish/python_modules/varnish.py deleted file mode 100755 index 02188ea5..00000000 --- a/varnish/python_modules/varnish.py +++ /dev/null @@ -1,1037 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Varnish gmond module for Ganglia -# -# Copyright (C) 2011 by Michael T. Conigliaro . -# All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -import os -import time -import copy - -NAME_PREFIX = 'varnish_' -PARAMS = { - 'stats_command' : 'varnishstat -1' -} -METRICS = { - 'time' : 0, - 'data' : {} -} -LAST_METRICS = copy.deepcopy(METRICS) -METRICS_CACHE_MAX = 5 - -def create_desc(skel, prop): - d = skel.copy() - for k,v in prop.iteritems(): - d[k] = v - return d - - -def get_metrics(): - """Return all metrics""" - - global METRICS, LAST_METRICS - - if (time.time() - METRICS['time']) > METRICS_CACHE_MAX: - - # get raw metric data - io = os.popen(PARAMS['stats_command']) - - # convert to dict - metrics = {} - for line in io.readlines(): - values = line.split()[:2] - try: - metrics[values[0]] = int(values[1]) - except ValueError: - metrics[values[0]] = 0 - - # update cache - LAST_METRICS = copy.deepcopy(METRICS) - METRICS = { - 'time': time.time(), - 'data': metrics - } - - return [METRICS, LAST_METRICS] - -def get_value(name): - """Return a value for the requested metric""" - - metrics = get_metrics()[0] - - name = name[len(NAME_PREFIX):] # remove prefix from name - try: - result = metrics['data'][name] - except StandardError: - result = 0 - - return result - - -def get_delta(name): - """Return change over time for the requested metric""" - - # get metrics - [curr_metrics, last_metrics] = get_metrics() - - # get delta - name = name[len(NAME_PREFIX):] # remove prefix from name - try: - delta = float(curr_metrics['data'][name] - last_metrics['data'][name])/(curr_metrics['time'] - last_metrics['time']) - if delta < 0: - print "Less than 0" - delta = 0 - except StandardError: - delta = 0 - - return delta - - -def get_cache_hit_ratio(name): - """Return cache hit ratio""" - - try: - result = get_delta(NAME_PREFIX + 'cache_hit') / get_delta(NAME_PREFIX + 'client_req') * 100 - except ZeroDivisionError: - result = 0 - - return result - - -def metric_init(lparams): - """Initialize metric descriptors""" - - global PARAMS, Desc_Skel - - # set parameters - for key in lparams: - PARAMS[key] = lparams[key] - - # define descriptors - time_max = 60 - - Desc_Skel = { - 'name' : 'XXX', - 'call_back' : 'XXX', - 'time_max' : 60, - 'value_type' : 'float', - 'format' : '%f', - 'units' : 'XXX', - 'slope' : 'both', # zero|positive|negative|both - 'description' : 'XXX', - 'groups' : 'varnish', - } - - descriptors = [] - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'cache_hit_ratio', - "call_back" : get_cache_hit_ratio, - "units" : "pct", - "description": "Cache Hit ratio", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'client_conn', - "call_back" : get_delta, - "units" : "conn/s", - "description": "Client connections accepted", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'client_drop', - "call_back" : get_delta, - "units" : "conn/s", - "description": "Connection dropped, no sess/wrk", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'client_req', - "call_back" : get_delta, - "units" : "req/s", - "description": "Client requests received", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'cache_hit', - "call_back" : get_delta, - "units" : "hit/s", - "description": "Cache hits", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'cache_hitpass', - "call_back" : get_delta, - "units" : "hit/s", - "description": "Cache hits for pass", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'cache_miss', - "units" : "miss/s", - "call_back" : get_delta, - "description": "Cache misses", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_conn', - "call_back" : get_delta, - "units" : "conn/s", - "description": "Backend conn. success", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_unhealthy', - "call_back" : get_delta, - "units" : "conn/s", - "description": "Backend conn. not attempted", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_busy', - "call_back" : get_delta, - "units" : "busy/s", - "description": "Backend conn. too many", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_fail', - "call_back" : get_delta, - "units" : "fail/s", - "description": "Backend conn. failures", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_reuse', - "call_back" : get_delta, - "units" : "/s", - "description": "Backend conn. reuses", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_toolate', - "call_back" : get_delta, - "units" : "/s", - "description": "Backend conn. was closed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_recycle', - "call_back" : get_delta, - "units" : "/s", - "description": "Backend conn. recycles", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_unused', - "call_back" : get_delta, - "units" : "/s", - "description": "Backend conn. unused", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_head', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch head", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_length', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch with Length", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_chunked', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch chunked", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_eof', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch EOF", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_bad', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch had bad headers", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_close', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch wanted close", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_oldhttp', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch pre HTTP/1.1 closed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_zero', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch zero len", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_failed', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch failed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_sess_mem', - "call_back" : get_value, - "units" : "Bytes", - "description": "N struct sess_mem", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_sess', - "call_back" : get_value, - "units" : "sessions", - "description": "N struct sess", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_object', - "call_back" : get_value, - "units" : "objects", - "description": "N struct object", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vampireobject', - "call_back" : get_value, - "units" : "objects", - "description": "N unresurrected objects", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_objectcore', - "call_back" : get_value, - "units" : "objects", - "description": "N struct objectcore", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_objecthead', - "call_back" : get_value, - "units" : "objects", - "description": "N struct objecthead", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_smf', - "call_back" : get_value, - "units" : "", - "description": "N struct smf", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_smf_frag', - "call_back" : get_value, - "units" : "frags", - "description": "N small free smf", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_smf_large', - "call_back" : get_value, - "units" : "frags", - "description": "N large free smf", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vbe_conn', - "call_back" : get_value, - "units" : "conn", - "description": "N struct vbe_conn", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk', - "call_back" : get_value, - "units" : "threads", - "description": "N worker threads", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_create', - "call_back" : get_delta, - "units" : "threads/s", - "description": "N worker threads created", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_failed', - "call_back" : get_delta, - "units" : "wrk/s", - "description": "N worker threads not created", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_max', - "call_back" : get_delta, - "units" : "threads/s", - "description": "N worker threads limited", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_queue', - "call_back" : get_value, - "units" : "req", - "description": "N queued work requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_overflow', - "call_back" : get_delta, - "units" : "req/s", - "description": "N overflowed work requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_drop', - "call_back" : get_delta, - "units" : "req/s", - "description": "N dropped work requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_backend', - "call_back" : get_value, - "units" : "backends", - "description": "N backends", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_expired', - "call_back" : get_delta, - "units" : "obj/s", - "description": "N expired objects", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_lru_nuked', - "call_back" : get_delta, - "units" : "obj/s", - "description": "N LRU nuked objects", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_lru_saved', - "call_back" : get_delta, - "units" : "obj/s", - "description": "N LRU saved objects", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_lru_moved', - "call_back" : get_delta, - "units" : "obj/s", - "description": "N LRU moved objects", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_deathrow', - "call_back" : get_delta, - "units" : "obj/s", - "description": "N objects on deathrow", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'losthdr', - "call_back" : get_delta, - "units" : "hdrs/s", - "description": "HTTP header overflows", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_objsendfile', - "call_back" : get_delta, - "units" : "obj/s", - "description": "Objects sent with sendfile", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_objwrite', - "call_back" : get_delta, - "units" : "obj/s", - "description": "Objects sent with write", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_objoverflow', - "call_back" : get_delta, - "description": "Objects overflowing workspace", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_sess', - "call_back" : get_delta, - "description": "Total Sessions", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_req', - "call_back" : get_delta, - "description": "Total Requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_pipe', - "call_back" : get_delta, - "description": "Total pipe", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_pass', - "call_back" : get_delta, - "description": "Total pass", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_fetch', - "call_back" : get_delta, - "description": "Total fetch", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_hdrbytes', - "call_back" : get_delta, - "description": "Total header bytes", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 's_bodybytes', - "call_back" : get_delta, - "units" : "bytes/s", - "description": "Total body bytes", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sess_closed', - "call_back" : get_delta, - "units" : "sessions/s", - "description": "Session Closed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sess_pipeline', - "call_back" : get_delta, - "description": "Session Pipeline", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sess_readahead', - "call_back" : get_delta, - "description": "Session Read Ahead", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sess_linger', - "call_back" : get_delta, - "description": "Session Linger", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sess_herd', - "call_back" : get_delta, - "description": "Session herd", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'shm_records', - "call_back" : get_delta, - "description": "SHM records", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'shm_writes', - "call_back" : get_delta, - "description": "SHM writes", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'shm_flushes', - "call_back" : get_delta, - "description": "SHM flushes due to overflow", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'shm_cont', - "call_back" : get_delta, - "description": "SHM MTX contention", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'shm_cycles', - "call_back" : get_delta, - "description": "SHM cycles through buffer", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sm_nreq', - "call_back" : get_delta, - "description": "allocator requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sm_nobj', - "call_back" : get_delta, - "description": "outstanding allocations", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sm_balloc', - "call_back" : get_value, - "description": "bytes allocated", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sm_bfree', - "call_back" : get_delta, - "description": "bytes free", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sma_nreq', - "call_back" : get_delta, - "description": "SMA allocator requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sma_nobj', - "call_back" : get_value, - "units" : "obj", - "description": "SMA outstanding allocations", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sma_nbytes', - "call_back" : get_value, - "units" : "Bytes", - "description": "SMA outstanding bytes", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sma_balloc', - "call_back" : get_delta, - "units" : "bytes/s", - "description": "SMA bytes allocated", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sma_bfree', - "call_back" : get_delta, - "units" : "bytes/s", - "description": "SMA bytes free", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sms_nreq', - "call_back" : get_delta, - "units" : "req/s", - "description": "SMS allocator requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sms_nobj', - "call_back" : get_value, - "units" : "obj", - "description": "SMS outstanding allocations", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sms_nbytes', - "call_back" : get_value, - "units" : "Bytes", - "description": "SMS outstanding bytes", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sms_balloc', - "call_back" : get_delta, - "units" : "bytes/s", - "description": "SMS bytes allocated", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'sms_bfree', - "call_back" : get_delta, - "units" : "Bytes/s", - "description": "SMS bytes freed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_req', - "call_back" : get_delta, - "units" : "req/s", - "description": "Backend requests made", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vcl', - "call_back" : get_value, - "units" : "vcl", - "description": "N vcl total", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vcl_avail', - "call_back" : get_value, - "units" : "vcl", - "description": "N vcl available", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vcl_discard', - "call_back" : get_value, - "units" : "vcl", - "description": "N vcl discarded", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge', - "call_back" : get_value, - "units" : "purges", - "description": "N total active purges", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge_add', - "call_back" : get_delta, - "units" : "purges/sec", - "description": "N new purges added", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge_retire', - "call_back" : get_delta, - "units" : "purges/s", - "description": "N old purges deleted", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge_obj_test', - "call_back" : get_delta, - "units" : "purges/s", - "description": "N objects tested", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge_re_test', - "call_back" : get_delta, - "description": "N regexps tested against", - "units" : "purges/s", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_purge_dups', - "call_back" : get_delta, - "units" : "purges/s", - "description": "N duplicate purges removed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'hcb_nolock', - "call_back" : get_delta, - "units" : "locks/s", - "description": "HCB Lookups without lock", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'hcb_lock', - "call_back" : get_delta, - "units" : "locks/s", - "description": "HCB Lookups with lock", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'hcb_insert', - "call_back" : get_delta, - "units" : "inserts/s", - "description": "HCB Inserts", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'esi_parse', - "call_back" : get_delta, - "units" : "obj/s", - "description": "Objects ESI parsed (unlock)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'esi_errors', - "call_back" : get_delta, - "units" : "err/s", - "description": "ESI parse errors (unlock)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'accept_fail', - "call_back" : get_delta, - "units" : "accepts/s", - "description": "Accept failures", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'client_drop_late', - "call_back" : get_delta, - "units" : "conn/s", - "description": "Connection dropped late", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'uptime', - "call_back" : get_value, - "units" : "seconds", - "description": "Client uptime", - })) - - ############################################################################## - - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'backend_retry', - "call_back" : get_delta, - "units" : "retries/s", - "description": "Backend conn. retry", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'dir_dns_cache_full', - "call_back" : get_delta, - "units" : "/s", - "description": "DNS director full dnscache", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'dir_dns_failed', - "call_back" : get_delta, - "units" : "/s", - "description": "DNS director failed lookups", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'dir_dns_hit', - "call_back" : get_delta, - "units" : "/s", - "description": "DNS director cached lookups hit", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'dir_dns_lookups', - "call_back" : get_delta, - "units" : "/s", - "description": "DNS director lookups", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'esi_warnings', - "call_back" : get_delta, - "units" : "/s", - "description": "ESI parse warnings (unlock)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_1xx', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch no body (1xx)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_204', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch no body (204)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'fetch_304', - "call_back" : get_delta, - "units" : "/s", - "description": "Fetch no body (304)", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban', - "call_back" : get_delta, - "units" : "/s", - "description": "N total active bans", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_add', - "call_back" : get_delta, - "units" : "/s", - "description": "N new bans added", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_retire', - "call_back" : get_delta, - "units" : "/s", - "description": "N old bans deleted", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_obj_test', - "call_back" : get_delta, - "units" : "/s", - "description": "N objects tested", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_re_test', - "call_back" : get_delta, - "units" : "/s", - "description": "N regexps tested against", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_dups', - "call_back" : get_delta, - "units" : "/s", - "description": "N duplicate bans removed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_add', - "call_back" : get_delta, - "units" : "/s", - "description": "N new bans added", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_dups', - "call_back" : get_delta, - "units" : "/s", - "description": "N duplicate bans removed", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_obj_test', - "call_back" : get_delta, - "units" : "/s", - "description": "N objects tested", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_re_test', - "call_back" : get_delta, - "units" : "/s", - "description": "N regexps tested against", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_ban_retire', - "call_back" : get_delta, - "units" : "/s", - "description": "N old bans deleted", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_gunzip', - "call_back" : get_delta, - "units" : "/s", - "description": "Gunzip operations", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_gzip', - "call_back" : get_delta, - "units" : "/s", - "description": "Gzip operations", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_vbc', - "call_back" : get_delta, - "units" : "/s", - "description": "N struct vbc", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_waitinglist', - "call_back" : get_delta, - "units" : "/s", - "description": "N struct waitinglist", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_lqueue', - "call_back" : get_value, - "units" : "", - "description": "work request queue length", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'n_wrk_queued', - "call_back" : get_value, - "units" : "req", - "description": "N queued work requests", - })) - - descriptors.append( create_desc(Desc_Skel, { - "name" : NAME_PREFIX + 'vmods', - "call_back" : get_value, - "units" : "vmods", - "description": "Loaded VMODs", - })) - - - - return descriptors - - -def metric_cleanup(): - """Cleanup""" - - pass - - -# the following code is for debugging and testing -if __name__ == '__main__': - descriptors = metric_init(PARAMS) - while True: - for d in descriptors: - print (('%s = %s') % (d['name'], d['format'])) % (d['call_back'](d['name'])) - print 'Sleeping 15 seconds' - time.sleep(15)