Skip to content

nareshov/Diamond

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Diamond is a python daemon that collects system metrics and publishes them to Graphite. It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.

Installation

** Installation/Building Dependencies **

  • make
  • rpm-build

** Core Dependencies **

  • CentOS or Ubuntu
  • Python 2.4+
  • python-configobj

** Unit Test Dependencies **

** Collector Dependencies**

*** SNMPInterfaceCollector ***

  • pysnmp

Usage

To install diamond:

make install

For testing, diamond can also be started directly without installing:

cp conf/diamond.conf.example conf/diamond.conf
edit conf/diamond.conf
make run

The run task will invoke diamond in debug mode for testing.

Ant can also build packages for CentOS/RHEL, Ubuntu/Debian, or generate a tar ball.

make buildrpm
sudo yum localinstall --nogpgcheck dist/diamond-0.2.0-1.noarch.rpm

make builddeb
sudo dpkg -i dist/diamond-0.2.0-1.deb

make tar
tar -xzvf dist/diamond-0.2.0.tar.gz

Configuration

If you've installed diamond via a package, the configuration file is /etc/diamond/diamond.cfg. By default, diamond will push to a graphite server host "graphite". You should probably change this to point to your own graphite server.

Other configuration should not be necessary.

By default diamond publishes metrics using the following form:

systems.<hostname>.<metrics>.<metric>

You can override the "systems" portion of the metric path by changing the "path_prefix" setting in the configuration file.

Built-In Collectors

  • CPUCollector
  • DiskSpaceCollector
  • DiskUsageCollector
  • ExampleCollector
  • FilestatCollector
  • HAProxyCollector
  • HttpdCollector
  • InterruptCollector
  • LoadAverageCollector
  • MemoryCollector
  • MySQLCollector
  • NetworkCollector
  • NginxCollector
  • PingCollector
  • SNMPCollector
  • SNMPInterfaceCollector
  • SockstatCollector
  • TCPCollector
  • UserScriptsCollector
  • VMStatCollector

Custom Collectors

Diamond collectors run within the diamond process and collect metrics that can be published to a graphite server.

Collectors are subclasses of diamond.collector.Collector. In their simplest form, they need to implement a single method called "collect".

import diamond.collector

class ExampleCollector(diamond.collector.Collector):

    def collect(self):
    """
    Overrides the Collector.collect method
    """
        # Set Metric Name
        metric_name = "my.example.metric"

        # Set Metric Value
        metric_value = 42

        # Publish Metric
        self.publish(metric_name, metric_value)

To run this collector in test mode you can invoke the diamond server with the -r option and specify the collector path.

python bin/diamond -f -v -r src/collectors/ExampleCollector/ExampleCollector.py -c conf/diamond.conf.example

Diamond supports dynamic addition of collectors. Its configured to scan for new collectors on a regular interval (configured in diamond.cfg). If diamond detects a new collector, or that a collectors module has changed (based on the file's mtime), it will be reloaded.

Diamond looks for collectors in /usr/lib/diamond/collectors/ (on Ubuntu). By default diamond will invoke the collect method every 60 seconds.

Diamond collectors that require a separate configuration file should place a .cfg file in /etc/diamond/collectors/. The configuration file name should match the name of the diamond collector class. For example, a collector called examplecollector.ExampleCollector could have its configuration file placed in /etc/diamond/collectors/ExampleCollector.cfg.

Testing

Requirements:

  • python-mock
  • python-configobj

To run the tests

make test

Contacts

Maintainer: Andy Kipp

Contributors

Ivan Pouzyrevsky

ooshlablu

oxcd8o

Rob Smith

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.9%
  • D 2.9%
  • Ruby 0.2%