Skip to content Skip to sidebar Skip to footer

Grahite, Carbon, CollectD, StatsD - Tagged Series In Python Program

I am trying to run some some python/other language modules modules/workflows/workloads and collect their CPU, Mem, I/O etc resource usage with Grahite, Carbon, CollectD, StatsD. I

Solution 1:

Although I ended up not using a tagged series, I have solved the problem above by writing a bash script and using the render api in graphite. Here is the walk around solution:

    #!/bin/bash   

    #Remove previous records. Be careful not to remove useful files!
    rm cpu.json, mem.json

    #clear variables for storing time 
    unset start
    unset finish

    #log start time of process using absolute time, if using relative time check doc at https://graphite.readthedocs.io/en/latest/render_api.html for rules
    start=$(date '+%H:%M_%Y%m%d')

    #call first module
    firstModule()

    #sleep 1 minute or more because you will get an error that start time and end time are equal
    sleep 100

    #call second module
    secondModule()

    #log finish date using absolute time, if using relative time check  doc at https://graphite.readthedocs.io/en/latest/render_api.html) for rules
    finish=$(date '+%H:%M_%Y%m%d')

    #collect data using curl here cpu usage and memusage, adjust to fit your setup and Voila!
    curl "http://host/render?target=carbon.agents.*.cpuUsage&width=500&height=300&from={$start}&until={$finish}&format=json" > cpu.json
    sudo curl "http://host/render?target=collectdlocalhost.memory.memory-used&width=500&height=300&from={$start}&until={$finish}&format=json" > mem.json

Post a Comment for "Grahite, Carbon, CollectD, StatsD - Tagged Series In Python Program"