ripienaar / gdash

A dashboard for Graphite
http://www.devco.net/
Apache License 2.0
754 stars 117 forks source link

Support for includes and properties in dash.yaml (fixed bug when missing gdash_properties) #52

Closed keymon closed 11 years ago

keymon commented 12 years ago

Two new features:

These two features allow you create a set of templates that you can include and parametrize, like this:

└── graph_templates
    ├── live
    │   ├── 3_OS_server0001
    │   │   └── dash.yaml
    │   ├── 3_OS_server0002
    │   │   └── dash.yaml
    │   ├── 3_OS_live_all
    │   │   └── dash.yaml
    └── templates
        ├── os.basic
        │   ├── 10-cpu.graph
        │   ├── 20-load.graph
        │   ├── 25-memory.graph
        │   ├── 26-swap-io.graph
        │   ├── 30-network.graph
        │   ├── 40-processes.graph
        │   ├── 80-io.graph
        │   ├── 81-io-time.graph
        │   ├── 82-io-ops.graph
        │   └── 90-df.graph
        ├── os.basic_multi
        │   ├── 10-cpu-multi.graph
        │   ├── 30-network-multi.graph
        │   ├── 80-io-multi.graph
        │   ├── 81-io-time-multi.graph
        │   └── 82-io-ops-multi.graph
        ├── os.marklogic
        │   ├── 92-ml-volumes-df.graph
        │   └── 93-ml-volumes-df.graph
        └── os.nfs
             ├── 91-nfs-basic.graph
             ├── 92-nfs-detailed.graph
             └── 93-slabinfo.graph

In the dash.yaml you can include the graphs as an include and override some properties:

:name: "OS slnldogo0002"
:description: "OS slnldogo0002: slnldogo0002_springer-sbm_com"

:include: 
 - "templates/os.basic" 
 - "templates/os.nfs" 
:graph_properties: 
 :environment: live
 :servers: [ server0001, server0002 ]

And in the graphs:

title       "Combined CPU Usage"
vtitle      "percent"
linemode    "connected" 
timezone    "Europe/London"
description "The combined CPU usage for all core servers"

servers = @properties[:servers] 
environment = @properties[:environment] 

server_definition = (servers.is_a? Array) ? "{#{servers.join(',')}}" : servers

field :iowait, :scale => 0.1,
               :color => "yellow",
               :alias => "IO Wait",
               :data  => "sumSeries(nonNegativeDerivative(servers.#{server_definition}.cpu*.cpu-{system,wait}.value))",
               :smoothing => 3

field :user,   :scale => 0.1,
               :color => "green",
               :alias => "User",
               :data  => "sumSeries(nonNegativeDerivative(servers.#{server_definition}.cpu*.cpu-user.value))",
               :smoothing => 3

field :other,  :scale => 0.1,
               :color => "red",
               :alias => "Other",
               :data  => "sumSeries(nonNegativeDerivative(servers.#{server_definition}.cpu-*.cpu-{interrupt,softirq,steal}.value))",
               :smoothing => 3

field :idle,   :scale => 0.1,
               :color => "grey",
               :alias => "idle",
               :data  => "sumSeries(nonNegativeDerivative(servers.#{server_definition}.cpu-*.cpu-idle.value))",
               :smoothing => 3

We got to access this properties as @properties[:servers] because the missing_method disallows access the overrides directly, not sure why.

keymon commented 11 years ago

Will close this request. It has diverged and should be included in other PR