New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Send collected data to graphite server #6201
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c89856e
Initial support for graphite
fstern 37cd04c
Enable graphite include
fstern e09e098
fixed typos.
fstern 360774e
Fixed port naming to graphite metric names
fstern 0dcd9d4
Added documentation for Graphite
fstern 39664df
added documentation for graphite
fstern eef3a3e
fixed style
fstern a93e024
replace / with _ in interface names for graphite
fstern e8db08c
sets default graphite port
fstern 5f71a10
adds rrd-name tags to the metric, otherwise metrics get lost
fstern 778d647
add suggested storage schema for graphite
fstern 4550b93
add whitespace
fstern 5f42205
Updated to show some output
laf 59e74d8
bad english
laf File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
source: Extensions/Graphite.md | ||
# Enabling support for Graphite. | ||
|
||
This module sends all metrics to a remote graphite service. You need something like Grafana for graphing. | ||
|
||
### What you don't get | ||
- Pretty graphs, this is why at present you need Grafana. You need to build your own graphs within Grafana. | ||
|
||
RRD will continue to function as normal so LibreNMS itself should continue to function as normal. | ||
|
||
### Configuration | ||
```php | ||
$config['graphite']['enable'] = true; | ||
$config['graphite']['host'] = 'your.graphite.server'; | ||
$config['graphite']['port'] = 2003; // this defaults to 2003 and is usually not needed | ||
$config['graphite']['prefix'] = 'your.metric.prefix'; | ||
``` | ||
|
||
Your metric path can be prefixed if required, otherwise the metric path for Graphite will be in the form of | ||
`hostname.measurement.fieldname`, interfaces will be stored as `hostname.ports.ifName.fieldname`. | ||
|
||
The same data then stored within rrd will be sent to Graphite and recorded. You can then create graphs within Grafana | ||
to display the information you need. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* LibreNMS | ||
* | ||
* Copyright (c) 2017 Falk Stern <https://github.com/fstern/ > | ||
* | ||
* 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, either version 3 of the License, or (at your | ||
* option) any later version. Please see LICENSE.txt at the top level of | ||
* the source code distribution for details. | ||
*/ | ||
|
||
function graphite_update($device, $measurement, $tags, $fields) | ||
{ | ||
global $graphite, $config; | ||
if ($graphite !== false) { | ||
$timestamp = time(); | ||
$graphite_prefix = $config['graphite']['prefix']; | ||
// metrics will be built as prefix.hostname.measurement.field value timestamp | ||
// metric fields can not contain . as this is used by graphite as a field separator | ||
$hostname = preg_replace('/\./', '_', $device['hostname']); | ||
$measurement = preg_replace(array('/\./', '/\//'), '_', $measurement); | ||
$measurement = preg_replace('/\|/', '.', $measurement); | ||
foreach ($fields as $k => $v) { | ||
$metric = implode(".", array_filter(array($graphite_prefix, $hostname, $measurement, $k))); | ||
$line = implode(" ", array($metric, $v, $timestamp)); | ||
d_echo("Sending $line\n"); | ||
fwrite($graphite, $line . "\n"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the default in includes/defaults.inc.php. This entire isset piece is then not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've moved it to includes/defaults.inc.php