mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add system validation (#12337)
validate lnms link and completion validate log rotation file is installed
This commit is contained in:
57
LibreNMS/Validations/System.php
Normal file
57
LibreNMS/Validations/System.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*
|
||||
* System.php
|
||||
*
|
||||
* Validate system items
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2020 Tony Murray
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Validations;
|
||||
|
||||
use LibreNMS\Validator;
|
||||
|
||||
class System extends BaseValidation
|
||||
{
|
||||
protected static $RUN_BY_DEFAULT = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate(Validator $validator)
|
||||
{
|
||||
$install_dir = $validator->getBaseDir();
|
||||
|
||||
$lnms = `which lnms 2>/dev/null`;
|
||||
if (empty($lnms)) {
|
||||
$validator->warn('Global lnms shortcut not installed. lnms command must be run with full path', "sudo ln -s $install_dir/lnms /usr/local/bin/lnms");
|
||||
}
|
||||
|
||||
$bash_completion_dir = '/etc/bash_completion.d/';
|
||||
$completion_file = 'lnms-completion.bash';
|
||||
if (is_dir($bash_completion_dir) && ! file_exists("$bash_completion_dir$completion_file")) {
|
||||
$validator->warn('Bash completion not installed. lnms command tab completion unavailable.', "sudo cp $install_dir/misc/lnms-completion.bash $bash_completion_dir");
|
||||
}
|
||||
|
||||
$rotation_file = '/etc/logrotate.d/librenms';
|
||||
if (! file_exists($rotation_file)) {
|
||||
$validator->warn('Log rotation not enabled, could cause disk space issues', "sudo cp $install_dir/misc/librenms.logrotate $rotation_file");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ if (isset($options['h'])) {
|
||||
- poller: check that the poller and discovery are running properly
|
||||
- programs: check that external programs exist and are executable
|
||||
- python: check that various Python modules and functions exist
|
||||
- system: checks system related items
|
||||
- updates: checks the status of git and updates
|
||||
- user: check that the LibreNMS user is set properly
|
||||
|
||||
|
||||
Reference in New Issue
Block a user