Automatically set rrdtool_version once (#13327)

* Automatically set rrdtool_version once
on first run if not already set

* In about controller too
This commit is contained in:
Tony Murray
2021-10-04 16:05:42 -05:00
committed by GitHub
parent 681508f45b
commit b5b532fbc5
5 changed files with 46 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ use Exception;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use LibreNMS\Data\Store\Rrd;
use LibreNMS\DB\Eloquent; use LibreNMS\DB\Eloquent;
use LibreNMS\Util\Debug; use LibreNMS\Util\Debug;
use Log; use Log;
@@ -457,6 +458,10 @@ class Config
} }
} }
if (! self::has('rrdtool_version')) {
self::persist('rrdtool_version', Rrd::version());
}
self::populateTime(); self::populateTime();
// populate legacy DB credentials, just in case something external uses them. Maybe remove this later // populate legacy DB credentials, just in case something external uses them. Maybe remove this later

View File

@@ -661,6 +661,18 @@ class Rrd extends BaseDatastore
return $result . ' '; return $result . ' ';
} }
/**
* Run rrdtool and parse the version from the output.
*
* @return string
*/
public static function version(): string
{
return str_replace('1.7.01.7.0', '1.7.0', implode(' ', array_slice(explode(' ', shell_exec(
Config::get('rrdtool', 'rrdtool') . ' --version | head -n1'
)), 1, 1)));
}
/** /**
* Only track update and create primarily, just put all others in an "other" bin * Only track update and create primarily, just put all others in an "other" bin
* *

View File

@@ -52,6 +52,7 @@ use App\Models\Vrf;
use App\Models\WirelessSensor; use App\Models\WirelessSensor;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use LibreNMS\Config; use LibreNMS\Config;
use LibreNMS\Data\Store\Rrd;
use LibreNMS\DB\Eloquent; use LibreNMS\DB\Eloquent;
use LibreNMS\Util\Version; use LibreNMS\Util\Version;
@@ -67,29 +68,27 @@ class AboutController extends Controller
'callback_uuid' => $callback_status ? Callback::get('uuid') : null, 'callback_uuid' => $callback_status ? Callback::get('uuid') : null,
'db_schema' => vsprintf('%s (%s)', $version->database()), 'db_schema' => vsprintf('%s (%s)', $version->database()),
'git_log' => $version->gitChangelog(), 'git_log' => $version->gitChangelog(),
'git_date' => $version->gitDate(), 'git_date' => $version->gitDate(),
'project_name' => Config::get('project_name'), 'project_name' => Config::get('project_name'),
'version_local' => $version->local(), 'version_local' => $version->local(),
'version_mysql' => Eloquent::version(), 'version_mysql' => Eloquent::version(),
'version_php' => phpversion(), 'version_php' => phpversion(),
'version_laravel' => App::VERSION(), 'version_laravel' => App::VERSION(),
'version_python' => Version::python(), 'version_python' => Version::python(),
'version_webserver' => $request->server('SERVER_SOFTWARE'), 'version_webserver' => $request->server('SERVER_SOFTWARE'),
'version_rrdtool' => str_replace('1.7.01.7.0', '1.7.0', implode(' ', array_slice(explode(' ', shell_exec( 'version_rrdtool' => Rrd::version(),
Config::get('rrdtool', 'rrdtool') . ' --version | head -n1' 'version_netsnmp' => str_replace('version: ', '', rtrim(shell_exec(Config::get('snmpget', 'snmpget') . ' -V 2>&1'))),
)), 1, 1))),
'version_netsnmp' => str_replace('version: ', '', rtrim(shell_exec(Config::get('snmpget', 'snmpget') . ' -V 2>&1'))),
'stat_apps' => Application::count(), 'stat_apps' => Application::count(),
'stat_devices' => Device::count(), 'stat_devices' => Device::count(),
'stat_diskio' => DiskIo::count(), 'stat_diskio' => DiskIo::count(),
'stat_entphys' => EntPhysical::count(), 'stat_entphys' => EntPhysical::count(),
'stat_events' => Eventlog::count(), 'stat_events' => Eventlog::count(),
'stat_hrdev' => HrDevice::count(), 'stat_hrdev' => HrDevice::count(),
'stat_ipv4_addy' => Ipv4Address::count(), 'stat_ipv4_addy' => Ipv4Address::count(),
'stat_ipv4_nets' => Ipv4Network::count(), 'stat_ipv4_nets' => Ipv4Network::count(),
'stat_ipv6_addy' => Ipv6Address::count(), 'stat_ipv6_addy' => Ipv6Address::count(),
'stat_ipv6_nets' => Ipv6Network::count(), 'stat_ipv6_nets' => Ipv6Network::count(),
'stat_memory' => Mempool::count(), 'stat_memory' => Mempool::count(),

View File

@@ -4887,6 +4887,13 @@
"order": 1, "order": 1,
"type": "boolean" "type": "boolean"
}, },
"rrdtool_version": {
"default": null,
"group": "poller",
"section": "rrdtool",
"order": 12,
"type": "text"
},
"sensors.guess_limits": { "sensors.guess_limits": {
"default": true, "default": true,
"type": "boolean" "type": "boolean"

View File

@@ -1238,6 +1238,10 @@ return [
'description' => 'Tune all rrd port files to use max values', 'description' => 'Tune all rrd port files to use max values',
'help' => 'Auto tune maximum value for rrd port files', 'help' => 'Auto tune maximum value for rrd port files',
], ],
'rrdtool_version' => [
'description' => 'Sets the version of rrdtool on your server',
'help' => 'Anything over 1.5.5 supports all features LibreNMS uses, do not set higher than your installed version',
],
'sfdp' => [ 'sfdp' => [
'description' => 'Path to sfdp', 'description' => 'Path to sfdp',
], ],