diamond-4.0.515/0000755000076500000240000000000013016133611013357 5ustar josestaff00000000000000diamond-4.0.515/.keep0000644000076500000240000000000012501431745014301 0ustar josestaff00000000000000diamond-4.0.515/bin/0000755000076500000240000000000013016133611014127 5ustar josestaff00000000000000diamond-4.0.515/bin/diamond0000755000076500000240000002474413015725651015515 0ustar josestaff00000000000000#!/usr/bin/env python # coding=utf-8 import os import sys import configobj if os.name != 'nt': import pwd import grp try: from setproctitle import setproctitle except ImportError: setproctitle = None for path in [ os.path.join('opt', 'diamond', 'lib'), os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')) ]: if os.path.exists(os.path.join(path, 'diamond', '__init__.py')): sys.path.append(path) break from diamond.server import Server from diamond.util import get_diamond_version from diamond.utils.log import setup_logging import multiprocessing import optparse import signal def main(): try: # Initialize Options defaults = { 'skip_pidfile': False, } if os.name == 'nt': defaults['skip_pidfile'] = True parser = optparse.OptionParser() parser.add_option("-c", "--configfile", dest="configfile", default="/etc/diamond/diamond.conf", help="config file") parser.add_option("-f", "--foreground", dest="foreground", default=False, action="store_true", help="run in foreground") parser.add_option("-l", "--log-stdout", dest="log_stdout", default=False, action="store_true", help="log to stdout") parser.add_option("-p", "--pidfile", dest="pidfile", default=None, help="pid file") parser.add_option("-r", "--run", dest="collector", default=None, help="run a given collector once and exit") parser.add_option("-v", "--version", dest="version", default=False, action="store_true", help="display the version and exit") parser.add_option("--skip-pidfile", dest="skip_pidfile", default=defaults['skip_pidfile'], action="store_true", help="Skip creating PID file") parser.add_option("-u", "--user", dest="user", default=None, help="Change to specified unprivilegd user") parser.add_option("-g", "--group", dest="group", default=None, help="Change to specified unprivilegd group") parser.add_option("--skip-change-user", dest="skip_change_user", default=False, action="store_true", help="Skip changing to an unprivilegd user") parser.add_option("--skip-fork", dest="skip_fork", default=False, action="store_true", help="Skip forking (damonizing) process") # Parse Command Line Args (options, args) = parser.parse_args() # Initial variables uid = -1 gid = -1 if options.version: print "Diamond version %s" % (get_diamond_version()) sys.exit(0) # Initialize Config options.configfile = os.path.abspath(options.configfile) if os.path.exists(options.configfile): config = configobj.ConfigObj(options.configfile) else: print >> sys.stderr, "ERROR: Config file: %s does not exist." % ( options.configfile) parser.print_help(sys.stderr) sys.exit(1) # Initialize Logging log = setup_logging(options.configfile, options.log_stdout) # Pass the exit up stream rather then handle it as an general exception except SystemExit, e: raise SystemExit except Exception, e: import traceback sys.stderr.write("Unhandled exception: %s" % str(e)) sys.stderr.write("traceback: %s" % traceback.format_exc()) sys.exit(1) # Switch to using the logging system try: # PID MANAGEMENT if not options.skip_pidfile: # Initialize Pid file if not options.pidfile: options.pidfile = str(config['server']['pid_file']) # Read existing pid file try: pf = file(options.pidfile, 'r') pid = int(pf.read().strip()) pf.close() except (IOError, ValueError): pid = None # Check existing pid file if pid: # Check if pid is real if not os.path.exists("/".join(["/proc", str(pid), "cmdline"])): # Pid is not real os.unlink(options.pidfile) pid = None print >> sys.stderr, ( "WARN: Bogus pid file was found. I deleted it.") else: print >> sys.stderr, ( "ERROR: Pidfile exists. Server already running?") sys.exit(1) # Get final GIDs if os.name != 'nt': if options.group is not None: gid = grp.getgrnam(options.group).gr_gid elif len(config['server']['group']): gid = grp.getgrnam(config['server']['group']).gr_gid # Get final UID if os.name != 'nt': if options.user is not None: uid = pwd.getpwnam(options.user).pw_uid elif len(config['server']['user']): uid = pwd.getpwnam(config['server']['user']).pw_uid # Fix up pid permissions if not options.foreground and not options.collector: # Write pid file pid = str(os.getpid()) try: pf = file(options.pidfile, 'w+') except IOError, e: print >> sys.stderr, "Failed to write PID file: %s" % (e) sys.exit(1) pf.write("%s\n" % pid) pf.close() os.chown(options.pidfile, uid, gid) # Log log.debug("Wrote First PID file: %s" % (options.pidfile)) # USER MANAGEMENT if not options.skip_change_user: # Switch user to specified user/group if required try: if gid != -1 and uid != -1: # Manually set the groups since they aren't set by default os.initgroups(pwd.getpwuid(uid).pw_name, gid) if gid != -1 and os.getgid() != gid: # Set GID os.setgid(gid) if uid != -1 and os.getuid() != uid: # Set UID os.setuid(uid) except Exception, e: print >> sys.stderr, "ERROR: Failed to set UID/GID. %s" % (e) sys.exit(1) # Log log.info('Changed UID: %d (%s) GID: %d (%s).' % ( os.getuid(), config['server']['user'], os.getgid(), config['server']['group'])) # DAEMONIZE MANAGEMENT if not options.skip_fork: # Detatch Process if not options.foreground and not options.collector: # Double fork to serverize process log.info('Detaching Process.') # Fork 1 try: pid = os.fork() if pid > 0: # Exit first paren sys.exit(0) except OSError, e: print >> sys.stderr, "Failed to fork process." % (e) sys.exit(1) # Decouple from parent environmen os.setsid() os.umask(0o022) # Fork 2 try: pid = os.fork() if pid > 0: # Exit second paren sys.exit(0) except OSError, e: print >> sys.stderr, "Failed to fork process." % (e) sys.exit(1) # Close file descriptors so that we can detach sys.stdout.close() sys.stderr.close() sys.stdin.close() os.close(0) os.close(1) os.close(2) sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w') # PID MANAGEMENT if not options.skip_pidfile: # Finish Initialize PID file if not options.foreground and not options.collector: # Write pid file pid = str(os.getpid()) try: pf = file(options.pidfile, 'w+') except IOError, e: log.error("Failed to write child PID file: %s" % (e)) sys.exit(1) pf.write("%s\n" % pid) pf.close() # Log log.debug("Wrote child PID file: %s" % (options.pidfile)) # Initialize Server server = Server(configfile=options.configfile) def sigint_handler(signum, frame): log.info("Signal Received: %d" % (signum)) # Delete Pidfile if not options.skip_pidfile and os.path.exists(options.pidfile): os.remove(options.pidfile) # Log log.debug("Removed PID file: %s" % (options.pidfile)) for child in multiprocessing.active_children(): child.terminate() sys.exit(0) # Set the signal handlers signal.signal(signal.SIGINT, sigint_handler) signal.signal(signal.SIGTERM, sigint_handler) server.run() # Pass the exit up stream rather then handle it as an general exception except SystemExit, e: raise SystemExit except Exception, e: import traceback log.error("Unhandled exception: %s" % str(e)) log.error("traceback: %s" % traceback.format_exc()) sys.exit(1) if __name__ == "__main__": if setproctitle: setproctitle(os.path.basename(__file__)) main() diamond-4.0.515/bin/diamond-setup0000755000076500000240000001764612621027505016651 0ustar josestaff00000000000000#!/usr/bin/env python ########################################################################## import os import sys import optparse import traceback from configobj import ConfigObj try: from setproctitle import setproctitle except ImportError: setproctitle = None for path in [ os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')), os.path.join('opt', 'diamond', 'lib'), ]: if os.path.exists(os.path.join(path, 'diamond', '__init__.py')): sys.path.append(path) break from diamond.collector import Collector from diamond.collector import str_to_bool def getIncludePaths(path): for f in os.listdir(path): cPath = os.path.abspath(os.path.join(path, f)) if os.path.isfile(cPath) and len(f) > 3 and f[-3:] == '.py': sys.path.append(os.path.dirname(cPath)) for f in os.listdir(path): cPath = os.path.abspath(os.path.join(path, f)) if os.path.isdir(cPath): getIncludePaths(cPath) collectors = {} def getCollectors(path): for f in os.listdir(path): cPath = os.path.abspath(os.path.join(path, f)) if (os.path.isfile(cPath) and len(f) > 3 and f[-3:] == '.py' and f[0:4] != 'test'): modname = f[:-3] try: # Import the module module = __import__(modname, globals(), locals(), ['*']) # Find the name for attr in dir(module): cls = getattr(module, attr) try: if (issubclass(cls, Collector) and cls.__name__ not in collectors): collectors[cls.__name__] = module break except TypeError: continue # print "Imported module: %s %s" % (modname, cls.__name__) except Exception: print "Failed to import module: %s. %s" % ( modname, traceback.format_exc()) collectors[modname] = False continue for f in os.listdir(path): cPath = os.path.abspath(os.path.join(path, f)) if os.path.isdir(cPath): getCollectors(cPath) def typeToString(key): if isinstance(obj.config[key], basestring): user_val = obj.config[key] elif isinstance(obj.config[key], bool): user_val = str(obj.config[key]) elif isinstance(obj.config[key], int): user_val = str(obj.config[key]) elif isinstance(obj.config[key], list): user_val = str(obj.config[key])[1:-1] else: raise NotImplementedError("Unknown type!") return user_val def stringToType(key, val): if type(obj.config[key]) is type(val): config_file[key] = val elif isinstance(obj.config[key], basestring): if val.lower() == 'false': config_file[key] = False elif val.lower() == 'true': config_file[key] = True else: config_file[key] = val elif isinstance(obj.config[key], bool): if isinstance(val, basestring): config_file[key] = str_to_bool(val) else: config_file[key] = bool(val) elif isinstance(obj.config[key], int): config_file[key] = int(val) elif isinstance(obj.config[key], list): entry = ConfigObj([key + ' = ' + val]) config_file[key] = entry[key] else: raise NotImplementedError("Unknown type!") def boolCheck(val): if isinstance(val, basestring): return str_to_bool(val) elif isinstance(val, bool): return val else: raise NotImplementedError("Unknown type!") def configureKey(key): if not config_keys[key]: return try: user_val = typeToString(key) except NotImplementedError: return print "\n" if key in default_conf_help: print default_conf_help[key] val = raw_input(key + ' [' + user_val + ']: ') # Empty user input? Default to current value if len(val) == 0: val = obj.config[key] try: stringToType(key, val) except NotImplementedError: return ########################################################################## if __name__ == "__main__": if setproctitle: setproctitle('diamond-setup') # Initialize Options parser = optparse.OptionParser() parser.add_option("-c", "--configfile", dest="configfile", default="/etc/diamond/diamond.conf", help="Path to the config file") parser.add_option("-C", "--collector", dest="collector", default=None, help="Configure a single collector") parser.add_option("-p", "--print", action="store_true", dest="dump", default=False, help="Just print the defaults") # Parse Command Line Args (options, args) = parser.parse_args() # Initialize Config if os.path.exists(options.configfile): config = ConfigObj(os.path.abspath(options.configfile)) else: print >> sys.stderr, "ERROR: Config file: %s does not exist." % ( options.configfile) print >> sys.stderr, ("Please run python config.py -c" + " /path/to/diamond.conf") parser.print_help(sys.stderr) sys.exit(1) if not options.dump: print '' print 'I will be over writing files in' print config['server']['collectors_config_path'] print 'Please type yes to continue' val = raw_input('Are you sure? ') if val != 'yes': sys.exit() getIncludePaths(config['server']['collectors_path']) getCollectors(config['server']['collectors_path']) tests = [] foundcollector = False for collector in collectors: if options.collector and collector != options.collector: continue # Skip configuring the basic collector object if collector == "Collector": continue foundcollector = True config_keys = {} config_file = ConfigObj() config_file.filename = (config['server']['collectors_config_path'] + "/" + collector + ".conf") # Find the class and load it from the collector module try: # We can for the name above, so we dont have to scan here anymore if not hasattr(collectors[collector], collector): continue cls = getattr(collectors[collector], collector) obj = cls(config=config, handlers={}) if options.dump: print collector + " " + str(obj.config) continue default_conf = obj.get_default_config() default_conf_help = obj.get_default_config_help() for key in obj.get_default_config(): config_keys[key] = True # Manage Keys config_keys['enabled'] = True config_keys['path'] = False config_keys['path_prefix'] = False config_keys['instance_prefix'] = False config_keys['interval'] = False print "*" * 60 print "\n\t\tNow configuring " + collector print collectors[collector].__doc__ print "(%s)" % collector configureKey('enabled') if boolCheck(config_file['enabled']): for key in config_keys: if key == 'enabled': continue configureKey(key) config_file.write() except IOError, (errno, strerror): print "I/O error({0}): {1}".format(errno, strerror) except KeyboardInterrupt: print sys.exit() except: continue if not foundcollector: print "Collector not found." diamond-4.0.515/bin/init.d/0000755000076500000240000000000013016133611015314 5ustar josestaff00000000000000diamond-4.0.515/bin/init.d/diamond0000755000076500000240000000377112501431745016674 0ustar josestaff00000000000000#!/bin/sh # # diamond Start the diamond statistics collector # # chkconfig: 2345 25 75 # description: Diamond is a daemon and toolset for gathering system statistics \ # and publishing them to Graphite. # processname: python # config: /etc/diamond/diamond.conf # pidfile: /var/run/diamond.pid ### BEGIN INIT INFO # Provides: diamond # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: System statistics collector for Graphite. # Description: Diamond is a daemon and toolset for gathering system statistics # and publishing them to Graphite. ### END INIT INFO # Author: Sam Bashton NAME=diamond DAEMON=/usr/bin/diamond DAEMON_ARGS="-p /var/run/diamond.pid" PIDFILE=/var/run/diamond.pid SCRIPTNAME=/etc/init.d/diamond LOCKDIR=/var/lock/subsys LOCKFILE=/var/lock/subsys/diamond . /etc/rc.d/init.d/functions start() { if [ -d "${LOCKDIR}" -a -w "${LOCKDIR}" ] then local pid __pids_var_run $NAME || rm -f "${LOCKFILE}" if ( set -o noclobber; echo "$$" > "${LOCKFILE}") 2> /dev/null; then true else echo "Failed to acquire lockfile: ${LOCKFILE}." echo "Held by $(cat ${LOCKFILE})" echo_failure return 1 fi fi echo -n $"Starting $NAME: " daemon --pidfile $PIDFILE $DAEMON $DAEMON_ARGS retval=$? if [ $retval -eq 0 ]; then echo_success echo else echo_failure echo fi return $retval } stop() { echo -n $"Stopping $NAME: " killproc -p $PIDFILE $NAME retval=$? if [ $retval -ne 0 ]; then killall -q diamond fi if [ -e "${LOCKFILE}" ] then rm -f "${LOCKFILE}" fi echo return $retval } restart() { stop start } case "$1" in start) start ;; stop) stop ;; status) status -p $PIDFILE $NAME ;; restart) restart ;; *) echo "Usage: $0 {start|stop|status}" exit 2 ;; esac exit $? diamond-4.0.515/conf/0000755000076500000240000000000013016133611014304 5ustar josestaff00000000000000diamond-4.0.515/conf/diamond.conf.example0000644000076500000240000001406213015725651020235 0ustar josestaff00000000000000################################################################################ # Diamond Configuration File ################################################################################ ################################################################################ ### Options for the server [server] # Handlers for published metrics. handlers = diamond.handler.graphite.GraphiteHandler, diamond.handler.archive.ArchiveHandler # User diamond will run as # Leave empty to use the current user user = # Group diamond will run as # Leave empty to use the current group group = # Pid file pid_file = /var/run/diamond.pid # Directory to load collector modules from collectors_path = /usr/share/diamond/collectors/ # Directory to load collector configs from collectors_config_path = /etc/diamond/collectors/ # Number of seconds between each collector load # collectors_load_delay = 1.0 # Directory to load handler configs from handlers_config_path = /etc/diamond/handlers/ # Directory to load handler modules from handlers_path = /usr/share/diamond/handlers/ # Maximum number of metrics waiting to be processed by handlers. # When metric queue is full, new metrics are dropped. metric_queue_size = 16384 ################################################################################ ### Options for handlers [handlers] # daemon logging handler(s) keys = rotated_file ### Defaults options for all Handlers [[default]] [[ArchiveHandler]] # File to write archive log files log_file = /var/log/diamond/archive.log # Number of days to keep archive log files days = 7 [[GraphiteHandler]] ### Options for GraphiteHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2003 # Socket timeout (seconds) timeout = 15 # Batch size for metrics batch = 1 [[GraphitePickleHandler]] ### Options for GraphitePickleHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2004 # Socket timeout (seconds) timeout = 15 # Batch size for pickled metrics batch = 256 [[MySQLHandler]] ### Options for MySQLHandler # MySQL Connection Info hostname = 127.0.0.1 port = 3306 username = root password = database = diamond table = metrics # INT UNSIGNED NOT NULL col_time = timestamp # VARCHAR(255) NOT NULL col_metric = metric # VARCHAR(255) NOT NULL col_value = value [[StatsdHandler]] host = 127.0.0.1 port = 8125 [[TSDBHandler]] host = 127.0.0.1 port = 4242 timeout = 15 [[LibratoHandler]] user = user@example.com apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 [[HostedGraphiteHandler]] apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 timeout = 15 batch = 1 [[SignalfxHandler]] auth_token = abcdefghijklmnopqrstuvwxyz # And any other config settings from GraphiteHandler are valid here [[HttpPostHandler]] ### Urp to post the metrics url = http://localhost:8888/ ### Metrics batch size batch = 100 ################################################################################ ### Options for collectors [collectors] [[default]] ### Defaults options for all Collectors # Uncomment and set to hardcode a hostname for the collector path # Keep in mind, periods are seperators in graphite # hostname = my_custom_hostname # If you prefer to just use a different way of calculating the hostname # Uncomment and set this to one of these values: # smart = Default. Tries fqdn_short. If that's localhost, uses hostname_short # fqdn_short = Default. Similar to hostname -s # fqdn = hostname output # fqdn_rev = hostname in reverse (com.example.www) # uname_short = Similar to uname -n, but only the first part # uname_rev = uname -r in reverse (com.example.www) # hostname_short = `hostname -s` # hostname = `hostname` # hostname_rev = `hostname` in reverse (com.example.www) # shell = Run the string set in hostname as a shell command and use its # output(with spaces trimmed off from both ends) as the hostname. # hostname_method = smart # Path Prefix and Suffix # you can use one or both to craft the path where you want to put metrics # such as: %(path_prefix)s.$(hostname)s.$(path_suffix)s.$(metric)s # path_prefix = servers # path_suffix = # Path Prefix for Virtual Machines # If the host supports virtual machines, collectors may report per # VM metrics. Following OpenStack nomenclature, the prefix for # reporting per VM metrics is "instances", and metric foo for VM # bar will be reported as: instances.bar.foo... # instance_prefix = instances # Default Poll Interval (seconds) # interval = 300 ################################################################################ # Default enabled collectors ################################################################################ [[CPUCollector]] enabled = True [[DiskSpaceCollector]] enabled = True [[DiskUsageCollector]] enabled = True [[LoadAverageCollector]] enabled = True [[MemoryCollector]] enabled = True [[VMStatCollector]] enabled = True ################################################################################ ### Options for logging # for more information on file format syntax: # http://docs.python.org/library/logging.config.html#configuration-file-format [loggers] keys = root # handlers are higher in this config file, in: # [handlers] # keys = ... [formatters] keys = default [logger_root] # to increase verbosity, set DEBUG level = INFO handlers = rotated_file propagate = 1 [handler_rotated_file] class = handlers.TimedRotatingFileHandler level = DEBUG formatter = default # rotate at midnight, each day and keep 7 days args = ('/var/log/diamond/diamond.log', 'midnight', 1, 7) [formatter_default] format = [%(asctime)s] [%(threadName)s] %(message)s datefmt = ################################################################################ ### Options for config merging # [configs] # path = "/etc/diamond/configs/" # extension = ".conf" #------------------------------------------------------------------------------- # Example: # /etc/diamond/configs/net.conf # [collectors] # # [[NetworkCollector]] # enabled = True diamond-4.0.515/conf/diamond.conf.example.windows0000644000076500000240000001235312606264167021734 0ustar josestaff00000000000000################################################################################ # Diamond Configuration File ################################################################################ ################################################################################ ### Options for the server [server] # Handlers for published metrics. handlers = diamond.handler.graphite.GraphiteHandler, diamond.handler.archive.ArchiveHandler # User diamond will run as # Leave empty to use the current user user = # Group diamond will run as # Leave empty to use the current group group = # Pid file pid_file = /var/run/diamond.pid # Directory to load collector modules from collectors_path = C:\\Program Files\\diamond\\collectors # Directory to load collector configs from collectors_config_path = C:\\Program Files\\diamond\\conf\\collectors # Number of seconds between each collector load # collectors_load_delay = 1.0 # Directory to load handler configs from handlers_config_path = C:\\Program Files\\diamond\\conf\\handlers # Directory to load handler modules from handlers_path = C:\\Program Files\\diamond\\handlers ################################################################################ ### Options for handlers [handlers] # daemon logging handler(s) keys = rotated_file ### Defaults options for all Handlers [[default]] enabled = False [[ArchiveHandler]] # File to write archive log files log_file = C:\\Program Files\\diamond\\archive.log # Number of days to keep archive log files days = 7 [[GraphiteHandler]] ### Options for GraphiteHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2003 # Socket timeout (seconds) timeout = 15 # Batch size for metrics batch = 1 [[GraphitePickleHandler]] ### Options for GraphitePickleHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2004 # Socket timeout (seconds) timeout = 15 # Batch size for pickled metrics batch = 256 [[MySQLHandler]] ### Options for MySQLHandler # MySQL Connection Info hostname = 127.0.0.1 port = 3306 username = root password = database = diamond table = metrics # INT UNSIGNED NOT NULL col_time = timestamp # VARCHAR(255) NOT NULL col_metric = metric # VARCHAR(255) NOT NULL col_value = value [[StatsdHandler]] host = 127.0.0.1 port = 8125 [[TSDBHandler]] host = 127.0.0.1 port = 4242 timeout = 15 [[LibratoHandler]] user = user@example.com apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 [[HttpPostHandler]] ### Urp to post the metrics url = http://localhost:8888/ ### Metrics batch size batch = 100 ################################################################################ ### Options for collectors [collectors] [[default]] ### Defaults options for all Collectors # Uncomment and set to hardcode a hostname for the collector path # Keep in mind, periods are seperators in graphite # hostname = my_custom_hostname # If you prefer to just use a different way of calculating the hostname # Uncomment and set this to one of these values: # smart = Default. Tries fqdn_short. If that's localhost, uses hostname_short # fqdn_short = Default. Similar to hostname -s # fqdn = hostname output # fqdn_rev = hostname in reverse (com.example.www) # uname_short = Similar to uname -n, but only the first part # uname_rev = uname -r in reverse (com.example.www) # hostname_short = `hostname -s` # hostname = `hostname` # hostname_rev = `hostname` in reverse (com.example.www) # hostname_method = smart # Path Prefix and Suffix # you can use one or both to craft the path where you want to put metrics # such as: %(path_prefix)s.$(hostname)s.$(path_suffix)s.$(metric)s # path_prefix = servers # path_suffix = # Path Prefix for Virtual Machines # If the host supports virtual machines, collectors may report per # VM metrics. Following OpenStack nomenclature, the prefix for # reporting per VM metrics is "instances", and metric foo for VM # bar will be reported as: instances.bar.foo... # instance_prefix = instances # Default Poll Interval (seconds) # interval = 300 ################################################################################ # Default enabled collectors ################################################################################ [[CPUCollector]] enabled = True [[DiskSpaceCollector]] enabled = True [[DiskUsageCollector]] enabled = True [[LoadAverageCollector]] enabled = True [[MemoryCollector]] enabled = True [[VMStatCollector]] enabled = True ################################################################################ ### Options for logging # for more information on file format syntax: # http://docs.python.org/library/logging.config.html#configuration-file-format [loggers] keys = root # handlers are higher in this config file, in: # [handlers] # keys = ... [formatters] keys = default [logger_root] # to increase verbosity, set DEBUG level = INFO handlers = rotated_file propagate = 1 [handler_rotated_file] class = handlers.TimedRotatingFileHandler level = DEBUG formatter = default # rotate at midnight, each day and keep 7 days args = ('C:\\Program Files\\diamond\\diamond.log', 'midnight', 1, 7) [formatter_default] format = [%(asctime)s] [%(threadName)s] %(message)s datefmt = diamond-4.0.515/conf/vagrant/0000755000076500000240000000000013016133611015746 5ustar josestaff00000000000000diamond-4.0.515/conf/vagrant/collectors/0000755000076500000240000000000013016133611020117 5ustar josestaff00000000000000diamond-4.0.515/conf/vagrant/collectors/RedisCollector.conf0000644000076500000240000000004613015725651023715 0ustar josestaff00000000000000enabled=true instances=localhost:6379 diamond-4.0.515/conf/vagrant/diamond.conf0000644000076500000240000001413613015725651020247 0ustar josestaff00000000000000################################################################################ # Diamond Configuration File ################################################################################ ################################################################################ ### Options for the server [server] # Handlers for published metrics. #handlers = diamond.handler.graphite.GraphiteHandler, diamond.handler.archive.ArchiveHandler handlers = diamond.handler.archive.ArchiveHandler # User diamond will run as # Leave empty to use the current user user = # Group diamond will run as # Leave empty to use the current group group = # Pid file pid_file = /var/run/diamond.pid # Directory to load collector modules from collectors_path = /vagrant/src/collectors/ # Directory to load collector configs from collectors_config_path = /etc/diamond/collectors/ # Number of seconds between each collector load # collectors_load_delay = 1.0 # Directory to load handler configs from handlers_config_path = /etc/diamond/handlers/ # Directory to load handler modules from handlers_path = /vagrant/src/diamond/handler/ # Maximum number of metrics waiting to be processed by handlers. # When metric queue is full, new metrics are dropped. metric_queue_size = 16384 ################################################################################ ### Options for handlers [handlers] # daemon logging handler(s) keys = rotated_file ### Defaults options for all Handlers [[default]] [[ArchiveHandler]] # File to write archive log files log_file = /var/log/diamond/archive.log # Number of days to keep archive log files days = 1 [[GraphiteHandler]] ### Options for GraphiteHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2003 # Socket timeout (seconds) timeout = 15 # Batch size for metrics batch = 1 [[GraphitePickleHandler]] ### Options for GraphitePickleHandler # Graphite server host host = 127.0.0.1 # Port to send metrics to port = 2004 # Socket timeout (seconds) timeout = 15 # Batch size for pickled metrics batch = 256 [[MySQLHandler]] ### Options for MySQLHandler # MySQL Connection Info hostname = 127.0.0.1 port = 3306 username = root password = database = diamond table = metrics # INT UNSIGNED NOT NULL col_time = timestamp # VARCHAR(255) NOT NULL col_metric = metric # VARCHAR(255) NOT NULL col_value = value [[StatsdHandler]] host = 127.0.0.1 port = 8125 [[TSDBHandler]] host = 127.0.0.1 port = 4242 timeout = 15 [[LibratoHandler]] user = user@example.com apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 [[HostedGraphiteHandler]] apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 timeout = 15 batch = 1 [[SignalfxHandler]] auth_token = abcdefghijklmnopqrstuvwxyz # And any other config settings from GraphiteHandler are valid here [[HttpPostHandler]] ### Urp to post the metrics url = http://localhost:8888/ ### Metrics batch size batch = 100 ################################################################################ ### Options for collectors [collectors] [[default]] ### Defaults options for all Collectors # Uncomment and set to hardcode a hostname for the collector path # Keep in mind, periods are seperators in graphite # hostname = my_custom_hostname # If you prefer to just use a different way of calculating the hostname # Uncomment and set this to one of these values: # smart = Default. Tries fqdn_short. If that's localhost, uses hostname_short # fqdn_short = Default. Similar to hostname -s # fqdn = hostname output # fqdn_rev = hostname in reverse (com.example.www) # uname_short = Similar to uname -n, but only the first part # uname_rev = uname -r in reverse (com.example.www) # hostname_short = `hostname -s` # hostname = `hostname` # hostname_rev = `hostname` in reverse (com.example.www) # shell = Run the string set in hostname as a shell command and use its # output(with spaces trimmed off from both ends) as the hostname. # hostname_method = smart # Path Prefix and Suffix # you can use one or both to craft the path where you want to put metrics # such as: %(path_prefix)s.$(hostname)s.$(path_suffix)s.$(metric)s # path_prefix = servers # path_suffix = # Path Prefix for Virtual Machines # If the host supports virtual machines, collectors may report per # VM metrics. Following OpenStack nomenclature, the prefix for # reporting per VM metrics is "instances", and metric foo for VM # bar will be reported as: instances.bar.foo... # instance_prefix = instances # Default Poll Interval (seconds) interval = 15 ################################################################################ # Default enabled collectors ################################################################################ [[CPUCollector]] enabled = True [[DiskSpaceCollector]] enabled = True [[DiskUsageCollector]] enabled = True [[LoadAverageCollector]] enabled = True [[MemoryCollector]] enabled = True [[VMStatCollector]] enabled = True ################################################################################ ### Options for logging # for more information on file format syntax: # http://docs.python.org/library/logging.config.html#configuration-file-format [loggers] keys = root # handlers are higher in this config file, in: # [handlers] # keys = ... [formatters] keys = default [logger_root] # to increase verbosity, set DEBUG level = DEBUG handlers = rotated_file propagate = 1 [handler_rotated_file] class = handlers.TimedRotatingFileHandler level = DEBUG formatter = default # rotate at midnight, each day and keep 7 days args = ('/var/log/diamond/diamond.log', 'midnight', 1, 7) [formatter_default] format = [%(asctime)s] [%(threadName)s] %(message)s datefmt = ################################################################################ ### Options for config merging # [configs] # path = "/etc/diamond/configs/" # extension = ".conf" #------------------------------------------------------------------------------- # Example: # /etc/diamond/configs/net.conf # [collectors] # # [[NetworkCollector]] # enabled = True diamond-4.0.515/debian/0000755000076500000240000000000013016133611014601 5ustar josestaff00000000000000diamond-4.0.515/debian/changelog0000644000076500000240000000116113016023367016460 0ustar josestaff00000000000000diamond (4.0.0) unstable; urgency=low * new upstream -- Rob Smith Wed, 31 Dec 2014 15:19:00 -0800 diamond (3.1.0) unstable; urgency=low * new upstream -- Rob Smith Tue, 05 Nov 2012 15:19:00 -0800 diamond (3.0.2) unstable; urgency=low * new upstream -- Rob Smith Tue, 01 Aug 2012 21:06:00 -0800 diamond (3.0.0) unstable; urgency=low * new upstream -- Rob Smith Tue, 24 Jul 2012 23:56:00 -0800 diamond (0.2.0) unstable; urgency=low * new upstream -- Christian Becker Tue, 16 Feb 2012 18:24:00 +0200 diamond-4.0.515/debian/compat0000644000076500000240000000000212501431745016006 0ustar josestaff000000000000007 diamond-4.0.515/debian/control0000644000076500000240000000117512501431745016217 0ustar josestaff00000000000000Source: diamond Section: misc Priority: extra Maintainer: Rob Smith Homepage: https://github.com/BrightcoveOS/Diamond Vcs-Git: git://github.com/BrightcoveOS/Diamond.git Vcs-Browser: https://github.com/BrightcoveOS/Diamond Build-Depends: debhelper (>= 7), python (>= 2.4), python-support, python-mock, python-configobj, cdbs Standards-Version: 3.9.1 Package: diamond Architecture: all Depends: ${misc:Depends}, ${python:Depends}, python (>= 2.4), python-configobj Description: System statistics collector for Graphite. Diamond is a daemon and toolset for gathering system statistics and publishing them to Graphite. diamond-4.0.515/debian/copyright0000644000076500000240000000246612501431745016553 0ustar josestaff00000000000000Files: * Copyright: (C) 2010-2012 by Brightcove Inc. http://www.brightcove.com/ (C) 2011-2012 by Ivan Pouzyrevsky (C) 2011-2012 by Rob Smith http://www.kormoc.com (C) 2012 Wijnand Modderman-Lenstra https://maze.io/ License: MIT 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. diamond-4.0.515/debian/diamond.default0000644000076500000240000000045312501431745017573 0ustar josestaff00000000000000# Defaults for diamond initscript # sourced by /etc/init.d/diamond # installed at /etc/default/diamond by the maintainer scripts # # This is a POSIX shell fragment # # Additional options that are passed to the Daemon. ENABLE_DIAMOND="yes" DIAMOND_PID="/var/run/diamond.pid" DIAMOND_USER="diamond" diamond-4.0.515/debian/diamond.init0000644000076500000240000001044012501431745017107 0ustar josestaff00000000000000#!/bin/sh ### BEGIN INIT INFO # Provides: diamond # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: System statistics collector for Graphite. # Description: Diamond is a daemon and toolset for gathering system statistics # and publishing them to Graphite. ### END INIT INFO # Author: Ivan Pouzyrevsky # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC=diamond NAME=diamond DAEMON=/usr/bin/diamond DAEMON_ARGS="-p /var/run/diamond.pid" PIDFILE=/var/run/diamond.pid SCRIPTNAME=/etc/init.d/diamond CONF=/etc/diamond/diamond.conf # Exit if the package is not installed [ -x $DAEMON ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Checking for a config file in place if [ ! -e $CONF ]; then echo "/etc/diamond/diamond.conf not found. Please see /etc/diamond/diamond.conf.example" exit 2 fi # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # If the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME return 0 } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $? ;; reload|force-reload) log_daemon_msg "Reloading $DESC" "$NAME" do_reload log_end_msg $? ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 exit 3 ;; esac : diamond-4.0.515/debian/diamond.upstart0000644000076500000240000000170412501431745017651 0ustar josestaff00000000000000# diamond - A system statistics collector for graphite # # Diamond is a daemon and toolset for gather system statistics # and publishing them to graphite. description "Diamond system statistics collector" start on (local-filesystems and net-device-up IFACE!=lo) stop on [!12345] limit nofile 32768 32768 kill timeout 5 script # Source /etc/diamond if exists. Otherwise defaults. if [ -f /etc/default/diamond ]; then . /etc/default/diamond else ENABLE_DIAMOND="yes" DIAMOND_PID="/var/run/diamond.pid" DIAMOND_USER="diamond" fi PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=`which diamond` # Launch Diamond if enabled in /etc/default if [ "x$ENABLE_DIAMOND" = "xyes" ]; then exec start-stop-daemon --start --make-pidfile --chuid $DIAMOND_USER --pidfile $DIAMOND_PID --exec $DAEMON -- --foreground --skip-change-user --skip-fork --skip-pidfile fi end script diamond-4.0.515/debian/dirs0000644000076500000240000000004712501431745015475 0ustar josestaff00000000000000etc/diamond/collectors var/log/diamond diamond-4.0.515/debian/postinst0000644000076500000240000000304612501431745016421 0ustar josestaff00000000000000#!/bin/sh # postinst script for diamond # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) if ! getent group diamond >/dev/null ; then addgroup --quiet --system diamond >/dev/null fi if ! getent passwd diamond >/dev/null; then adduser --quiet --system --no-create-home --home /var/log/diamond \ --ingroup diamond \ --shell /usr/sbin/nologin diamond fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # Prevent diamond from auto-starting at this stage of the install. # For some reason, it fails to start and throws an exception chmod -x /usr/bin/diamond # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# # Enable startup chmod +x /usr/bin/diamond # Log / Run directory permissions chown -R diamond:diamond /var/log/diamond exit 0 diamond-4.0.515/debian/postrm0000644000076500000240000000204312501431745016056 0ustar josestaff00000000000000#!/bin/sh # postrm script for diamond # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `remove' # * `purge' # * `upgrade' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # * `disappear' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in purge) [ -d /var/log/diamond ] && rm -rf /var/log/diamond [ -d /etc/diamond ] && rm -rf /etc/diamond ;; purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 diamond-4.0.515/debian/preinst0000644000076500000240000000126212501431745016220 0ustar josestaff00000000000000#!/bin/sh # preinst script for diamond # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `install' # * `install' # * `upgrade' # * `abort-upgrade' # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in install|upgrade) ;; abort-upgrade) ;; *) echo "preinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 diamond-4.0.515/debian/prerm0000644000076500000240000000164112501431745015662 0ustar josestaff00000000000000#!/bin/sh # prerm script for diamond # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `remove' # * `upgrade' # * `failed-upgrade' # * `remove' `in-favour' # * `deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package # Stop diamond if it's running stop diamond || true case "$1" in remove|upgrade|deconfigure) ;; failed-upgrade) ;; *) echo "prerm called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 diamond-4.0.515/debian/pyversions0000644000076500000240000000000512501431745016747 0ustar josestaff000000000000002.4- diamond-4.0.515/debian/rules0000755000076500000240000000036512501431745015674 0ustar josestaff00000000000000#!/usr/bin/make -f # -*- makefile -*- DEB_PYTHON_SYSTEM := pysupport include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk clean:: rm -rf build build-stamp configure-stamp build/ MANIFEST dh_clean diamond-4.0.515/LICENSE0000644000076500000240000000252512501431745014377 0ustar josestaff00000000000000Copyright (C) 2010-2012 by Brightcove Inc. http://www.brightcove.com/ Copyright (C) 2011-2012 by Ivan Pouzyrevsky Copyright (C) 2011-2012 by Rob Smith http://www.kormoc.com Copyright (C) 2012 Wijnand Modderman-Lenstra https://maze.io/ Copyright (C) 2012 Dennis Kaarsemaker License: MIT 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. diamond-4.0.515/MANIFEST.in0000644000076500000240000000057213015725651015133 0ustar josestaff00000000000000include LICENSE include MANIFEST.in include version.txt include .keep include rpm/upstart/diamond.conf include rpm/systemd/diamond.service graft bin graft debian graft conf exclude conf/*.conf graft src/collectors global-exclude */tests/* recursive-exclude src/collectors/*/test * diamond-4.0.515/PKG-INFO0000644000076500000240000000057113016133611014457 0ustar josestaff00000000000000Metadata-Version: 1.1 Name: diamond Version: 4.0.515 Summary: Smart data producer for graphite graphing package Home-page: https://github.com/python-diamond/Diamond Author: The Diamond Team Author-email: diamond@librelist.com License: MIT License Description: UNKNOWN Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 diamond-4.0.515/rpm/0000755000076500000240000000000013016133611014155 5ustar josestaff00000000000000diamond-4.0.515/rpm/systemd/0000755000076500000240000000000013016133611015645 5ustar josestaff00000000000000diamond-4.0.515/rpm/systemd/diamond.service0000644000076500000240000000031712501431745020652 0ustar josestaff00000000000000[Unit] Description=diamond - A system statistics collector for graphite [Service] ExecStart=/usr/bin/python /usr/bin/diamond --log-stdout --foreground Restart=on-abort [Install] WantedBy=multi-user.target diamond-4.0.515/rpm/upstart/0000755000076500000240000000000013016133611015657 5ustar josestaff00000000000000diamond-4.0.515/rpm/upstart/diamond.conf0000644000076500000240000000045112501431745020150 0ustar josestaff00000000000000# diamond - A system statistics collector for graphite # # Diamond is a daemon and toolset for gather system statistics # and publishing them to graphite. start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn script /usr/bin/python /usr/bin/diamond --foreground end script diamond-4.0.515/setup.cfg0000644000076500000240000000036512606264167015223 0ustar josestaff00000000000000[bdist_rpm] requires = python-configobj provides = diamond pre-install = rpm/preinstall post-install = rpm/postinstall pre-uninstall = rpm/preuninstall install-script = rpm/install build_requires = python-setuptools [bdist_wheel] universal = 1 diamond-4.0.515/setup.py0000755000076500000240000001150613016126100015072 0ustar josestaff00000000000000#!/usr/bin/env python # coding=utf-8 import sys import os from glob import glob import platform def running_under_virtualenv(): if hasattr(sys, 'real_prefix'): return True elif sys.prefix != getattr(sys, "base_prefix", sys.prefix): return True if os.getenv('VIRTUAL_ENV', False): return True return False if os.environ.get('USE_SETUPTOOLS'): from setuptools import setup setup_kwargs = dict(zip_safe=0) else: from distutils.core import setup setup_kwargs = dict() if os.name == 'nt': pgm_files = os.environ["ProgramFiles"] base_files = os.path.join(pgm_files, 'diamond') data_files = [ (base_files, ['LICENSE', 'version.txt']), (os.path.join(base_files, 'user_scripts'), []), (os.path.join(base_files, 'conf'), glob('conf/*.conf.*')), (os.path.join(base_files, 'collectors'), glob('conf/collectors/*')), (os.path.join(base_files, 'handlers'), glob('conf/handlers/*')), ] install_requires = ['configobj', 'psutil', ], else: data_files = [ ('share/diamond', ['LICENSE', 'version.txt']), ('share/diamond/user_scripts', []), ] distro = platform.dist()[0] distro_major_version = platform.dist()[1].split('.')[0] if running_under_virtualenv(): data_files.append(('etc/diamond', glob('conf/*.conf.*'))) data_files.append(('etc/diamond/collectors', glob('conf/collectors/*'))) data_files.append(('etc/diamond/handlers', glob('conf/handlers/*'))) else: data_files.append(('/etc/diamond', glob('conf/*.conf.*'))) data_files.append(('/etc/diamond/collectors', glob('conf/collectors/*'))) data_files.append(('/etc/diamond/handlers', glob('conf/handlers/*'))) if distro == 'Ubuntu': data_files.append(('/etc/init', ['debian/diamond.upstart'])) if distro in ['centos', 'redhat', 'debian', 'fedora', 'oracle']: data_files.append(('/etc/init.d', ['bin/init.d/diamond'])) data_files.append(('/var/log/diamond', ['.keep'])) if distro_major_version >= 7 and not distro == 'debian': data_files.append(('/usr/lib/systemd/system', ['rpm/systemd/diamond.service'])) elif distro_major_version >= 6 and not distro == 'debian': data_files.append(('/etc/init', ['rpm/upstart/diamond.conf'])) # Support packages being called differently on different distros # Are we in a virtenv? if running_under_virtualenv(): install_requires = ['configobj', 'psutil', ] else: if distro == ['debian', 'ubuntu']: install_requires = ['python-configobj', 'python-psutil', ] # Default back to pip style requires else: install_requires = ['configobj', 'psutil', ] def get_version(): """ Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs """ try: f = open('version.txt') except IOError: os.system("./version.sh > version.txt") f = open('version.txt') version = ''.join(f.readlines()).rstrip() f.close() return version def pkgPath(root, path, rpath="/"): """ Package up a path recursively """ global data_files if not os.path.exists(path): return files = [] for spath in os.listdir(path): # Ignore test directories if spath == 'test': continue subpath = os.path.join(path, spath) spath = os.path.join(rpath, spath) if os.path.isfile(subpath): files.append(subpath) if os.path.isdir(subpath): pkgPath(root, subpath, spath) data_files.append((root + rpath, files)) if os.name == 'nt': pkgPath(os.path.join(base_files, 'collectors'), 'src/collectors', '\\') else: pkgPath('share/diamond/collectors', 'src/collectors') version = get_version() setup( name='diamond', version=version, url='https://github.com/python-diamond/Diamond', author='The Diamond Team', author_email='diamond@librelist.com', license='MIT License', description='Smart data producer for graphite graphing package', package_dir={'': 'src'}, packages=['diamond', 'diamond.handler', 'diamond.utils'], scripts=['bin/diamond', 'bin/diamond-setup'], data_files=data_files, install_requires=install_requires, classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 2', ], ** setup_kwargs ) diamond-4.0.515/src/0000755000076500000240000000000013016133611014146 5ustar josestaff00000000000000diamond-4.0.515/src/collectors/0000755000076500000240000000000013016133611016317 5ustar josestaff00000000000000diamond-4.0.515/src/collectors/amavis/0000755000076500000240000000000013016133611017577 5ustar josestaff00000000000000diamond-4.0.515/src/collectors/amavis/amavis.py0000644000076500000240000000741613015725651021453 0ustar josestaff00000000000000# coding=utf-8 """ Collector that reports amavis metrics as reported by amavisd-agent #### Dependencies * amavisd-agent must be present in PATH """ import os import subprocess import re import diamond.collector import diamond.convertor from diamond.collector import str_to_bool class AmavisCollector(diamond.collector.Collector): # From the source of amavisd-agent and it seems like the three interesting # formats are these: ("x y/h", "xMB yMB/h", "x s y s/msg"), # so this, ugly as it is to hardcode it this way, it should be right. # # The other option would be to directly read and decode amavis' berkeley # db, and I don't even want to get there matchers = [ re.compile(r'^\s*(?PsysUpTime)\s+TimeTicks\s+(?P