Skip to content

Instantly share code, notes, and snippets.

@sax
Forked from matthiasg/carbon-cache.sh
Last active December 29, 2015 11:19

Revisions

  1. sax revised this gist Nov 26, 2013. 2 changed files with 11 additions and 11 deletions.
    16 changes: 8 additions & 8 deletions graphite.sh
    Original file line number Diff line number Diff line change
    @@ -3,25 +3,25 @@

    set -o xtrace
    . /lib/svc/share/smf_include.sh


    if [ -z "$SMF_FMRI" ]; then
    SMF_FMRI="svc:/graphite/management/graphite-web:default"
    fi

    cd /
    PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH
    PIDFILE=/var/run/graphite.pid


    case "$1" in
    'start')
    #### STARTUP
    rm -f -- $PIDFILE
    PYTHONPATH=/opt/local/lib/python2.7/site-packages/graphite:/opt/local/lib/python2.7
    /opt/local/bin/django-admin.py runserver --pythonpath=$PYTHONPATH --settings=graphite.settings 0.0.0.0:80 &
    PID=$!
    echo $PID > $PIDFILE
    ;;

    'stop')
    #### SHUTDOWN
    kill `cat $PIDFILE`
    rm -f -- $PIDFILE
    contract=`svcprop -p restarter/contract $SMF_FMRI`
    smf_kill_contract ${contract} TERM
    ;;

    *)
    6 changes: 3 additions & 3 deletions graphite.xml
    Original file line number Diff line number Diff line change
    @@ -13,11 +13,11 @@
    <dependency name='carbon' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/graphite/carbon-cache'/>
    </dependency>
    <method_context>
    <method_credential user="graphite" privileges="basic,net_privaddr" group="graphite"/>
    </method_context>
    <exec_method name='start' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='60'/>
    <property_group name='startd' type='framework'>
    <propval name='duration' type='astring' value='transient'/>
    </property_group>
    <stability value='Unstable'/>
    <template>
    <common_name>
  2. @matthiasg matthiasg revised this gist Feb 14, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions in-graphite-machine.sh
    Original file line number Diff line number Diff line change
    @@ -61,6 +61,7 @@ cp local_settings.py.example local_settings.py
    # Initialize graphite/carbon database
    cd /opt/local/graphite
    export LC_ALL="en_US.UTF-8" # imporant for syncdb (otherwise the user creation will fail)
    mkdir /opt/local/graphite/storage
    #will ask for username and password
    python /opt/local/lib/python2.7/site-packages/graphite/manage.py syncdb

  3. @matthiasg matthiasg renamed this gist Feb 14, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @matthiasg matthiasg revised this gist Feb 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion in graphite machine
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ cp local_settings.py.example local_settings.py
    #
    # change local_settings.py:
    #
    # TIME_ZONE = 'Europe/London' # (timezone based on whatever you need-BUT smartos defaults to UTC time so this is consistent )
    # TIME_ZONE = 'UTC' # (timezone based on whatever you need-BUT smartos defaults to UTC time so this is consistent )
    #
    # CONF_DIR = '/opt/local/graphite/conf'
    # STORAGE_DIR = '/opt/local/graphite/storage'
  5. @matthiasg matthiasg revised this gist Feb 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion in graphite machine
    Original file line number Diff line number Diff line change
    @@ -105,7 +105,7 @@ svccfg import graphite.xml
    svccfg import statsd.xml

    svcsadm enable carbon-cache
    svcsadm enable graphite
    svcsadm enable graphite/graphite
    svcsadm enable statsd

    # Services are running now. statsd logs to /var/log/statsd.log and when set
  6. @matthiasg matthiasg revised this gist Feb 1, 2013. 1 changed file with 32 additions and 3 deletions.
    35 changes: 32 additions & 3 deletions in graphite machine
    Original file line number Diff line number Diff line change
    @@ -67,18 +67,47 @@ python /opt/local/lib/python2.7/site-packages/graphite/manage.py syncdb
    # create log folder
    mkdir /opt/local/graphite/storage/log/webapp


    #
    # NOW THE SYSTEM IS SETUP, SERVICES CAN BE STARTED MANUALLY OR YOU CAN INSTALL SMF SERVICES
    #

    # MANUALLY>

    # STARTING CARBON
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    # STARTING GRAPHITE
    run-graphite-devel-server.py --libs=/opt/local/lib/python2.7/site-packages/graphite /opt/local/graphite &



    ### Optional STATSD
    # I INSTALLED IT IN A DIFFERENT MACHINE (with git clone and npm install) and then copied it over to /opt/local/statsd
    # git clone https://github.com/etsy/statsd

    # then copy exampleConfig.js into config.js and update ip to 127.0.0.1
    cd /opt/local/statsd
    node stats.js config.js &
    node stats.js config.js &

    # SERVICES>
    # This is alternative above (but statsd is identical just leave out the last line to start node)

    mkdir /opt/custom/smf
    cd /opt/custom/smf
    # PUT ALL xml files in here

    mkdir /opt/custom/share/svc
    cd /opt/custom/share/svc
    # PUT THE .sh files in here

    cd /opt/custom/smf
    svccfg import carbon-cache.xml
    svccfg import graphite.xml
    svccfg import statsd.xml

    svcsadm enable carbon-cache
    svcsadm enable graphite
    svcsadm enable statsd

    # Services are running now. statsd logs to /var/log/statsd.log and when set
    # to debug this will get huge to beware! you can change statsd.sh of course.

  7. @matthiasg matthiasg revised this gist Feb 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion in graphite machine
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ cp local_settings.py.example local_settings.py
    #
    # change local_settings.py:
    #
    # TIME_ZONE = 'Europe/Berlin' # (timezone based on whatever you need)
    # TIME_ZONE = 'Europe/London' # (timezone based on whatever you need-BUT smartos defaults to UTC time so this is consistent )
    #
    # CONF_DIR = '/opt/local/graphite/conf'
    # STORAGE_DIR = '/opt/local/graphite/storage'
  8. @matthiasg matthiasg revised this gist Jan 31, 2013. 2 changed files with 60 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions statsd.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash
    # Simple Ad Hoc Graphite StatsD Service

    set -o xtrace
    . /lib/svc/share/smf_include.sh

    cd /
    PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH
    PIDFILE=/var/run/statsd.pid

    case "$1" in
    'start')
    #### STARTUP
    rm -f -- $PIDFILE
    cd /opt/local/statsd
    /opt/local/bin/node stats.js config.js > /var/log/statd.log &
    PID=$!
    echo $PID > $PIDFILE
    ;;

    'stop')
    #### SHUTDOWN
    kill `cat $PIDFILE`
    rm -f -- $PIDFILE
    ;;

    *)
    echo "Usage: $0 { start | stop }"
    exit $SMF_EXIT_ERR_FATAL
    ;;
    esac
    exit $SMF_EXIT_OK
    28 changes: 28 additions & 0 deletions statsd.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <?xml version='1.0'?>
    <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
    <service_bundle type='manifest' name='export'>
    <service name='graphite/statsd' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='net-physical' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/network/physical'/>
    </dependency>
    <dependency name='filesystem' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='carbon' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/graphite/graphite'/>
    </dependency>
    <exec_method name='start' type='method' exec='/opt/custom/share/svc/statsd.sh %m' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/custom/share/svc/statsd.sh %m' timeout_seconds='60'/>
    <property_group name='startd' type='framework'>
    <propval name='duration' type='astring' value='transient'/>
    </property_group>
    <stability value='Unstable'/>
    <template>
    <common_name>
    <loctext xml:lang='C'>StatsD Service</loctext>
    </common_name>
    </template>
    </service>
    </service_bundle>
  9. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graphite.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ case "$1" in
    #### STARTUP
    rm -f -- $PIDFILE
    PYTHONPATH=/opt/local/lib/python2.7/site-packages/graphite:/opt/local/lib/python2.7
    /opt/local/bin/django-admin.py runserver --pythonpath=$PYTHONPATH 0.0.0.0:80 &
    /opt/local/bin/django-admin.py runserver --pythonpath=$PYTHONPATH --settings=graphite.settings 0.0.0.0:80 &
    PID=$!
    echo $PID > $PIDFILE
    ;;
  10. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graphite.xml
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    </dependency>
    <dependency name='carbon' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/graphite/carbon-cache'/>
    </dependency
    </dependency>
    <exec_method name='start' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='60'/>
    <property_group name='startd' type='framework'>
  11. @matthiasg matthiasg revised this gist Jan 31, 2013. 3 changed files with 45 additions and 9 deletions.
    32 changes: 32 additions & 0 deletions graphite.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash
    # Simple Ad Hoc Graphite Django Service

    set -o xtrace
    . /lib/svc/share/smf_include.sh

    cd /
    PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH
    PIDFILE=/var/run/graphite.pid

    case "$1" in
    'start')
    #### STARTUP
    rm -f -- $PIDFILE
    PYTHONPATH=/opt/local/lib/python2.7/site-packages/graphite:/opt/local/lib/python2.7
    /opt/local/bin/django-admin.py runserver --pythonpath=$PYTHONPATH 0.0.0.0:80 &
    PID=$!
    echo $PID > $PIDFILE
    ;;

    'stop')
    #### SHUTDOWN
    kill `cat $PIDFILE`
    rm -f -- $PIDFILE
    ;;

    *)
    echo "Usage: $0 { start | stop }"
    exit $SMF_EXIT_ERR_FATAL
    ;;
    esac
    exit $SMF_EXIT_OK
    4 changes: 2 additions & 2 deletions in Global Zone
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    imgadm import 84cb7edc-3f22-11e2-8a2a-3f2a7b148699
    # adjust ip and stuff in graphite.json
    vmadm create -f graphite.json
    # adjust ip and stuff in vm-graphite.json
    vmadm create -f vm-graphite.json
    zlogin <uuid of machine just created>
    18 changes: 11 additions & 7 deletions in graphite machine → in graphite machine
    Original file line number Diff line number Diff line change
    @@ -58,22 +58,26 @@ cp local_settings.py.example local_settings.py
    # LOCAL_DATA_DIR = /opt/local/graphite/storage/whisper
    #

    # STARTING CARBON
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    # Initialize graphite/carbon database
    cd /opt/local/graphite

    export LC_ALL="en_US.UTF-8" # imporant for syncdb (otherwise the user creation will fail)
    #will ask for username and password
    python /opt/local/lib/python2.7/site-packages/graphite/manage.py syncdb

    # create log folder
    mkdir /opt/local/graphite/storage/log/webapp

    # STARTING CARBON
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    # STARTING GRAPHITE
    run-graphite-devel-server.py --libs=/opt/local/lib/python2.7/site-packages/graphite /opt/local/graphite &


    ### STATSD
    # I INSTALLED IT IN A DIFFERENT MACHINE (with git) and then copied it over to /opt/local/statsd
    # git clone https://github.com/etsy/statsd

    ### Optional STATSD
    # I INSTALLED IT IN A DIFFERENT MACHINE (with git clone and npm install) and then copied it over to /opt/local/statsd
    # git clone https://github.com/etsy/statsd

    # then copy exampleConfig.js into config.js and update ip to 127.0.0.1
    cd /opt/local/statsd
  12. @matthiasg matthiasg renamed this gist Jan 31, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions graphite.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <?xml version='1.0'?>
    <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
    <service_bundle type='manifest' name='export'>
    <service name='graphite/graphite' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='net-physical' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/network/physical'/>
    </dependency>
    <dependency name='filesystem' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='carbon' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/graphite/carbon-cache'/>
    </dependency
    <exec_method name='start' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/custom/share/svc/graphite.sh %m' timeout_seconds='60'/>
    <property_group name='startd' type='framework'>
    <propval name='duration' type='astring' value='transient'/>
    </property_group>
    <stability value='Unstable'/>
    <template>
    <common_name>
    <loctext xml:lang='C'>Graphite Service</loctext>
    </common_name>
    </template>
    </service>
    </service_bundle>
  14. @matthiasg matthiasg renamed this gist Jan 31, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graphite.xml → carbon-cache.xml
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?xml version='1.0'?>
    <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
    <!-- put in /opt/custom/smf and import using svccfg import /opt/custom/smf/graphite.xml -->
    <!-- put in /opt/custom/smf and import using svccfg import /opt/custom/smf/carbon-cache.xml -->
    <service_bundle type='manifest' name='export'>
    <service name='graphite/carbon-cache' type='service' version='0'>
    <create_default_instance enabled='true'/>
  15. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions carbon-cache.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash
    # Simple Ad Hoc Carbon Cache Service
    #
    # put in /opt/custom/share/svc/carbon-cache.sh

    set -o xtrace
    . /lib/svc/share/smf_include.sh

    cd /
    PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH

    case "$1" in
    'start')
    #### STARTUP
    /opt/local/bin/carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start
    ;;

    'stop')
    #### SHUTDOWN
    /opt/local/bin/carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf stop
    ;;

    *)
    echo "Usage: $0 { start | stop }"
    exit $SMF_EXIT_ERR_FATAL
    ;;
    esac
    exit $SMF_EXIT_OK
  16. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 26 additions and 0 deletions.
    26 changes: 26 additions & 0 deletions graphite.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <?xml version='1.0'?>
    <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
    <!-- put in /opt/custom/smf and import using svccfg import /opt/custom/smf/graphite.xml -->
    <service_bundle type='manifest' name='export'>
    <service name='graphite/carbon-cache' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='net-physical' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/network/physical'/>
    </dependency>
    <dependency name='filesystem' grouping='require_all' restart_on='none' type='service'>
    <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <exec_method name='start' type='method' exec='/opt/custom/share/svc/carbon-cache.sh %m' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/custom/share/svc/carbon-cache.sh %m' timeout_seconds='60'/>
    <property_group name='startd' type='framework'>
    <propval name='duration' type='astring' value='transient'/>
    </property_group>
    <stability value='Unstable'/>
    <template>
    <common_name>
    <loctext xml:lang='C'>Carbon Cache Default Script</loctext>
    </common_name>
    </template>
    </service>
    </service_bundle>
  17. @matthiasg matthiasg revised this gist Jan 31, 2013. 1 changed file with 6 additions and 9 deletions.
    15 changes: 6 additions & 9 deletions in graphite machine
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,14 @@
    ### GRAPHITE
    export LC_ALL="en_US.UTF-8" # imporant for syncdb (otherwise the user creation will fail)
    PYTHONPATH=/opt/local/lib/python2.7

    pkgin in py27-carbon-0.9.10
    pkgin in py27-graphite-web-0.9.10
    export GRAPHITE_ROOT=/opt/local/graphite/
    export GRAPHITE_CONF_DIR=/opt/local/etc/graphite

    cd /opt/local/lib/python2.7/site-packages/graphite
    cp local_settings.py.example local_settings.py

    #
    # change these to (timezone based on whatever you need):
    # change local_settings.py:
    #
    # TIME_ZONE = 'Europe/Berlin'
    # TIME_ZONE = 'Europe/Berlin' # (timezone based on whatever you need)
    #
    # CONF_DIR = '/opt/local/graphite/conf'
    # STORAGE_DIR = '/opt/local/graphite/storage'
    @@ -52,8 +48,7 @@ cp local_settings.py.example local_settings.py
    #

    # CONFIGURING CARBON
    # instead of relying on the declares above you can change the carbon.conf (/opt/local/etc/graphite/carbon.conf) like this
    #
    # change the carbon.conf (/opt/local/etc/graphite/carbon.conf) like this
    #
    # STORAGE_DIR = /opt/local/graphite/storage
    # CONF_DIR = /opt/local/etc/graphite
    @@ -67,6 +62,8 @@ cp local_settings.py.example local_settings.py
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    cd /opt/local/graphite

    export LC_ALL="en_US.UTF-8" # imporant for syncdb (otherwise the user creation will fail)
    #will ask for username and password
    python /opt/local/lib/python2.7/site-packages/graphite/manage.py syncdb

  18. @matthiasg matthiasg revised this gist Jan 29, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion in graphite machine
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ cp local_settings.py.example local_settings.py
    # LOG_DIR = /opt/local/graphite/storage/log/carbon-cache
    # PID_DIR = /opt/local/graphite/storage
    #
    # LOCAL_DATA_DIR = /opt/local/graphite/storage/content
    # LOCAL_DATA_DIR = /opt/local/graphite/storage/whisper
    #

    # STARTING CARBON
  19. @matthiasg matthiasg revised this gist Jan 29, 2013. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions in graphite machine
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,17 @@ cp local_settings.py.example local_settings.py
    # aggregationMethod = sum
    #

    # CONFIGURING CARBON
    # instead of relying on the declares above you can change the carbon.conf (/opt/local/etc/graphite/carbon.conf) like this
    #
    #
    # STORAGE_DIR = /opt/local/graphite/storage
    # CONF_DIR = /opt/local/etc/graphite
    # LOG_DIR = /opt/local/graphite/storage/log/carbon-cache
    # PID_DIR = /opt/local/graphite/storage
    #
    # LOCAL_DATA_DIR = /opt/local/graphite/storage/content
    #

    # STARTING CARBON
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start
  20. @matthiasg matthiasg revised this gist Jan 29, 2013. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions in graphite machine
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,38 @@ cp local_settings.py.example local_settings.py
    # also comment in the DATABASE={ ... } part
    # and change NAME to /opt/local/graphite/storage/graphite.db
    #

    #
    # Note: I read on http://www.spacevatican.org/2012/9/18/using-statsd-and-graphite-from-a-rails-app/
    # that
    #
    # "When using statsd with its default settings it’s crucial that you keep at least
    # some 10 second data (the default graphite config keeps 1min resolution data only).
    # If you don’t then the mismatch between statsd’s flush rate and graphite’s
    # flush rate will cause you to lose data. "
    #
    # That means storage-schemas.conf in /opt/local/etc/graphite should be edited like this:

    # Add the following to storage-schemas.conf, above the [default_1min_for_1day] section
    #
    # [stats]
    # pattern = ^stats\..*
    # retentions = 10:2160,60:10080,600:262974
    #
    # [stats_count]
    # pattern = ^stats_counts\..*
    # retentions = 10:2160,60:10080,600:262974
    #
    # and edit storage-aggregation.conf by adding before the default entry
    #
    # [stats_counts]
    # pattern = ^stats_counts\.
    # xFilesFactor = 0
    # aggregationMethod = sum
    #


    # STARTING CARBON
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    cd /opt/local/graphite
  21. @matthiasg matthiasg created this gist Jan 28, 2013.
    19 changes: 19 additions & 0 deletions graphite.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    {
    "alias":"graphite",
    "brand": "joyent",
    "image_uuid": "84cb7edc-3f22-11e2-8a2a-3f2a7b148699",
    "max_physical_memory": 512,
    "resolvers": [
    "8.8.8.8",
    "8.8.4.4"
    ],
    "nics": [
    {
    "interface": "net0",
    "nic_tag": "admin",
    "gateway": "192.168.2.254",
    "ip": "192.168.2.203",
    "netmask": "255.255.255.0"
    }
    ]
    }
    4 changes: 4 additions & 0 deletions in Global Zone
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    imgadm import 84cb7edc-3f22-11e2-8a2a-3f2a7b148699
    # adjust ip and stuff in graphite.json
    vmadm create -f graphite.json
    zlogin <uuid of machine just created>
    40 changes: 40 additions & 0 deletions in graphite machine
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    ### GRAPHITE
    export LC_ALL="en_US.UTF-8" # imporant for syncdb (otherwise the user creation will fail)
    PYTHONPATH=/opt/local/lib/python2.7

    pkgin in py27-carbon-0.9.10
    pkgin in py27-graphite-web-0.9.10
    export GRAPHITE_ROOT=/opt/local/graphite/
    export GRAPHITE_CONF_DIR=/opt/local/etc/graphite
    cd /opt/local/lib/python2.7/site-packages/graphite
    cp local_settings.py.example local_settings.py

    #
    # change these to (timezone based on whatever you need):
    #
    # TIME_ZONE = 'Europe/Berlin'
    #
    # CONF_DIR = '/opt/local/graphite/conf'
    # STORAGE_DIR = '/opt/local/graphite/storage'
    # CONTENT_DIR = '/opt/local/graphite/webapp/content'
    #
    # also comment in the DATABASE={ ... } part
    # and change NAME to /opt/local/graphite/storage/graphite.db
    #
    carbon-cache.py --config=/opt/local/etc/graphite/carbon.conf start

    cd /opt/local/graphite
    #will ask for username and password
    python /opt/local/lib/python2.7/site-packages/graphite/manage.py syncdb

    mkdir /opt/local/graphite/storage/log/webapp
    run-graphite-devel-server.py --libs=/opt/local/lib/python2.7/site-packages/graphite /opt/local/graphite &


    ### STATSD
    # I INSTALLED IT IN A DIFFERENT MACHINE (with git) and then copied it over to /opt/local/statsd
    # git clone https://github.com/etsy/statsd

    # then copy exampleConfig.js into config.js and update ip to 127.0.0.1
    cd /opt/local/statsd
    node stats.js config.js &
    14 changes: 14 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    var StatsdClient = new require('statsd-client');
    console.dir(StatsdClient)
    var sdc = new StatsdClient({host: '<IP?', port:8125, prefix:"test"});
    console.dir(sdc)

    var timer = new Date();
    for (var i = 0; i < 100; i++) {
    sdc.increment('counter'); // Increment by one.
    };
    sdc.increment('counter'); // Increment by one.
    sdc.gauge('gauge', 10); // Set gauge to 10
    sdc.timing('timer', timer); // Calculates time diff

    sdc.close(); // Optional - stop NOW
    5 changes: 5 additions & 0 deletions usage from client
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    forward port 8080 and port 8125 to that machines ip if necessary

    create a folder for statsd
    npm install statsd-client