Files

84 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2020-09-21 15:40:17 +02:00
<?php
// vim:fenc=utf-8:filetype=php:ts=4
2009-04-29 15:07:28 +00:00
/*
* Copyright (C) 2009 Bruno Prémont <bonbons AT linux-vserver.org>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; only version 2 of the License is applicable.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
2016-08-18 20:28:22 -05:00
function load_graph_definitions_local($logarithmic = false, $tinylegend = false)
{
global $GraphDefs, $MetaGraphDefs;
2009-04-29 15:07:28 +00:00
2016-08-18 20:28:22 -05:00
// Define 1-rrd Graph definitions here
2020-09-21 15:40:17 +02:00
$GraphDefs['local_type'] = [
2016-08-18 20:28:22 -05:00
'-v', 'Commits',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'DEF:max={file}:value:MAX',
2020-09-21 15:59:34 +02:00
'AREA:max#B7B7F7',
'AREA:min#FFFFFF',
'LINE1:avg#0000FF:Commits',
2016-08-18 20:28:22 -05:00
'GPRINT:min:MIN:%6.1lf Min,',
'GPRINT:avg:AVERAGE:%6.1lf Avg,',
'GPRINT:max:MAX:%6.1lf Max,',
2020-09-21 15:40:17 +02:00
'GPRINT:avg:LAST:%6.1lf Last\l', ];
2009-04-29 15:07:28 +00:00
2016-08-18 20:28:22 -05:00
// Define MetaGraph definition type -> function mappings here
$MetaGraphDefs['local_meta'] = 'meta_graph_local';
2009-04-29 15:07:28 +00:00
}
2020-09-21 15:40:17 +02:00
function meta_graph_local($host, $plugin, $plugin_instance, $type, $type_instances, $opts = [])
2016-08-18 20:28:22 -05:00
{
2020-09-21 15:40:17 +02:00
$sources = [];
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
$title = "$host/$plugin" . (! is_null($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
if (! isset($opts['title'])) {
2016-08-18 20:28:22 -05:00
$opts['title'] = $title;
}
2020-09-21 15:40:17 +02:00
$opts['rrd_opts'] = ['-v', 'Events'];
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
$files = [];
/* $opts['colors'] = array(
'ham' => '00e000',
'spam' => '0000ff',
'malware' => '990000',
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
'sent' => '00e000',
'deferred' => 'a0e000',
'reject' => 'ff0000',
'bounced' => 'a00050'
);
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
$type_instances = array('ham', 'spam', 'malware', 'sent', 'deferred', 'reject', 'bounced'); */
2016-08-18 20:28:22 -05:00
foreach ($type_instances as $inst) {
2020-09-21 15:40:17 +02:00
$file = '';
2019-06-23 00:29:12 -05:00
foreach (\LibreNMS\Config::get('datadirs') as $datadir) {
2020-09-21 15:40:17 +02:00
if (is_file($datadir . '/' . $title . '-' . $inst . '.rrd')) {
$file = $datadir . '/' . $title . '-' . $inst . '.rrd';
2016-08-18 20:28:22 -05:00
break;
}
}
if ($file == '') {
continue;
}
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
$sources[] = ['name'=>$inst, 'file'=>$file];
2016-08-18 20:28:22 -05:00
}
2009-04-29 15:07:28 +00:00
2020-09-21 15:40:17 +02:00
// return collectd_draw_meta_stack($opts, $sources);
2016-08-18 20:28:22 -05:00
return collectd_draw_meta_line($opts, $sources);
2009-04-29 15:07:28 +00:00
}