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