mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Consolidate DB version code (#13111)
* Consilidate DB version and don't use dbConnected() function * cleanup imports
This commit is contained in:
@@ -28,6 +28,7 @@ use Dotenv\Dotenv;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Events\StatementPrepared;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use LibreNMS\Util\Laravel;
|
||||
|
||||
class Eloquent
|
||||
@@ -144,4 +145,9 @@ class Eloquent
|
||||
]);
|
||||
\Config::set('database.default', $name);
|
||||
}
|
||||
|
||||
public static function version($name = null)
|
||||
{
|
||||
return Arr::first(self::DB($name)->selectOne('select version()'));
|
||||
}
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ class Database extends BaseValidation
|
||||
|
||||
private function checkVersion(Validator $validator)
|
||||
{
|
||||
$version = Eloquent::DB()->selectOne('SELECT VERSION() as version')->version;
|
||||
$version = Eloquent::version();
|
||||
$version = explode('-', $version);
|
||||
|
||||
if (isset($version[1]) && $version[1] == 'MariaDB') {
|
||||
|
@@ -49,9 +49,9 @@ use App\Models\Syslog;
|
||||
use App\Models\Vlan;
|
||||
use App\Models\Vrf;
|
||||
use App\Models\WirelessSensor;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\DB\Eloquent;
|
||||
use LibreNMS\Util\Version;
|
||||
|
||||
class AboutController extends Controller
|
||||
@@ -71,7 +71,7 @@ class AboutController extends Controller
|
||||
'project_name' => Config::get('project_name'),
|
||||
|
||||
'version_local' => $version->local(),
|
||||
'version_mysql' => current(DB::selectOne('select version()')),
|
||||
'version_mysql' => Eloquent::version(),
|
||||
'version_php' => phpversion(),
|
||||
'version_laravel' => App::VERSION(),
|
||||
'version_python' => Version::python(),
|
||||
|
@@ -656,7 +656,7 @@ function version_info($remote = false)
|
||||
$output['db_schema'] = vsprintf('%s (%s)', $version->database());
|
||||
$output['php_ver'] = phpversion();
|
||||
$output['python_ver'] = \LibreNMS\Util\Version::python();
|
||||
$output['mysql_ver'] = dbIsConnected() ? dbFetchCell('SELECT version()') : '?';
|
||||
$output['mysql_ver'] = \LibreNMS\DB\Eloquent::isConnected() ? \LibreNMS\DB\Eloquent::version() : '?';
|
||||
$output['rrdtool_ver'] = 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)));
|
||||
|
Reference in New Issue
Block a user