File: graph-config.txt

package info (click to toggle)
serverstats 0.8.2-8
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 604 kB
  • ctags: 796
  • sloc: php: 4,238; perl: 90; sh: 15; makefile: 12
file content (220 lines) | stat: -rw-r--r-- 9,155 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
===============================================================================
 Serverstats - GRAPH CONFIGURATION
 Version: $Id$
===============================================================================

1. Introduction
2. Example: Configure graphs for loadavg and use
3. What to do if it does not work
4. More complex examples


===============================================================================
 1. Introduction
===============================================================================

  Here we will explain the configuration needed for two typical graphs (by 
  example).


===============================================================================
 2. Example: Configure graphs for loadavg and users (logged in)
===============================================================================

  The configuration for graphs is splitted in two PHP files:

  * config/sources.php - settings for the data sources
  * config/graph.php - settings for graph image to display

  Settings in config/graph.php are mapped to 'rrdtool graph' parameters,
  it's a good idea to have a look at 'man rrdgraph' for detailed description
  of the used parameters.

  ---------------------------------------------------------------------------

  Settings in config/sources.php (for data sources 'load' and 'users'):

    $config = array(); // this line is only needed once in this file
    $config['load']['module'] = new load();
    $config['users']['module'] = new users();

  Explanation:

  For every source you have to enter the following:

    $config[<name>]['module'] = new <sourcemodulname>([parameters]);

  <sourcemodulname> is a class in sources/ directory, which is used to collect
  the data. serverstats ships with a lot of sources, we will use 
  sources/load.php and sources/users.php in this guide, because they don't need
  any additional configuration to work.

  For information on how to set up sources for Traffic, Apache requests/s, ...
  have a lock at doc/sources.txt.

  Available [parameters] can be found in __construct() methode 
  in sources/<sourcemodulname>.php and in doc/sources.txt. An example line from
  sources/disk.php:

    public function __construct($disk, $withpartitions = false,
        $sector_size = 512, $path_stat = '/proc/diskstats')

  here $disk is a mandatory parameter (e.g. 'hda'), all the other partameters
  have default values like $path_stat = '/proc/diskstats' which don't need to
  be changed if the default is OK. So the line in config/sources.php for the
  disk source could look like this:

    $config['disk']['module'] = new disk('hda');

  If you have a "sector size" of 1024 and not the default 512, you have to pass
  something like that: 

    $config['disk']['module'] = new disk('hdb', false, 1024);

  The parameters are explained in doc/sources.txt in detail. If a parameter has
  no default value, it must be provided in config/sources.php.

  For 'load' and 'users' no additional parameters are available (or needed).

  ---------------------------------------------------------------------------

  Example for settings in config/graph.php

  (for only two graphs from data source 'load' and 'users'):

    $config['list'] = array(
            array(
                    'title' => 'Number of User logged in',
                    'verticalLabel' => 'Users',
                    'lowerLimit' => 0,
                    'altAutoscaleMax' => true,
                    'content' => array(
                            array(
                                    'type' => 'LINE',
                                    'width' => 2,
                                    'source' => 'users',
                                    'ds' => 'users',
                                    'cf' => 'AVERAGE',
                                    'legend' => 'Number of Users',
                                    'color' => 'FF0000'
                            )
                    )
            ),
            array(
                    'title' => 'Load Average'
                    'verticalLabel' => 'loadavg',
                    'lowerLimit' => 0,
                    'altAutoscaleMax' => true,
                    'content' => array(
                            array(
                                    'type' => 'AREA',
                                    'source' => 'load',
                                    'ds' => '1min',
                                    'cf' => 'AVERAGE',
                                    'legend' => '1min',
                                    'color' => 'FF0000'
                            ),
                            array(
                                    'type' => 'AREA',
                                    'source' => 'load',
                                    'ds' => '5min',
                                    'cf' => 'AVERAGE',
                                    'legend' => '5min',
                                    'color' => 'EE0000'
                            ),
                            array(
                                    'type' => 'AREA',
                                    'source' => 'load',
                                    'ds' => '15min',
                                    'cf' => 'AVERAGE',
                                    'legend' => '15min',
                                    'color' => 'DD0000'
                            )
                    )
            )
    );

  Explanation:

    $config['list']

  is the array with all the graphs you would like to display. If you want to use
  additional graphs, you have to add them here (see config.sample/graph.php for
  examples). 
  Every element of 'list' is a graph.

    $config['list'][0]

  the first graph, in this case 'Number of User logged in'.

  Settings in element 'content':

    * 'type' - that's the Typ of graph (line, area..., see:
      http://people.ee.ethz.ch/oetiker/webtools/rrdtool/doc/rrdgraph_graph.en.html#graph)

    * 'source' - that's the mapping to the source, as defined in 
      config/sources.php
      This setting has to fit to an existing source class in sources/ directory.

    * 'ds' (Datasource, see rrdtool manual: 'DS') - that's the name of the 
      datasource, which is used to create and update the stats data (in rrd
      file).
      One rrd file / source class can have more than one datasource.
      
      - 'sources" are the PHP scripts / classes used to collect data, and write 
        them to rrd files 
      - datasources are 'fields' in the rrd file.

	  this value has to match to the datasource settings in the 
	  sources/<sourcemodulname>.php file, which aren't defined in
	  config/ dir but in sources/<sourcemodulname>.php file.
	  
	  For example, the matching part from sources/load.php:

    public function initRRD(rrd $rrd) {
          $rrd->addDatasource('1min', 'GAUGE', null, 0);
          $rrd->addDatasource('5min', 'GAUGE', null, 0);
          $rrd->addDatasource('15min', 'GAUGE', null, 0);
          $rrd->addDatasource('running', 'GAUGE', null, 0);
          $rrd->addDatasource('tasks', 'GAUGE', null, 0);
    }

      see: http://people.ee.ethz.ch/oetiker/webtools/rrdtool/doc/rrdcreate.en.html#item_ds_3ads_2dname_3adst_3adst_arguments

    * 'cf' (consolidation function) - that's the type of 'data consolidation'
      (possible values: average, minimum, maximum, total, last - have a look at
      man rrdgraph for details!). 
      In most cases you want to see an average value, so choose 'average'. A
      CF can only be choosen, if the rrd data archive has been created with
      the matching CF. If you choose only AVERAGE values for the archive in 
      config/rra.php, you'll not be able to plot MAX values.
      ('LAST' has been relaced by VDEFs in rrdtool 1.2)

      see: http://people.ee.ethz.ch/oetiker/webtools/rrdtool/doc/rrdtool.en.html#item_consolidation

    * 'legend' (optional) - that's the legend displayed below the graph

      - if you want to display ':' you have to escape it (":" -> "\:")
      - you get new lines using "\n"  (see 'man rrdgraph')

    * 'color' - that's the graph color (the color of the plotted AREA or LINE)


===============================================================================
 3. What to do if it does not work:
===============================================================================

  Have a look at doc/faq.txt, to find out what to do if no graphs are 
  displayed.


===============================================================================
 4. More complex examples:
===============================================================================

  More complex, working examples can be found in config.sample/.

  A more advanced configuration with a lot of nice graphs can be found here:

	* demo -> http://www.webmasterpro.de/~ddanier/serverstats/demo/
	* config -> http://www.webmasterpro.de/~ddanier/serverstats/graph_example.phps