Collectd graph bug fix (#8855)

- fix graph color handling bug
- fix graph listing when metagraph exists
- show collectd metric name (plugin and type) in title

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
KOMEDA Shinji
2018-07-07 22:27:46 +09:00
committed by Neil Lathwood
parent f22e1a6ba6
commit d6c54af9e1
3 changed files with 16 additions and 5 deletions

View File

@@ -55,13 +55,14 @@ class CollectdColor
$value,
$matches
)) {
$this->r = (('0x' . $matches[1]) / 255.0);
$this->g = (('0x' . $matches[2]) / 255.0);
$this->b = (('0x' . $matches[3]) / 255.0);
$this->r = (hexdec('0x' . $matches[1]) / 255.0);
$this->g = (hexdec('0x' . $matches[2]) / 255.0);
$this->b = (hexdec('0x' . $matches[3]) / 255.0);
}
}
} else {
if (is_a($value, 'CollectdColor')) {
if (is_a($value, 'CollectdColor') ||
is_a($value, 'LibreNMS\CollectdColor')) {
$this->r = $value->r;
$this->g = $value->g;
$this->b = $value->b;

View File

@@ -20,6 +20,7 @@ require 'includes/collectd/config.php';
require 'includes/collectd/functions.php';
require 'includes/collectd/definitions.php';
global $MetaGraphDefs;
load_graph_definitions();
@@ -86,7 +87,7 @@ foreach ($pinsts as &$instance) {
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
if ($MetaGraphDefs[$type]) {
$typeinstances = array($MetaGraphDefs[$type]);
$typeinstances = array('');
}
foreach ($typeinstances as &$tinst) {

View File

@@ -40,6 +40,15 @@ if (!$auth) {
} else {
if (isset($config['graph_types'][$type][$subtype]['descr'])) {
$title .= " :: " . $config['graph_types'][$type][$subtype]['descr'];
} elseif ($type == "device" && $subtype == "collectd") {
$title .= " :: " . ucfirst($subtype) . " :: " . $vars['c_plugin'];
if (isset($vars['c_plugin_instance'])) {
$title .= " - " . $vars['c_plugin_instance'];
}
$title .= " - " . $vars['c_type'];
if (isset($vars['c_type_instance'])) {
$title .= " - " . $vars['c_type_instance'];
}
} else {
$title .= " :: " . ucfirst($subtype);
}