1 <?php // vim:fenc=utf-8:filetype=php:ts=4
2 /*
3 * Copyright (C) 2009 Bruno Prémont <bonbons AT linux-vserver.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
19 function load_graph_definitions_local($logarithmic = false, $tinylegend = false) {
20 global $GraphDefs, $MetaGraphDefs;
22 // Define 1-rrd Graph definitions here
23 $GraphDefs['local_type'] = array(
24 '-v', 'Commits',
25 'DEF:avg={file}:value:AVERAGE',
26 'DEF:min={file}:value:MIN',
27 'DEF:max={file}:value:MAX',
28 "AREA:max#B7B7F7",
29 "AREA:min#FFFFFF",
30 "LINE1:avg#0000FF:Commits",
31 'GPRINT:min:MIN:%6.1lf Min,',
32 'GPRINT:avg:AVERAGE:%6.1lf Avg,',
33 'GPRINT:max:MAX:%6.1lf Max,',
34 'GPRINT:avg:LAST:%6.1lf Last\l');
36 // Define MetaGraph definition type -> function mappings here
37 $MetaGraphDefs['local_meta'] = 'meta_graph_local';
38 }
40 function meta_graph_local($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array()) {
41 global $config;
42 $sources = array();
44 $title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
45 if (!isset($opts['title']))
46 $opts['title'] = $title;
47 $opts['rrd_opts'] = array('-v', 'Events');
49 $files = array();
50 /* $opts['colors'] = array(
51 'ham' => '00e000',
52 'spam' => '0000ff',
53 'malware' => '990000',
55 'sent' => '00e000',
56 'deferred' => 'a0e000',
57 'reject' => 'ff0000',
58 'bounced' => 'a00050'
59 );
61 $type_instances = array('ham', 'spam', 'malware', 'sent', 'deferred', 'reject', 'bounced'); */
62 foreach ($type_instances as $inst) {
63 $file = '';
64 foreach ($config['datadirs'] as $datadir)
65 if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
66 $file = $datadir.'/'.$title.'-'.$inst.'.rrd';
67 break;
68 }
69 if ($file == '')
70 continue;
72 $sources[] = array('name'=>$inst, 'file'=>$file);
73 }
75 // return collectd_draw_meta_stack($opts, $sources);
76 return collectd_draw_meta_line($opts, $sources);
77 }
79 ?>