From c0125f28e408d3410b48205258c8aa0ba70da5d6 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 23 Aug 2015 19:36:22 +0000 Subject: [PATCH 1/2] Added support for rrdtool 1.5 --- doc/Extensions/Distributed-Poller.md | 21 +++++++++++++++++++-- doc/Extensions/RRDCached.md | 15 +++++++++++---- includes/defaults.inc.php | 1 + includes/rrdtool.inc.php | 16 ++-------------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/doc/Extensions/Distributed-Poller.md b/doc/Extensions/Distributed-Poller.md index 86163b644..e6c3e2c9d 100644 --- a/doc/Extensions/Distributed-Poller.md +++ b/doc/Extensions/Distributed-Poller.md @@ -5,7 +5,11 @@ These machines can be in a different physical location and therefore minimize ne Devices can also be groupped together into a `poller_group` to pin these devices to a single or a group of designated pollers. -All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached. +~~All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached.~~ + +> This is no longer a strict requirement with the use of rrdtool 1.5 and above. If you are NOT running 1.5 then you will still +need to share the RRD-folder. + It is also required that all pollers can access the central memcached to communicate with eachother. In order to enable distributed polling, set `$config['distributed_poller'] = true` and your memcached details into `$config['distributed_poller_memcached_host']` and `$config['distributed_poller_memcached_port']`. @@ -49,7 +53,14 @@ The pollers, web and API layers should all be able to access the database server ####RRD Storage Central storage should be provided so all RRD files can be read from and written to in one location. As suggested above, it's recommended that RRD Cached is configured and used. -For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles with the rrd directory also exported by NFS for simple access and maintenance. +For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles ~~with the rrd directory also exported by NFS for simple access and maintenance.~~ + +Sharing rrd files via something like NFS is no longer required if you run rrdtool 1.5 or greater. If you don't - please share your rrd folder as before. If you run rrdtool +1.5 or greater then add this config to your pollers: + +```php +$config['rrdtool_version'] = 1.5; +``` ####Memcache Memcache is required for the distributed pollers to be able to register to a central location and record what devices are polled. Memcache can run from any of the kit so long as it is accessable by all pollers. @@ -88,4 +99,10 @@ $config['rrd_dir'] = "/opt/librenms/rrd"; $config['rrdcached_dir'] = ""; ``` +For rrdtool 1.5 or greater then you can enable support for rrdcached to create the rrd files: + +```php +$config['rrdtool_version'] = 1.5; +``` + $config['rrdcached_dir'] Is only needed if you are using tcp connections for rrd cached and needs only to be set if you want to store rrd files within a sub directory of your rrdcached base directory. diff --git a/doc/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index 27a157c5d..1459235c6 100644 --- a/doc/Extensions/RRDCached.md +++ b/doc/Extensions/RRDCached.md @@ -6,19 +6,19 @@ This document will explain how to setup RRDCached for LibreNMS. This example is based on a fresh LibreNMS install, on a minimimal CentOS installation. In this example, we'll use the Repoforge repository. -```ssh +```php rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm vi /etc/yum.repos.d/rpmforge.repo ``` - Enable the Extra repo -```ssh +```php yum update rrdtool vi /etc/yum.repos.d/rpmforge.repo ``` - Disable the [rpmforge] and [rpmforge-extras] repos again -```ssh +```php vi /etc/sysconfig/rrdcached # Settings for rrdcached @@ -34,6 +34,13 @@ service rrdcached start ``` Edit config.php to include: -```ssh +```php $config['rrdcached'] = "unix:/var/run/rrdcached/rrdcached.sock"; ``` + +> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To +enable this set the following config: + +```php +$config['rrdtool_version'] = 1.5; +``` diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 66ca1fcea..9f370381a 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -51,6 +51,7 @@ $config['own_hostname'] = 'localhost'; // Location of executables $config['rrdtool'] = '/usr/bin/rrdtool'; +$config['rrdtool_version'] = 1.4; // Doesn't need to contain minor numbers. $config['fping'] = '/usr/bin/fping'; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index a8a7e9936..3e09d523b 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -166,7 +166,7 @@ function rrdtool_graph($graph_file, $options) { function rrdtool($command, $filename, $options) { global $config, $debug, $rrd_pipes, $console_color; - if ($command != 'create' && $config['rrdcached']) { + if ($config['rrdtool_version'] >= 1.5 && $config['rrdcached']) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); $filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename); @@ -206,19 +206,7 @@ function rrdtool($command, $filename, $options) { function rrdtool_create($filename, $options) { - global $config, $console_color; - - if ($config['norrd']) { - print $console_color->convert('[%gRRD Disabled%n] ', false); - } - else { - $command = $config['rrdtool']." create $filename $options"; - } - - d_echo($console_color->convert('RRD[%g'.$command.'%n] ')); - - return shell_exec($command); - + return rrdtool('create', $filename, $options); } From 4d9163c9ecc964d1a8536ab44f931b4de0a2c052 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 24 Aug 2015 19:14:30 +0000 Subject: [PATCH 2/2] Make network graphs compatible with 1.4.x and 1.5.x rrdtool --- html/includes/graphs/generic_multi_seperated.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/html/includes/graphs/generic_multi_seperated.inc.php b/html/includes/graphs/generic_multi_seperated.inc.php index ce0a9472b..9b37f3751 100644 --- a/html/includes/graphs/generic_multi_seperated.inc.php +++ b/html/includes/graphs/generic_multi_seperated.inc.php @@ -74,7 +74,7 @@ foreach ($rrd_list as $rrd) { $stack = 'STACK'; } - $rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In ':$stack"; + $rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In '$stack"; $rrd_options .= ' GPRINT:inbits'.$i.':LAST:%6.2lf%s'; $rrd_options .= ' GPRINT:inbits'.$i.':AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:inbits'.$i.':MAX:%6.2lf%s'; @@ -84,8 +84,8 @@ foreach ($rrd_list as $rrd) { } $rrd_options .= " COMMENT:'\\n'"; - $rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out."::$stack"; - $rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out':"; + $rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out.":$stack"; + $rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out'"; $rrd_options .= ' GPRINT:outbits'.$i.':LAST:%6.2lf%s'; $rrd_options .= ' GPRINT:outbits'.$i.':AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:outbits'.$i.':MAX:%6.2lf%s'; @@ -141,21 +141,21 @@ if (!$args['nototal']) { $rrd_options .= " COMMENT:' \\n'"; - $rrd_options .= " HRULE:999999999999999#FFFFFF:'".str_pad('Total', 10)."In ':"; + $rrd_options .= " HRULE:999999999999999#FFFFFF:'".str_pad('Total', 10)."In '"; $rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s'; $rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s'; $rrd_options .= " GPRINT:totin:%6.2lf%s$total_units"; $rrd_options .= " COMMENT:'\\n'"; - $rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Out':"; + $rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Out'"; $rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s'; $rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s'; $rrd_options .= " GPRINT:totout:%6.2lf%s$total_units"; $rrd_options .= " COMMENT:'\\n'"; - $rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Agg':"; + $rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Agg'"; $rrd_options .= ' GPRINT:bits:LAST:%6.2lf%s'; $rrd_options .= ' GPRINT:bits:AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:bits:MAX:%6.2lf%s';