mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove Laravel helpers (#11428)
* Remove Laravel helpers * Replace qualifier with import
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Alert;
|
namespace LibreNMS\Alert;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\Alert\Transport as TransportInterface;
|
use LibreNMS\Interfaces\Alert\Transport as TransportInterface;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ abstract class Transport implements TransportInterface
|
|||||||
{
|
{
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach (explode(PHP_EOL, $input) as $option) {
|
foreach (explode(PHP_EOL, $input) as $option) {
|
||||||
if (str_contains($option, '=')) {
|
if (Str::contains($option, '=')) {
|
||||||
list($k,$v) = explode('=', $option, 2);
|
list($k,$v) = explode('=', $option, 2);
|
||||||
$options[$k] = trim($v);
|
$options[$k] = trim($v);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace LibreNMS\Alert\Transport;
|
namespace LibreNMS\Alert\Transport;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Alert\Transport;
|
use LibreNMS\Alert\Transport;
|
||||||
|
|
||||||
class Smseagle extends Transport
|
class Smseagle extends Transport
|
||||||
@ -44,7 +45,7 @@ class Smseagle extends Transport
|
|||||||
'to' => implode(',', $opts['to']),
|
'to' => implode(',', $opts['to']),
|
||||||
'message' => $obj['title'],
|
'message' => $obj['title'],
|
||||||
];
|
];
|
||||||
$url = starts_with($opts['url'], 'http') ? '' : 'http://';
|
$url = Str::startsWith($opts['url'], 'http') ? '' : 'http://';
|
||||||
$url .= $opts['url'] . '/index.php/http_api/send_sms?' . http_build_query($params);
|
$url .= $opts['url'] . '/index.php/http_api/send_sms?' . http_build_query($params);
|
||||||
$curl = curl_init($url);
|
$curl = curl_init($url);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Alerting;
|
namespace LibreNMS\Alerting;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\DB\Schema;
|
use LibreNMS\DB\Schema;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -69,7 +70,7 @@ class QueryBuilderFilter implements \JsonSerializable
|
|||||||
continue; // don't include the time based macros, they don't work like that
|
continue; // don't include the time based macros, they don't work like that
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ends_with($key, '_usage_perc')) || (starts_with($key, 'packet_loss_'))) {
|
if ((Str::endsWith($key, '_usage_perc')) || (Str::startsWith($key, 'packet_loss_'))) {
|
||||||
$this->filter[$field] = [
|
$this->filter[$field] = [
|
||||||
'id' => $field,
|
'id' => $field,
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
@ -114,7 +115,7 @@ class QueryBuilderFilter implements \JsonSerializable
|
|||||||
|
|
||||||
$field = "$table.$column";
|
$field = "$table.$column";
|
||||||
|
|
||||||
if (ends_with($column, ['_perc', '_current', '_usage', '_perc_warn'])) {
|
if (Str::endsWith($column, ['_perc', '_current', '_usage', '_perc_warn'])) {
|
||||||
$this->filter[$field] = [
|
$this->filter[$field] = [
|
||||||
'id' => $field,
|
'id' => $field,
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
@ -145,14 +146,14 @@ class QueryBuilderFilter implements \JsonSerializable
|
|||||||
|
|
||||||
private function getColumnType($type)
|
private function getColumnType($type)
|
||||||
{
|
{
|
||||||
if (starts_with($type, ['varchar', 'text', 'double', 'float'])) {
|
if (Str::startsWith($type, ['varchar', 'text', 'double', 'float'])) {
|
||||||
return 'string';
|
return 'string';
|
||||||
} elseif (starts_with($type, ['int', 'tinyint', 'smallint', 'mediumint', 'bigint'])) {
|
} elseif (Str::startsWith($type, ['int', 'tinyint', 'smallint', 'mediumint', 'bigint'])) {
|
||||||
//TODO implement field selection and change back to integer
|
//TODO implement field selection and change back to integer
|
||||||
return 'string';
|
return 'string';
|
||||||
} elseif (starts_with($type, ['timestamp', 'datetime'])) {
|
} elseif (Str::startsWith($type, ['timestamp', 'datetime'])) {
|
||||||
return 'datetime';
|
return 'datetime';
|
||||||
} elseif (starts_with($type, 'enum')) {
|
} elseif (Str::startsWith($type, 'enum')) {
|
||||||
return 'enum';
|
return 'enum';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace LibreNMS\Alerting;
|
|||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
class QueryBuilderFluentParser extends QueryBuilderParser
|
class QueryBuilderFluentParser extends QueryBuilderParser
|
||||||
@ -132,14 +133,14 @@ class QueryBuilderFluentParser extends QueryBuilderParser
|
|||||||
protected function expandRule($rule)
|
protected function expandRule($rule)
|
||||||
{
|
{
|
||||||
$field = $rule['field'];
|
$field = $rule['field'];
|
||||||
if (starts_with($field, 'macros.')) {
|
if (Str::startsWith($field, 'macros.')) {
|
||||||
$field = DB::raw($this->expandMacro($field));
|
$field = DB::raw($this->expandMacro($field));
|
||||||
}
|
}
|
||||||
|
|
||||||
$op = $rule['operator'];
|
$op = $rule['operator'];
|
||||||
|
|
||||||
$value = $rule['value'];
|
$value = $rule['value'];
|
||||||
if (!is_array($value) && starts_with($value, '`') && ends_with($value, '`')) {
|
if (!is_array($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
|
||||||
$value = DB::raw($this->expandMacro(trim($value, '`')));
|
$value = DB::raw($this->expandMacro(trim($value, '`')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ class QueryBuilderFluentParser extends QueryBuilderParser
|
|||||||
$joins = [];
|
$joins = [];
|
||||||
foreach ($this->generateGlue() as $glue) {
|
foreach ($this->generateGlue() as $glue) {
|
||||||
list($left, $right) = explode(' = ', $glue, 2);
|
list($left, $right) = explode(' = ', $glue, 2);
|
||||||
if (str_contains($right, '.')) { // last line is devices.device_id = ? for alerting... ignore it
|
if (Str::contains($right, '.')) { // last line is devices.device_id = ? for alerting... ignore it
|
||||||
list($leftTable, $leftKey) = explode('.', $left);
|
list($leftTable, $leftKey) = explode('.', $left);
|
||||||
list($rightTable, $rightKey) = explode('.', $right);
|
list($rightTable, $rightKey) = explode('.', $right);
|
||||||
$target_table = ($rightTable != 'devices' ? $rightTable : $leftTable); // don't try to join devices
|
$target_table = ($rightTable != 'devices' ? $rightTable : $leftTable); // don't try to join devices
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Alerting;
|
namespace LibreNMS\Alerting;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\DB\Schema;
|
use LibreNMS\DB\Schema;
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
foreach ($rules['rules'] as $rule) {
|
foreach ($rules['rules'] as $rule) {
|
||||||
if (array_key_exists('rules', $rule)) {
|
if (array_key_exists('rules', $rule)) {
|
||||||
$tables = array_merge($this->findTablesRecursive($rule), $tables);
|
$tables = array_merge($this->findTablesRecursive($rule), $tables);
|
||||||
} elseif (str_contains($rule['field'], '.')) {
|
} elseif (Str::contains($rule['field'], '.')) {
|
||||||
list($table, $column) = explode('.', $rule['field']);
|
list($table, $column) = explode('.', $rule['field']);
|
||||||
|
|
||||||
if ($table == 'macros') {
|
if ($table == 'macros') {
|
||||||
@ -188,7 +189,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
$value = '1';
|
$value = '1';
|
||||||
} else {
|
} else {
|
||||||
// value is a field, mark it with backticks
|
// value is a field, mark it with backticks
|
||||||
if (starts_with($value, '%')) {
|
if (Str::startsWith($value, '%')) {
|
||||||
$value = '`' . ltrim($value, '%') . '`';
|
$value = '`' . ltrim($value, '%') . '`';
|
||||||
} else {
|
} else {
|
||||||
// but if it has quotes just remove the %
|
// but if it has quotes just remove the %
|
||||||
@ -295,7 +296,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
$op = self::$operators[$builder_op];
|
$op = self::$operators[$builder_op];
|
||||||
$value = $rule['value'];
|
$value = $rule['value'];
|
||||||
|
|
||||||
if (is_string($value) && starts_with($value, '`') && ends_with($value, '`')) {
|
if (is_string($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
|
||||||
// pass through value such as field
|
// pass through value such as field
|
||||||
$value = trim($value, '`');
|
$value = trim($value, '`');
|
||||||
if ($expand) {
|
if ($expand) {
|
||||||
@ -329,14 +330,14 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
*/
|
*/
|
||||||
protected function expandMacro($subject, $tables_only = false, $depth_limit = 20)
|
protected function expandMacro($subject, $tables_only = false, $depth_limit = 20)
|
||||||
{
|
{
|
||||||
if (!str_contains($subject, 'macros.')) {
|
if (!Str::contains($subject, 'macros.')) {
|
||||||
return $subject;
|
return $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
$macros = Config::get('alert.macros.rule');
|
$macros = Config::get('alert.macros.rule');
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while ($count++ < $depth_limit && str_contains($subject, 'macros.')) {
|
while ($count++ < $depth_limit && Str::contains($subject, 'macros.')) {
|
||||||
$subject = preg_replace_callback('/%?macros.([^ =()]+)/', function ($matches) use ($macros) {
|
$subject = preg_replace_callback('/%?macros.([^ =()]+)/', function ($matches) use ($macros) {
|
||||||
$name = $matches[1];
|
$name = $matches[1];
|
||||||
if (isset($macros[$name])) {
|
if (isset($macros[$name])) {
|
||||||
@ -356,7 +357,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
$subject = preg_replace('/%([^%.]+)\./', '$1.', $subject);
|
$subject = preg_replace('/%([^%.]+)\./', '$1.', $subject);
|
||||||
|
|
||||||
// wrap entire macro result in parenthesis if needed
|
// wrap entire macro result in parenthesis if needed
|
||||||
if (!(starts_with($subject, '(') && ends_with($subject, ')'))) {
|
if (!(Str::startsWith($subject, '(') && Str::endsWith($subject, ')'))) {
|
||||||
$subject = "($subject)";
|
$subject = "($subject)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +407,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
$this->schema->getColumns($parent),
|
$this->schema->getColumns($parent),
|
||||||
$this->schema->getColumns($child)
|
$this->schema->getColumns($child)
|
||||||
), function ($table) {
|
), function ($table) {
|
||||||
return ends_with($table, '_id');
|
return Str::endsWith($table, '_id');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (count($shared_keys) === 1) {
|
if (count($shared_keys) === 1) {
|
||||||
@ -425,7 +426,7 @@ class QueryBuilderParser implements \JsonSerializable
|
|||||||
|
|
||||||
if (!$this->schema->columnExists($child, $child_key)) {
|
if (!$this->schema->columnExists($child, $child_key)) {
|
||||||
// if they don't match, guess the column name from the parent
|
// if they don't match, guess the column name from the parent
|
||||||
if (ends_with($parent, 'xes')) {
|
if (Str::endsWith($parent, 'xes')) {
|
||||||
$child_key = substr($parent, 0, -2) . '_id';
|
$child_key = substr($parent, 0, -2) . '_id';
|
||||||
} else {
|
} else {
|
||||||
$child_key = preg_replace('/s$/', '_id', $parent);
|
$child_key = preg_replace('/s$/', '_id', $parent);
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Authentication;
|
namespace LibreNMS\Authentication;
|
||||||
|
|
||||||
use App\Models\Notification;
|
|
||||||
use App\Models\NotificationAttrib;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\DB\Eloquent;
|
use LibreNMS\DB\Eloquent;
|
||||||
use LibreNMS\Exceptions\AuthenticationException;
|
use LibreNMS\Exceptions\AuthenticationException;
|
||||||
use Phpass\PasswordHash;
|
use Phpass\PasswordHash;
|
||||||
@ -35,13 +34,13 @@ class MysqlAuthorizer extends AuthorizerBase
|
|||||||
$this->changePassword($username, $password);
|
$this->changePassword($username, $password);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif (starts_with($hash, '$1$')) {
|
} elseif (Str::startsWith($hash, '$1$')) {
|
||||||
// old md5 crypt
|
// old md5 crypt
|
||||||
if (crypt($password, $hash) == $hash) {
|
if (crypt($password, $hash) == $hash) {
|
||||||
$this->changePassword($username, $password);
|
$this->changePassword($username, $password);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif (starts_with($hash, '$P$')) {
|
} elseif (Str::startsWith($hash, '$P$')) {
|
||||||
// Phpass
|
// Phpass
|
||||||
$hasher = new PasswordHash();
|
$hasher = new PasswordHash();
|
||||||
if ($hasher->CheckPassword($password, $hash)) {
|
if ($hasher->CheckPassword($password, $hash)) {
|
||||||
|
@ -29,6 +29,7 @@ use App\Models\GraphType;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\DB\Eloquent;
|
use LibreNMS\DB\Eloquent;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class Config
|
|||||||
return self::$config[$key];
|
return self::$config[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str_contains($key, '.')) {
|
if (!Str::contains($key, '.')) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ class Config
|
|||||||
return self::$config['os'][$os][$key];
|
return self::$config['os'][$os][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str_contains($key, '.')) {
|
if (!Str::contains($key, '.')) {
|
||||||
return self::get($key, $default);
|
return self::get($key, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +214,7 @@ class Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$config['os'][$os][$key])) {
|
if (!isset(self::$config['os'][$os][$key])) {
|
||||||
if (!str_contains($key, '.')) {
|
if (!Str::contains($key, '.')) {
|
||||||
return self::get($key, $default);
|
return self::get($key, $default);
|
||||||
}
|
}
|
||||||
if (!self::has("os.$os.$key")) {
|
if (!self::has("os.$os.$key")) {
|
||||||
@ -298,7 +299,7 @@ class Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str_contains($key, '.')) {
|
if (!Str::contains($key, '.')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +386,7 @@ class Config
|
|||||||
if (isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT'])) {
|
if (isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT'])) {
|
||||||
$port = $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '';
|
$port = $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '';
|
||||||
// handle literal IPv6
|
// handle literal IPv6
|
||||||
$server = str_contains($_SERVER['SERVER_NAME'], ':') ? "[{$_SERVER['SERVER_NAME']}]" : $_SERVER['SERVER_NAME'];
|
$server = Str::contains($_SERVER['SERVER_NAME'], ':') ? "[{$_SERVER['SERVER_NAME']}]" : $_SERVER['SERVER_NAME'];
|
||||||
Arr::set(self::$config, 'base_url', "http://$server$port/");
|
Arr::set(self::$config, 'base_url', "http://$server$port/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +535,7 @@ class Config
|
|||||||
*/
|
*/
|
||||||
public static function locateBinary($binary)
|
public static function locateBinary($binary)
|
||||||
{
|
{
|
||||||
if (!str_contains($binary, '/')) {
|
if (!Str::contains($binary, '/')) {
|
||||||
$output = `whereis -b $binary`;
|
$output = `whereis -b $binary`;
|
||||||
$list = trim(substr($output, strpos($output, ':') + 1));
|
$list = trim(substr($output, strpos($output, ':') + 1));
|
||||||
$targets = explode(' ', $list);
|
$targets = explode(' ', $list);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\DB;
|
namespace LibreNMS\DB;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Util\Version;
|
use LibreNMS\Util\Version;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -274,7 +275,7 @@ class Schema
|
|||||||
|
|
||||||
public function getTableFromKey($key)
|
public function getTableFromKey($key)
|
||||||
{
|
{
|
||||||
if (ends_with($key, '_id')) {
|
if (Str::endsWith($key, '_id')) {
|
||||||
// hardcoded
|
// hardcoded
|
||||||
if ($key == 'app_id') {
|
if ($key == 'app_id') {
|
||||||
return 'applications';
|
return 'applications';
|
||||||
@ -283,8 +284,8 @@ class Schema
|
|||||||
// try to guess assuming key_id = keys table
|
// try to guess assuming key_id = keys table
|
||||||
$guessed_table = substr($key, 0, -3);
|
$guessed_table = substr($key, 0, -3);
|
||||||
|
|
||||||
if (!ends_with($guessed_table, 's')) {
|
if (!Str::endsWith($guessed_table, 's')) {
|
||||||
if (ends_with($guessed_table, 'x')) {
|
if (Str::endsWith($guessed_table, 'x')) {
|
||||||
$guessed_table .= 'es';
|
$guessed_table .= 'es';
|
||||||
} else {
|
} else {
|
||||||
$guessed_table .= 's';
|
$guessed_table .= 's';
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Data\Store;
|
namespace LibreNMS\Data\Store;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Data\Measure\Measurement;
|
use LibreNMS\Data\Measure\Measurement;
|
||||||
use LibreNMS\Exceptions\FileExistsException;
|
use LibreNMS\Exceptions\FileExistsException;
|
||||||
@ -439,7 +440,7 @@ class Rrd extends BaseDatastore
|
|||||||
if ($this->rrdcached && version_compare($this->version, '1.5', '>=')) {
|
if ($this->rrdcached && version_compare($this->version, '1.5', '>=')) {
|
||||||
$chk = $this->command('last', $filename, '');
|
$chk = $this->command('last', $filename, '');
|
||||||
$filename = str_replace([$this->rrd_dir . '/', $this->rrd_dir], '', $filename);
|
$filename = str_replace([$this->rrd_dir . '/', $this->rrd_dir], '', $filename);
|
||||||
return !str_contains(implode($chk), "$filename': No such file or directory");
|
return !Str::contains(implode($chk), "$filename': No such file or directory");
|
||||||
} else {
|
} else {
|
||||||
return is_file($filename);
|
return is_file($filename);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Device;
|
namespace LibreNMS\Device;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
||||||
use LibreNMS\Interfaces\Discovery\DiscoveryModule;
|
use LibreNMS\Interfaces\Discovery\DiscoveryModule;
|
||||||
@ -91,7 +92,7 @@ class Processor extends Model implements DiscoveryModule, PollerModule, Discover
|
|||||||
$proc->hrDeviceIndex = $hrDeviceIndex;
|
$proc->hrDeviceIndex = $hrDeviceIndex;
|
||||||
|
|
||||||
// handle string indexes
|
// handle string indexes
|
||||||
if (str_contains($oid, '"')) {
|
if (Str::contains($oid, '"')) {
|
||||||
$oid = preg_replace_callback('/"([^"]+)"/', function ($matches) {
|
$oid = preg_replace_callback('/"([^"]+)"/', function ($matches) {
|
||||||
return string_to_oid($matches[1]);
|
return string_to_oid($matches[1]);
|
||||||
}, $oid);
|
}, $oid);
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Device;
|
namespace LibreNMS\Device;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ class YamlDiscovery
|
|||||||
foreach ($data as $name => $value) {
|
foreach ($data as $name => $value) {
|
||||||
if ($name == '$oid' || $name == 'skip_values') {
|
if ($name == '$oid' || $name == 'skip_values') {
|
||||||
$current_data[$name] = $value;
|
$current_data[$name] = $value;
|
||||||
} elseif (str_contains($value, '{{')) {
|
} elseif (Str::contains($value, '{{')) {
|
||||||
// replace embedded values
|
// replace embedded values
|
||||||
$current_data[$name] = static::replaceValues($name, $index, $count, $data, $pre_cache);
|
$current_data[$name] = static::replaceValues($name, $index, $count, $data, $pre_cache);
|
||||||
} else {
|
} else {
|
||||||
@ -223,7 +225,7 @@ class YamlDiscovery
|
|||||||
foreach ((array)$data['oid'] as $oid) {
|
foreach ((array)$data['oid'] as $oid) {
|
||||||
if (!array_key_exists($oid, $pre_cache)) {
|
if (!array_key_exists($oid, $pre_cache)) {
|
||||||
if (isset($data['snmp_flags'])) {
|
if (isset($data['snmp_flags'])) {
|
||||||
$snmp_flag = array_wrap($data['snmp_flags']);
|
$snmp_flag = Arr::wrap($data['snmp_flags']);
|
||||||
} else {
|
} else {
|
||||||
$snmp_flag = ['-OteQUs'];
|
$snmp_flag = ['-OteQUs'];
|
||||||
}
|
}
|
||||||
@ -260,7 +262,7 @@ class YamlDiscovery
|
|||||||
// Dynamic skipping of data
|
// Dynamic skipping of data
|
||||||
$op = isset($skip_value['op']) ? $skip_value['op'] : '!=';
|
$op = isset($skip_value['op']) ? $skip_value['op'] : '!=';
|
||||||
$tmp_value = static::getValueFromData($skip_value['oid'], $index, $yaml_item_data, $pre_cache);
|
$tmp_value = static::getValueFromData($skip_value['oid'], $index, $yaml_item_data, $pre_cache);
|
||||||
if (str_contains($skip_value['oid'], '.')) {
|
if (Str::contains($skip_value['oid'], '.')) {
|
||||||
list($skip_value['oid'], $targeted_index) = explode('.', $skip_value['oid'], 2);
|
list($skip_value['oid'], $targeted_index) = explode('.', $skip_value['oid'], 2);
|
||||||
$tmp_value = static::getValueFromData($skip_value['oid'], $targeted_index, $yaml_item_data, $pre_cache);
|
$tmp_value = static::getValueFromData($skip_value['oid'], $targeted_index, $yaml_item_data, $pre_cache);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Exceptions;
|
namespace LibreNMS\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Interfaces\Exceptions\UpgradeableException;
|
use LibreNMS\Interfaces\Exceptions\UpgradeableException;
|
||||||
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
@ -41,8 +42,8 @@ class FilePermissionsException extends \Exception implements UpgradeableExceptio
|
|||||||
{
|
{
|
||||||
// cannot write to storage directory
|
// cannot write to storage directory
|
||||||
if ($exception instanceof \ErrorException &&
|
if ($exception instanceof \ErrorException &&
|
||||||
starts_with($exception->getMessage(), 'file_put_contents(') &&
|
Str::startsWith($exception->getMessage(), 'file_put_contents(') &&
|
||||||
str_contains($exception->getMessage(), '/storage/')) {
|
Str::contains($exception->getMessage(), '/storage/')) {
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class FilePermissionsException extends \Exception implements UpgradeableExceptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// monolog cannot init log file
|
// monolog cannot init log file
|
||||||
if ($exception instanceof \UnexpectedValueException && str_contains($exception->getFile(), 'Monolog/Handler/StreamHandler.php')) {
|
if ($exception instanceof \UnexpectedValueException && Str::contains($exception->getFile(), 'Monolog/Handler/StreamHandler.php')) {
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace LibreNMS;
|
namespace LibreNMS;
|
||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\WirelessSensor;
|
use LibreNMS\Device\WirelessSensor;
|
||||||
use LibreNMS\Device\YamlDiscovery;
|
use LibreNMS\Device\YamlDiscovery;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
@ -111,7 +112,7 @@ class OS implements ProcessorDiscovery
|
|||||||
*/
|
*/
|
||||||
public function getCacheByIndex($oid, $mib = null, $snmpflags = '-OQUs')
|
public function getCacheByIndex($oid, $mib = null, $snmpflags = '-OQUs')
|
||||||
{
|
{
|
||||||
if (str_contains($oid, '.')) {
|
if (Str::contains($oid, '.')) {
|
||||||
echo "Error: don't use this with numeric oids!\n";
|
echo "Error: don't use this with numeric oids!\n";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ class OS implements ProcessorDiscovery
|
|||||||
*/
|
*/
|
||||||
public function getCacheTable($oid, $mib = null, $depth = 1)
|
public function getCacheTable($oid, $mib = null, $depth = 1)
|
||||||
{
|
{
|
||||||
if (str_contains($oid, '.')) {
|
if (Str::contains($oid, '.')) {
|
||||||
echo "Error: don't use this with numeric oids!\n";
|
echo "Error: don't use this with numeric oids!\n";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\Processor;
|
use LibreNMS\Device\Processor;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
@ -42,7 +43,7 @@ class Dnos extends OS implements ProcessorDiscovery
|
|||||||
$device = $this->getDevice();
|
$device = $this->getDevice();
|
||||||
$processors = array();
|
$processors = array();
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.3')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.3')) {
|
||||||
d_echo('Dell S Series Chassis');
|
d_echo('Dell S Series Chassis');
|
||||||
$this->findProcessors(
|
$this->findProcessors(
|
||||||
$processors,
|
$processors,
|
||||||
@ -51,7 +52,7 @@ class Dnos extends OS implements ProcessorDiscovery
|
|||||||
'.1.3.6.1.4.1.6027.3.10.1.2.9.1.2',
|
'.1.3.6.1.4.1.6027.3.10.1.2.9.1.2',
|
||||||
'Stack Unit'
|
'Stack Unit'
|
||||||
);
|
);
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.2')) {
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.2')) {
|
||||||
d_echo('Dell C Series Chassis');
|
d_echo('Dell C Series Chassis');
|
||||||
$this->findProcessors(
|
$this->findProcessors(
|
||||||
$processors,
|
$processors,
|
||||||
@ -68,7 +69,7 @@ class Dnos extends OS implements ProcessorDiscovery
|
|||||||
'.1.3.6.1.4.1.6027.3.8.1.5.1.1.1',
|
'.1.3.6.1.4.1.6027.3.8.1.5.1.1.1',
|
||||||
'Line Card'
|
'Line Card'
|
||||||
);
|
);
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.4')) {
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.4')) {
|
||||||
d_echo('Dell M Series Chassis');
|
d_echo('Dell M Series Chassis');
|
||||||
$this->findProcessors(
|
$this->findProcessors(
|
||||||
$processors,
|
$processors,
|
||||||
@ -77,7 +78,7 @@ class Dnos extends OS implements ProcessorDiscovery
|
|||||||
'.1.3.6.1.4.1.6027.3.19.1.2.8.1.2',
|
'.1.3.6.1.4.1.6027.3.19.1.2.8.1.2',
|
||||||
'Stack Unit'
|
'Stack Unit'
|
||||||
);
|
);
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.5')) {
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.6027.1.5')) {
|
||||||
d_echo('Dell Z Series Chassis');
|
d_echo('Dell Z Series Chassis');
|
||||||
$this->findProcessors(
|
$this->findProcessors(
|
||||||
$processors,
|
$processors,
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\Processor;
|
use LibreNMS\Device\Processor;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
@ -41,19 +42,19 @@ class Edgecos extends OS implements ProcessorDiscovery
|
|||||||
{
|
{
|
||||||
$device = $this->getDevice();
|
$device = $this->getDevice();
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.24.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.24.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.22.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.22.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.39.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.39.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.45.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.45.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.42.101.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.42.101.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
||||||
$oid = '.1.3.6.1.4.1.259.10.1.27.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.10.1.27.1.39.2.1.0';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11.')) { //ES3510MA
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11.')) { //ES3510MA
|
||||||
$oid = '.1.3.6.1.4.1.259.8.1.11.1.39.2.1.0';
|
$oid = '.1.3.6.1.4.1.259.8.1.11.1.39.2.1.0';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\WirelessSensor;
|
use LibreNMS\Device\WirelessSensor;
|
||||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
|
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
|
||||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
|
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
|
||||||
@ -44,7 +45,7 @@ class Ios extends Cisco implements
|
|||||||
{
|
{
|
||||||
$device = $this->getDevice();
|
$device = $this->getDevice();
|
||||||
|
|
||||||
if (!starts_with($device['hardware'], 'AIR-') && !str_contains($device['hardware'], 'ciscoAIR')) {
|
if (!Str::startsWith($device['hardware'], 'AIR-') && !Str::contains($device['hardware'], 'ciscoAIR')) {
|
||||||
// unsupported IOS hardware
|
// unsupported IOS hardware
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ class Ios extends Cisco implements
|
|||||||
$descr = $ent['entPhysicalDescr'];
|
$descr = $ent['entPhysicalDescr'];
|
||||||
unset($entPhys[$entIndex]); // only use each one once
|
unset($entPhys[$entIndex]); // only use each one once
|
||||||
|
|
||||||
if (ends_with($descr, 'Radio')) {
|
if (Str::endsWith($descr, 'Radio')) {
|
||||||
d_echo("Mapping entPhysicalIndex $entIndex to ifIndex $index\n");
|
d_echo("Mapping entPhysicalIndex $entIndex to ifIndex $index\n");
|
||||||
$data[$index]['entPhysicalIndex'] = $entIndex;
|
$data[$index]['entPhysicalIndex'] = $entIndex;
|
||||||
$data[$index]['entPhysicalDescr'] = $descr;
|
$data[$index]['entPhysicalDescr'] = $descr;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\WirelessSensor;
|
use LibreNMS\Device\WirelessSensor;
|
||||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
|
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
|
||||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
|
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
|
||||||
@ -270,7 +271,7 @@ class Pmp extends OS implements
|
|||||||
private function isAp()
|
private function isAp()
|
||||||
{
|
{
|
||||||
$device = $this->getDevice();
|
$device = $this->getDevice();
|
||||||
return str_contains($device['hardware'], 'AP') || str_contains($device['hardware'], 'Master');
|
return Str::contains($device['hardware'], 'AP') || Str::contains($device['hardware'], 'Master');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,7 +297,7 @@ class Pmp extends OS implements
|
|||||||
$boxType = snmp_get($device, 'boxDeviceType.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
$boxType = snmp_get($device, 'boxDeviceType.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
||||||
|
|
||||||
foreach ($types as $key => $value) {
|
foreach ($types as $key => $value) {
|
||||||
if (str_contains($boxType, $key)) {
|
if (Str::contains($boxType, $key)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\Processor;
|
use LibreNMS\Device\Processor;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
use LibreNMS\Interfaces\Polling\ProcessorPolling;
|
use LibreNMS\Interfaces\Polling\ProcessorPolling;
|
||||||
@ -48,7 +49,7 @@ class Powerconnect extends OS implements ProcessorDiscovery, ProcessorPolling
|
|||||||
public function discoverProcessors()
|
public function discoverProcessors()
|
||||||
{
|
{
|
||||||
$device = $this->getDevice();
|
$device = $this->getDevice();
|
||||||
if (starts_with($device['sysObjectID'], [
|
if (Str::startsWith($device['sysObjectID'], [
|
||||||
'.1.3.6.1.4.1.674.10895.3020',
|
'.1.3.6.1.4.1.674.10895.3020',
|
||||||
'.1.3.6.1.4.1.674.10895.3021',
|
'.1.3.6.1.4.1.674.10895.3021',
|
||||||
'.1.3.6.1.4.1.674.10895.3030',
|
'.1.3.6.1.4.1.674.10895.3030',
|
||||||
@ -63,7 +64,7 @@ class Powerconnect extends OS implements ProcessorDiscovery, ProcessorPolling
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif (starts_with($device['sysObjectID'], [
|
} elseif (Str::startsWith($device['sysObjectID'], [
|
||||||
'.1.3.6.1.4.1.674.10895.3024',
|
'.1.3.6.1.4.1.674.10895.3024',
|
||||||
'.1.3.6.1.4.1.674.10895.3042',
|
'.1.3.6.1.4.1.674.10895.3042',
|
||||||
'.1.3.6.1.4.1.674.10895.3053',
|
'.1.3.6.1.4.1.674.10895.3053',
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\Processor;
|
use LibreNMS\Device\Processor;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
@ -31,7 +32,7 @@ class Sonicwall extends OS implements ProcessorDiscovery
|
|||||||
*/
|
*/
|
||||||
public function discoverProcessors()
|
public function discoverProcessors()
|
||||||
{
|
{
|
||||||
if (starts_with($this->getDevice()['sysObjectID'], '.1.3.6.1.4.1.8741.1')) {
|
if (Str::startsWith($this->getDevice()['sysObjectID'], '.1.3.6.1.4.1.8741.1')) {
|
||||||
return array(
|
return array(
|
||||||
Processor::discover(
|
Processor::discover(
|
||||||
'sonicwall',
|
'sonicwall',
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\OS;
|
namespace LibreNMS\OS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Device\Processor;
|
use LibreNMS\Device\Processor;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||||
use LibreNMS\Interfaces\Polling\NacPolling;
|
use LibreNMS\Interfaces\Polling\NacPolling;
|
||||||
@ -68,7 +69,7 @@ class Vrp extends OS implements
|
|||||||
$descr = $entry['hwEntityBomEnDesc'];
|
$descr = $entry['hwEntityBomEnDesc'];
|
||||||
$usage = $entry['hwEntityCpuUsage'];
|
$usage = $entry['hwEntityCpuUsage'];
|
||||||
|
|
||||||
if (empty($descr) || str_contains($descr, 'No') || str_contains($usage, 'No')) {
|
if (empty($descr) || Str::contains($descr, 'No') || Str::contains($usage, 'No')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace LibreNMS;
|
namespace LibreNMS;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Proc
|
class Proc
|
||||||
{
|
{
|
||||||
@ -299,7 +300,7 @@ class Proc
|
|||||||
*/
|
*/
|
||||||
private function checkAddEOL($string)
|
private function checkAddEOL($string)
|
||||||
{
|
{
|
||||||
if (!ends_with($string, PHP_EOL)) {
|
if (!Str::endsWith($string, PHP_EOL)) {
|
||||||
$string .= PHP_EOL;
|
$string .= PHP_EOL;
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
namespace LibreNMS\Snmptrap\Handlers;
|
namespace LibreNMS\Snmptrap\Handlers;
|
||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||||
use LibreNMS\Snmptrap\Trap;
|
use LibreNMS\Snmptrap\Trap;
|
||||||
use Log;
|
use Log;
|
||||||
@ -57,7 +58,7 @@ class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
|||||||
public function getThresholdMessage($thresholdOid)
|
public function getThresholdMessage($thresholdOid)
|
||||||
{
|
{
|
||||||
foreach ($this->getThresholds() as $oid => $descr) {
|
foreach ($this->getThresholds() as $oid => $descr) {
|
||||||
if (str_contains($thresholdOid, $oid)) {
|
if (Str::contains($thresholdOid, $oid)) {
|
||||||
return $descr;
|
return $descr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
namespace LibreNMS\Snmptrap\Handlers;
|
namespace LibreNMS\Snmptrap\Handlers;
|
||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||||
use LibreNMS\Snmptrap\Trap;
|
use LibreNMS\Snmptrap\Trap;
|
||||||
use Log;
|
use Log;
|
||||||
@ -55,7 +56,7 @@ class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
|||||||
public function getThresholdMessage($thresholdOid)
|
public function getThresholdMessage($thresholdOid)
|
||||||
{
|
{
|
||||||
foreach ($this->getThresholds() as $oid => $descr) {
|
foreach ($this->getThresholds() as $oid => $descr) {
|
||||||
if (str_contains($thresholdOid, $oid)) {
|
if (Str::contains($thresholdOid, $oid)) {
|
||||||
return $descr;
|
return $descr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ namespace LibreNMS\Snmptrap;
|
|||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Snmptrap\Handlers\Fallback;
|
use LibreNMS\Snmptrap\Handlers\Fallback;
|
||||||
use LibreNMS\Util\IP;
|
use LibreNMS\Util\IP;
|
||||||
use Log;
|
use Log;
|
||||||
@ -79,7 +80,7 @@ class Trap
|
|||||||
public function findOid($search)
|
public function findOid($search)
|
||||||
{
|
{
|
||||||
return $this->oid_data->keys()->first(function ($oid) use ($search) {
|
return $this->oid_data->keys()->first(function ($oid) use ($search) {
|
||||||
return str_contains($oid, $search);
|
return Str::contains($oid, $search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ class Trap
|
|||||||
public function findOids($search)
|
public function findOids($search)
|
||||||
{
|
{
|
||||||
return $this->oid_data->keys()->filter(function ($oid) use ($search) {
|
return $this->oid_data->keys()->filter(function ($oid) use ($search) {
|
||||||
return str_contains($oid, $search);
|
return Str::contains($oid, $search);
|
||||||
})->all();
|
})->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Util;
|
namespace LibreNMS\Util;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Exceptions\FileNotFoundException;
|
use LibreNMS\Exceptions\FileNotFoundException;
|
||||||
use LibreNMS\Exceptions\InvalidModuleException;
|
use LibreNMS\Exceptions\InvalidModuleException;
|
||||||
@ -285,7 +286,7 @@ class ModuleTestHelper
|
|||||||
{
|
{
|
||||||
$full_name = basename($os_file, '.json');
|
$full_name = basename($os_file, '.json');
|
||||||
|
|
||||||
if (!str_contains($full_name, '_')) {
|
if (!Str::contains($full_name, '_')) {
|
||||||
return [$full_name, ''];
|
return [$full_name, ''];
|
||||||
} elseif (is_file(Config::get('install_dir') . "/includes/definitions/$full_name.yaml")) {
|
} elseif (is_file(Config::get('install_dir') . "/includes/definitions/$full_name.yaml")) {
|
||||||
return [$full_name, ''];
|
return [$full_name, ''];
|
||||||
@ -362,7 +363,7 @@ class ModuleTestHelper
|
|||||||
$result[] = "$oid|4|"; // empty data, we don't know type, put string
|
$result[] = "$oid|4|"; // empty data, we don't know type, put string
|
||||||
} else {
|
} else {
|
||||||
list($raw_type, $data) = explode(':', $raw_data, 2);
|
list($raw_type, $data) = explode(':', $raw_data, 2);
|
||||||
if (starts_with($raw_type, 'Wrong Type (should be ')) {
|
if (Str::startsWith($raw_type, 'Wrong Type (should be ')) {
|
||||||
// device returned the wrong type, save the wrong type to emulate the device behavior
|
// device returned the wrong type, save the wrong type to emulate the device behavior
|
||||||
list($raw_type, $data) = explode(':', ltrim($data), 2);
|
list($raw_type, $data) = explode(':', ltrim($data), 2);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class Url
|
|||||||
unset($vars['page']);
|
unset($vars['page']);
|
||||||
|
|
||||||
foreach ($vars as $var => $value) {
|
foreach ($vars as $var => $value) {
|
||||||
if ($value == '0' || $value != '' && !str_contains($var, 'opt') && !is_numeric($var)) {
|
if ($value == '0' || $value != '' && !Str::contains($var, 'opt') && !is_numeric($var)) {
|
||||||
$url .= $var . '=' . urlencode($value) . '/';
|
$url .= $var . '=' . urlencode($value) . '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Validations;
|
namespace LibreNMS\Validations;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Validator;
|
use LibreNMS\Validator;
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ class Programs extends BaseValidation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($output, '::1 is unreachable') || str_contains($output, 'Address family not supported')) {
|
if (Str::contains($output, '::1 is unreachable') || Str::contains($output, 'Address family not supported')) {
|
||||||
$validator->warn("IPv6 is disabled on your server, you will not be able to add IPv6 devices.");
|
$validator->warn("IPv6 is disabled on your server, you will not be able to add IPv6 devices.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,7 +82,7 @@ class Programs extends BaseValidation
|
|||||||
$getcap_out = shell_exec("$getcap $cmd");
|
$getcap_out = shell_exec("$getcap $cmd");
|
||||||
preg_match("#^$cmd = (.*)$#", $getcap_out, $matches);
|
preg_match("#^$cmd = (.*)$#", $getcap_out, $matches);
|
||||||
|
|
||||||
if (is_null($matches) || !str_contains($matches[1], 'cap_net_raw+ep')) {
|
if (is_null($matches) || !Str::contains($matches[1], 'cap_net_raw+ep')) {
|
||||||
$validator->fail(
|
$validator->fail(
|
||||||
"$bin should have CAP_NET_RAW!",
|
"$bin should have CAP_NET_RAW!",
|
||||||
"setcap cap_net_raw+ep $cmd"
|
"setcap cap_net_raw+ep $cmd"
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Validations;
|
namespace LibreNMS\Validations;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Util\Env;
|
use LibreNMS\Util\Env;
|
||||||
use LibreNMS\Util\Git;
|
use LibreNMS\Util\Git;
|
||||||
@ -99,7 +100,7 @@ class User extends BaseValidation
|
|||||||
);
|
);
|
||||||
|
|
||||||
$files = array_filter(explode(PHP_EOL, $find_result), function ($file) use ($ignore_files) {
|
$files = array_filter(explode(PHP_EOL, $find_result), function ($file) use ($ignore_files) {
|
||||||
if (starts_with($file, $ignore_files)) {
|
if (Str::startsWith($file, $ignore_files)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS;
|
namespace LibreNMS;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\ValidationGroup;
|
use LibreNMS\Interfaces\ValidationGroup;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ class Validator
|
|||||||
$group = 'unknown';
|
$group = 'unknown';
|
||||||
$bt = debug_backtrace();
|
$bt = debug_backtrace();
|
||||||
foreach ($bt as $entry) {
|
foreach ($bt as $entry) {
|
||||||
if (starts_with($entry['class'], 'LibreNMS\Validations')) {
|
if (Str::startsWith($entry['class'], 'LibreNMS\Validations')) {
|
||||||
$group = str_replace('LibreNMS\Validations\\', '', $entry['class']);
|
$group = str_replace('LibreNMS\Validations\\', '', $entry['class']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\Console\Input\InputDefinition;
|
use Symfony\Component\Console\Input\InputDefinition;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
@ -47,11 +48,11 @@ class BashCompletionCommand extends Command
|
|||||||
$command_def = $commands[$command]->getDefinition();
|
$command_def = $commands[$command]->getDefinition();
|
||||||
$previous_name = ltrim($previous, '-');
|
$previous_name = ltrim($previous, '-');
|
||||||
|
|
||||||
if (starts_with($previous, '-') && $command_def->hasOption($previous_name) && $command_def->getOption($previous_name)->acceptValue()) {
|
if (Str::startsWith($previous, '-') && $command_def->hasOption($previous_name) && $command_def->getOption($previous_name)->acceptValue()) {
|
||||||
$completions = $this->completeOptionValue($command_def->getOption($previous_name), $current);
|
$completions = $this->completeOptionValue($command_def->getOption($previous_name), $current);
|
||||||
} else {
|
} else {
|
||||||
$completions = collect();
|
$completions = collect();
|
||||||
if (!starts_with($previous, '-')) {
|
if (!Str::startsWith($previous, '-')) {
|
||||||
$completions = $this->completeArguments($command, $current, end($words));
|
$completions = $this->completeArguments($command, $current, end($words));
|
||||||
}
|
}
|
||||||
$completions = $completions->merge($this->completeOption($command_def, $current, $this->getPreviousOptions($words)));
|
$completions = $completions->merge($this->completeOption($command_def, $current, $this->getPreviousOptions($words)));
|
||||||
@ -93,11 +94,11 @@ class BashCompletionCommand extends Command
|
|||||||
});
|
});
|
||||||
|
|
||||||
$completions = $all_commands->filter(function ($cmd) use ($partial) {
|
$completions = $all_commands->filter(function ($cmd) use ($partial) {
|
||||||
return empty($partial) || starts_with($cmd, $partial);
|
return empty($partial) || Str::startsWith($cmd, $partial);
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle : silliness
|
// handle : silliness
|
||||||
if (str_contains($partial, ':')) {
|
if (Str::contains($partial, ':')) {
|
||||||
$completions = $completions->map(function ($cmd) {
|
$completions = $completions->map(function ($cmd) {
|
||||||
return substr($cmd, strpos($cmd, ':') + 1);
|
return substr($cmd, strpos($cmd, ':') + 1);
|
||||||
});
|
});
|
||||||
@ -144,14 +145,14 @@ class BashCompletionCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $options->filter(function ($option) use ($partial) {
|
return $options->filter(function ($option) use ($partial) {
|
||||||
return empty($partial) || starts_with($option, $partial);
|
return empty($partial) || Str::startsWith($option, $partial);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPreviousOptions($words)
|
private function getPreviousOptions($words)
|
||||||
{
|
{
|
||||||
return array_reduce($words, function ($result, $word) {
|
return array_reduce($words, function ($result, $word) {
|
||||||
if (starts_with($word, '-')) {
|
if (Str::startsWith($word, '-')) {
|
||||||
$split = explode('=', $word, 2); // users may use equals for values
|
$split = explode('=', $word, 2); // users may use equals for values
|
||||||
$result[] = reset($split);
|
$result[] = reset($split);
|
||||||
}
|
}
|
||||||
@ -174,7 +175,7 @@ class BashCompletionCommand extends Command
|
|||||||
return trim($value);
|
return trim($value);
|
||||||
})
|
})
|
||||||
->filter(function ($value) use ($partial) {
|
->filter(function ($value) use ($partial) {
|
||||||
return empty($partial) || starts_with($value, $partial);
|
return empty($partial) || Str::startsWith($value, $partial);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return collect();
|
return collect();
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace App\Http\Controllers\Ajax;
|
namespace App\Http\Controllers\Ajax;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use \LibreNMS\Config;
|
use \LibreNMS\Config;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
@ -71,7 +72,7 @@ class NetCommand extends Controller
|
|||||||
function () use ($proc, $request) {
|
function () use ($proc, $request) {
|
||||||
// a bit dirty, bust browser initial cache
|
// a bit dirty, bust browser initial cache
|
||||||
$ua = $request->header('User-Agent');
|
$ua = $request->header('User-Agent');
|
||||||
if (str_contains($ua, ['Chrome', 'Trident'])) {
|
if (Str::contains($ua, ['Chrome', 'Trident'])) {
|
||||||
$char = "\f"; // line feed
|
$char = "\f"; // line feed
|
||||||
} else {
|
} else {
|
||||||
$char = "";
|
$char = "";
|
||||||
|
@ -6,6 +6,7 @@ use App\Checks;
|
|||||||
use Illuminate\Contracts\Session\Session;
|
use Illuminate\Contracts\Session\Session;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
class LegacyController extends Controller
|
class LegacyController extends Controller
|
||||||
@ -19,16 +20,16 @@ class LegacyController extends Controller
|
|||||||
$init_modules = ['web', 'auth'];
|
$init_modules = ['web', 'auth'];
|
||||||
require base_path('/includes/init.php');
|
require base_path('/includes/init.php');
|
||||||
|
|
||||||
set_debug(str_contains($request->path(), 'debug'));
|
set_debug(Str::contains($request->path(), 'debug'));
|
||||||
|
|
||||||
ob_start(); // protect against bad plugins that output during start
|
ob_start(); // protect against bad plugins that output during start
|
||||||
\LibreNMS\Plugins::start();
|
\LibreNMS\Plugins::start();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
if (str_contains($request->path(), 'widescreen=yes')) {
|
if (Str::contains($request->path(), 'widescreen=yes')) {
|
||||||
$session->put('widescreen', 1);
|
$session->put('widescreen', 1);
|
||||||
}
|
}
|
||||||
if (str_contains($request->path(), 'widescreen=no')) {
|
if (Str::contains($request->path(), 'widescreen=no')) {
|
||||||
$session->forget('widescreen');
|
$session->forget('widescreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace App\Http\Controllers\Select;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
class GraphAggregateController extends Controller
|
class GraphAggregateController extends Controller
|
||||||
@ -56,7 +57,7 @@ class GraphAggregateController extends Controller
|
|||||||
// handle search
|
// handle search
|
||||||
if ($search = strtolower($request->get('term'))) {
|
if ($search = strtolower($request->get('term'))) {
|
||||||
$types = array_filter($types, function ($type) use ($search) {
|
$types = array_filter($types, function ($type) use ($search) {
|
||||||
return !str_contains(strtolower($type), $search);
|
return !Str::contains(strtolower($type), $search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Util\Graph;
|
use LibreNMS\Util\Graph;
|
||||||
use LibreNMS\Util\StringHelpers;
|
use LibreNMS\Util\StringHelpers;
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ class GraphController extends Controller
|
|||||||
private function formatGraph($top, $graph)
|
private function formatGraph($top, $graph)
|
||||||
{
|
{
|
||||||
$text = $graph;
|
$text = $graph;
|
||||||
if (str_contains('_', $graph)) {
|
if (Str::contains('_', $graph)) {
|
||||||
list($type, $subtype) = explode('_', $graph, 2);
|
list($type, $subtype) = explode('_', $graph, 2);
|
||||||
} else {
|
} else {
|
||||||
$type = $graph;
|
$type = $graph;
|
||||||
@ -131,18 +132,18 @@ class GraphController extends Controller
|
|||||||
$terms = preg_split('/[ _-]/', $search, 2);
|
$terms = preg_split('/[ _-]/', $search, 2);
|
||||||
$first = array_shift($terms);
|
$first = array_shift($terms);
|
||||||
|
|
||||||
if (str_contains($type, $first)) {
|
if (Str::contains($type, $first)) {
|
||||||
// search matches type, show all unless there are more terms.
|
// search matches type, show all unless there are more terms.
|
||||||
if (!empty($terms)) {
|
if (!empty($terms)) {
|
||||||
$sub_search = array_shift($terms);
|
$sub_search = array_shift($terms);
|
||||||
$graphs = $graphs->filter(function ($graph) use ($sub_search) {
|
$graphs = $graphs->filter(function ($graph) use ($sub_search) {
|
||||||
return str_contains(strtolower($graph), $sub_search);
|
return Str::contains(strtolower($graph), $sub_search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if the type matches, don't filter the sub values
|
// if the type matches, don't filter the sub values
|
||||||
$graphs = $graphs->filter(function ($graph) use ($search) {
|
$graphs = $graphs->filter(function ($graph) use ($search) {
|
||||||
return str_contains(strtolower($graph), $search);
|
return Str::contains(strtolower($graph), $search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ namespace App\Http\Controllers\Select;
|
|||||||
use App\ApiClients\GraylogApi;
|
use App\ApiClients\GraylogApi;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
class GraylogStreamsController extends Controller
|
class GraylogStreamsController extends Controller
|
||||||
@ -50,7 +51,7 @@ class GraylogStreamsController extends Controller
|
|||||||
$streams = [];
|
$streams = [];
|
||||||
try {
|
try {
|
||||||
$streams = collect($api->getStreams()['streams'])->filter(function ($stream) use ($search) {
|
$streams = collect($api->getStreams()['streams'])->filter(function ($stream) use ($search) {
|
||||||
return !$search || str_contains(strtolower($stream['title']), $search) || str_contains(strtolower($stream['description']), $search);
|
return !$search || Str::contains(strtolower($stream['title']), $search) || Str::contains(strtolower($stream['description']), $search);
|
||||||
})->map(function ($stream) {
|
})->map(function ($stream) {
|
||||||
$text = $stream['title'];
|
$text = $stream['title'];
|
||||||
if ($stream['description']) {
|
if ($stream['description']) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace App\Http\Controllers\Table;
|
namespace App\Http\Controllers\Table;
|
||||||
|
|
||||||
use App\Models\Port;
|
use App\Models\Port;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Util\Html;
|
use LibreNMS\Util\Html;
|
||||||
use LibreNMS\Util\Url;
|
use LibreNMS\Util\Url;
|
||||||
@ -128,6 +129,6 @@ class CustomersController extends TableController
|
|||||||
|
|
||||||
private function getTypeStrings()
|
private function getTypeStrings()
|
||||||
{
|
{
|
||||||
return array_wrap(Config::get('customers_descr', ['cust']));
|
return Arr::wrap(Config::get('customers_descr', ['cust']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ use App\Models\AuthLog;
|
|||||||
use App\Models\Dashboard;
|
use App\Models\Dashboard;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserPref;
|
use App\Models\UserPref;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Authentication\LegacyAuth;
|
use LibreNMS\Authentication\LegacyAuth;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use Toastr;
|
use Toastr;
|
||||||
@ -177,7 +178,7 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route(str_contains(URL::previous(), 'preferences') ? 'preferences.index' : 'users.index'));
|
return redirect(route(Str::contains(URL::previous(), 'preferences') ? 'preferences.index' : 'users.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace App\Http\Controllers\Widgets;
|
namespace App\Http\Controllers\Widgets;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ImageController extends WidgetController
|
class ImageController extends WidgetController
|
||||||
{
|
{
|
||||||
@ -51,7 +52,7 @@ class ImageController extends WidgetController
|
|||||||
$data['image_url'] = str_replace(['@AUTO_HEIGHT@', '@AUTO_WIDTH@'], [$dimensions['y'], $dimensions['x']], $data['image_url']);
|
$data['image_url'] = str_replace(['@AUTO_HEIGHT@', '@AUTO_WIDTH@'], [$dimensions['y'], $dimensions['x']], $data['image_url']);
|
||||||
|
|
||||||
// bust cache
|
// bust cache
|
||||||
if (str_contains($data['image_url'], '?')) {
|
if (Str::contains($data['image_url'], '?')) {
|
||||||
$data['image_url'] .= '&' . mt_rand();
|
$data['image_url'] .= '&' . mt_rand();
|
||||||
} else {
|
} else {
|
||||||
$data['image_url'] .= '?' . mt_rand();
|
$data['image_url'] .= '?' . mt_rand();
|
||||||
|
@ -29,6 +29,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\DeviceGroup;
|
use App\Models\DeviceGroup;
|
||||||
use App\Models\UserWidget;
|
use App\Models\UserWidget;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
abstract class WidgetController extends Controller
|
abstract class WidgetController extends Controller
|
||||||
@ -115,7 +116,7 @@ abstract class WidgetController extends Controller
|
|||||||
{
|
{
|
||||||
if ($view instanceof View) {
|
if ($view instanceof View) {
|
||||||
$html = $view->__toString();
|
$html = $view->__toString();
|
||||||
$show_settings = (int)starts_with($view->getName(), 'widgets.settings.');
|
$show_settings = (int)Str::startsWith($view->getName(), 'widgets.settings.');
|
||||||
} else {
|
} else {
|
||||||
$html = (string)$view;
|
$html = (string)$view;
|
||||||
$show_settings = (int)$this->show_settings;
|
$show_settings = (int)$this->show_settings;
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
|||||||
|
|
||||||
use App\Models\UserPref;
|
use App\Models\UserPref;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
class VerifyTwoFactor
|
class VerifyTwoFactor
|
||||||
@ -20,7 +21,7 @@ class VerifyTwoFactor
|
|||||||
// check twofactor
|
// check twofactor
|
||||||
if (Config::get('twofactor') === true) {
|
if (Config::get('twofactor') === true) {
|
||||||
// don't apply on 2fa checking routes
|
// don't apply on 2fa checking routes
|
||||||
if (starts_with($request->route()->getName(), '2fa.')) {
|
if (Str::startsWith($request->route()->getName(), '2fa.')) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,25 +1275,6 @@ function ResolveGlues($tables, $target, $x = 0, $hist = array(), $last = array()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('str_contains')) {
|
|
||||||
/**
|
|
||||||
* Determine if a given string contains a given substring.
|
|
||||||
*
|
|
||||||
* @param string $haystack
|
|
||||||
* @param string|array $needles
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function str_contains($haystack, $needles)
|
|
||||||
{
|
|
||||||
foreach ((array)$needles as $needle) {
|
|
||||||
if ($needle != '' && strpos($haystack, $needle) !== false) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given string contains a given substring.
|
* Determine if a given string contains a given substring.
|
||||||
*
|
*
|
||||||
@ -1341,44 +1322,6 @@ function get_sql_filter_min_severity($min_severity, $alert_rules_name)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('ends_with')) {
|
|
||||||
/**
|
|
||||||
* Determine if a given string ends with a given substring.
|
|
||||||
*
|
|
||||||
* @param string $haystack
|
|
||||||
* @param string|array $needles
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function ends_with($haystack, $needles)
|
|
||||||
{
|
|
||||||
foreach ((array)$needles as $needle) {
|
|
||||||
if ((string)$needle === substr($haystack, -strlen($needle))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('starts_with')) {
|
|
||||||
/**
|
|
||||||
* Determine if a given string starts with a given substring.
|
|
||||||
*
|
|
||||||
* @param string $haystack
|
|
||||||
* @param string|array $needles
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function starts_with($haystack, $needles)
|
|
||||||
{
|
|
||||||
foreach ((array)$needles as $needle) {
|
|
||||||
if ($needle != '' && strpos($haystack, $needle) === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a list of items up to a max amount
|
* Print a list of items up to a max amount
|
||||||
* If over that number, a line will print the total items
|
* If over that number, a line will print the total items
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
echo "\nCaching OIDs:";
|
echo "\nCaching OIDs:";
|
||||||
|
|
||||||
if ($device['os'] == 'junos') {
|
if ($device['os'] == 'junos') {
|
||||||
@ -101,7 +103,7 @@ if ($device['os'] == 'saf-cfm') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ([1 => 'm1Description', 2 => 'm2Description', 3 => 'm3Description', 4 => 'm4Description'] as $index => $item) {
|
foreach ([1 => 'm1Description', 2 => 'm2Description', 3 => 'm3Description', 4 => 'm4Description'] as $index => $item) {
|
||||||
if (!str_contains($device_array[$item], 'N/A')) {
|
if (!Str::contains($device_array[$item], 'N/A')) {
|
||||||
$entity_array[] = [
|
$entity_array[] = [
|
||||||
'entPhysicalDescr' => $device_array[$item],
|
'entPhysicalDescr' => $device_array[$item],
|
||||||
'entPhysicalVendorType' => 'module',
|
'entPhysicalVendorType' => 'module',
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
* See COPYING for more details.
|
* See COPYING for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Exceptions\HostExistsException;
|
use LibreNMS\Exceptions\HostExistsException;
|
||||||
use LibreNMS\Exceptions\InvalidIpException;
|
use LibreNMS\Exceptions\InvalidIpException;
|
||||||
@ -913,13 +914,13 @@ function get_device_divisor($device, $os_version, $sensor_type, $oid)
|
|||||||
}
|
}
|
||||||
} elseif ($device['os'] == 'huaweiups') {
|
} elseif ($device['os'] == 'huaweiups') {
|
||||||
if ($sensor_type == 'frequency') {
|
if ($sensor_type == 'frequency') {
|
||||||
if (starts_with($device['hardware'], "UPS2000")) {
|
if (Str::startsWith($device['hardware'], "UPS2000")) {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
} elseif ($device['os'] == 'hpe-rtups') {
|
} elseif ($device['os'] == 'hpe-rtups') {
|
||||||
if ($sensor_type == 'voltage' && !starts_with($oid, '.1.3.6.1.2.1.33.1.2.5.') && !starts_with($oid, '.1.3.6.1.2.1.33.1.3.3.1.3')) {
|
if ($sensor_type == 'voltage' && !Str::startsWith($oid, '.1.3.6.1.2.1.33.1.2.5.') && !Str::startsWith($oid, '.1.3.6.1.2.1.33.1.3.3.1.3')) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} elseif ($device['os'] == 'apc-mgeups') {
|
} elseif ($device['os'] == 'apc-mgeups') {
|
||||||
@ -934,16 +935,16 @@ function get_device_divisor($device, $os_version, $sensor_type, $oid)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sensor_type == 'voltage' && !starts_with($oid, '.1.3.6.1.2.1.33.1.2.5.')) {
|
if ($sensor_type == 'voltage' && !Str::startsWith($oid, '.1.3.6.1.2.1.33.1.2.5.')) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sensor_type == 'runtime') {
|
if ($sensor_type == 'runtime') {
|
||||||
if (starts_with($oid, '.1.3.6.1.2.1.33.1.2.2.')) {
|
if (Str::startsWith($oid, '.1.3.6.1.2.1.33.1.2.2.')) {
|
||||||
return 60;
|
return 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starts_with($oid, '.1.3.6.1.2.1.33.1.2.3.')) {
|
if (Str::startsWith($oid, '.1.3.6.1.2.1.33.1.2.3.')) {
|
||||||
if ($device['os'] == 'routeros') {
|
if ($device['os'] == 'routeros') {
|
||||||
return 60;
|
return 60;
|
||||||
} else {
|
} else {
|
||||||
@ -985,7 +986,7 @@ function ignore_storage($os, $descr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (Config::getOsSetting($os, 'ignore_mount_string') as $ims) {
|
foreach (Config::getOsSetting($os, 'ignore_mount_string') as $ims) {
|
||||||
if (str_contains($descr, $ims)) {
|
if (Str::contains($descr, $ims)) {
|
||||||
d_echo("ignored $descr (matched: $ims)\n");
|
d_echo("ignored $descr (matched: $ims)\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1037,7 +1038,7 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
|||||||
if (!is_numeric($snmp_value)) {
|
if (!is_numeric($snmp_value)) {
|
||||||
if ($sensor_type === 'temperature') {
|
if ($sensor_type === 'temperature') {
|
||||||
// For temp sensors, try and detect fahrenheit values
|
// For temp sensors, try and detect fahrenheit values
|
||||||
if (ends_with($snmp_value, array('f', 'F'))) {
|
if (Str::endsWith($snmp_value, array('f', 'F'))) {
|
||||||
$user_function = 'fahrenheit_to_celsius';
|
$user_function = 'fahrenheit_to_celsius';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
// FIXME should do the deletion etc in a common file perhaps? like for the sensors
|
// FIXME should do the deletion etc in a common file perhaps? like for the sensors
|
||||||
@ -15,13 +16,13 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (Config::get('libvirt_protocols') as $method) {
|
foreach (Config::get('libvirt_protocols') as $method) {
|
||||||
if (str_contains($method, 'qemu')) {
|
if (Str::contains($method, 'qemu')) {
|
||||||
$uri = $method.'://'.$userHostname.'/system';
|
$uri = $method.'://'.$userHostname.'/system';
|
||||||
} else {
|
} else {
|
||||||
$uri = $method.'://'.$userHostname;
|
$uri = $method.'://'.$userHostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($method, 'ssh') && !$ssh_ok) {
|
if (Str::contains($method, 'ssh') && !$ssh_ok) {
|
||||||
// Check if we are using SSH if we can log in without password - without blocking the discovery
|
// Check if we are using SSH if we can log in without password - without blocking the discovery
|
||||||
// Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-)
|
// Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-)
|
||||||
exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$userHostname.' echo -e', $out, $ret);
|
exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$userHostname.' echo -e', $out, $ret);
|
||||||
@ -30,7 +31,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ssh_ok || !str_contains($method, 'ssh')) {
|
if ($ssh_ok || !Str::contains($method, 'ssh')) {
|
||||||
// Fetch virtual machine list
|
// Fetch virtual machine list
|
||||||
unset($domlist);
|
unset($domlist);
|
||||||
exec(Config::get('virsh').' -rc '.$uri.' list', $domlist);
|
exec(Config::get('virsh').' -rc '.$uri.' list', $domlist);
|
||||||
|
@ -10,23 +10,24 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
if ($device['os'] == 'edgecos') {
|
if ($device['os'] == 'edgecos') {
|
||||||
d_echo('EdgeCore Memory:');
|
d_echo('EdgeCore Memory:');
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
||||||
$temp_mibs = 'ECS4510-MIB';
|
$temp_mibs = 'ECS4510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
||||||
$temp_mibs = 'ES3528MV2-MIB';
|
$temp_mibs = 'ES3528MV2-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
||||||
$temp_mibs = 'ECS4110-MIB';
|
$temp_mibs = 'ECS4110-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
||||||
$temp_mibs = 'ECS4120-MIB';
|
$temp_mibs = 'ECS4120-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
||||||
$temp_mibs = 'ECS4210-MIB';
|
$temp_mibs = 'ECS4210-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
||||||
$temp_mibs = 'ECS3510-MIB';
|
$temp_mibs = 'ECS3510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
||||||
$temp_mibs = 'ECS2100-MIB';
|
$temp_mibs = 'ECS2100-MIB';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
if ($device['os'] == 'ironware' || $device['os_type'] == 'ironware') {
|
if ($device['os'] == 'ironware' || $device['os_type'] == 'ironware') {
|
||||||
if (str_contains($device['sysDescr'], array('NetIron', 'MLX', 'CER')) === false) {
|
if (Str::contains($device['sysDescr'], array('NetIron', 'MLX', 'CER')) === false) {
|
||||||
echo 'Ironware Dynamic: ';
|
echo 'Ironware Dynamic: ';
|
||||||
|
|
||||||
$percent = snmp_get($device, 'snAgGblDynMemUtil.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
|
$percent = snmp_get($device, 'snAgGblDynMemUtil.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
if ($device['os'] == 'sonicwall') {
|
if ($device['os'] == 'sonicwall') {
|
||||||
echo 'SonicWALL-MEMORY-POOL: ';
|
echo 'SonicWALL-MEMORY-POOL: ';
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
||||||
$usage = snmp_get($device, 'SNWL-SSLVPN-MIB::memoryUtilization.0', '-Ovq');
|
$usage = snmp_get($device, 'SNWL-SSLVPN-MIB::memoryUtilization.0', '-Ovq');
|
||||||
} else {
|
} else {
|
||||||
$usage = snmp_get($device, 'SONICWALL-FIREWALL-IP-STATISTICS-MIB::sonicCurrentRAMUtil.0', '-Ovq');
|
$usage = snmp_get($device, 'SONICWALL-FIREWALL-IP-STATISTICS-MIB::sonicCurrentRAMUtil.0', '-Ovq');
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (starts_with($device['sysDescr'], 'Linux') || starts_with($device['sysObjectID'], '.1.3.6.1.4.1.8072.3.2.10')) {
|
use Illuminate\Support\Str;
|
||||||
if (starts_with($device['sysObjectID'], array('.1.3.6.1.4.1.10002.1', '.1.3.6.1.4.1.41112.1.4'))
|
|
||||||
|| str_contains(snmp_walk($device, 'dot11manufacturerName', '-Osqnv', 'IEEE802dot11-MIB'), 'Ubiquiti')
|
if (Str::startsWith($device['sysDescr'], 'Linux') || Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.8072.3.2.10')) {
|
||||||
|
if (Str::startsWith($device['sysObjectID'], array('.1.3.6.1.4.1.10002.1', '.1.3.6.1.4.1.41112.1.4'))
|
||||||
|
|| Str::contains(snmp_walk($device, 'dot11manufacturerName', '-Osqnv', 'IEEE802dot11-MIB'), 'Ubiquiti')
|
||||||
) {
|
) {
|
||||||
$os = 'airos';
|
$os = 'airos';
|
||||||
if (str_contains(snmp_walk($device, 'dot11manufacturerProductName', '-Osqnv', 'IEEE802dot11-MIB'), 'UAP')) {
|
if (Str::contains(snmp_walk($device, 'dot11manufacturerProductName', '-Osqnv', 'IEEE802dot11-MIB'), 'UAP')) {
|
||||||
$os = 'unifi';
|
$os = 'unifi';
|
||||||
} elseif (snmp_get($device, 'fwVersion.1', '-Osqnv', 'UBNT-AirFIBER-MIB', 'ubnt') !== false) {
|
} elseif (snmp_get($device, 'fwVersion.1', '-Osqnv', 'UBNT-AirFIBER-MIB', 'ubnt') !== false) {
|
||||||
$os = 'airos-af';
|
$os = 'airos-af';
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
if ($device['os_group'] == 'cisco') {
|
if ($device['os_group'] == 'cisco') {
|
||||||
echo ' CISCO-ENTITY-SENSOR: ';
|
echo ' CISCO-ENTITY-SENSOR: ';
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ if ($device['os_group'] == 'cisco') {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($entity_array[$phys_index]['entPhysicalClass'] === 'port') {
|
if ($entity_array[$phys_index]['entPhysicalClass'] === 'port') {
|
||||||
if (str_contains($entity_array[$phys_index][0]['entAliasMappingIdentifier'], 'ifIndex.')) {
|
if (Str::contains($entity_array[$phys_index][0]['entAliasMappingIdentifier'], 'ifIndex.')) {
|
||||||
list(, $tmp_ifindex) = explode(".", $entity_array[$phys_index][0]['entAliasMappingIdentifier']);
|
list(, $tmp_ifindex) = explode(".", $entity_array[$phys_index][0]['entAliasMappingIdentifier']);
|
||||||
$tmp_port = get_port_by_index_cache($device['device_id'], $tmp_ifindex);
|
$tmp_port = get_port_by_index_cache($device['device_id'], $tmp_ifindex);
|
||||||
if (is_array($tmp_port)) {
|
if (is_array($tmp_port)) {
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
* @author LibreNMS Contributors
|
* @author LibreNMS Contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
||||||
$licenses = snmp_get($device, 'SNWL-SSLVPN-MIB::userLicense.0', '-Ovq');
|
$licenses = snmp_get($device, 'SNWL-SSLVPN-MIB::userLicense.0', '-Ovq');
|
||||||
$licenses = str_replace(' Users', '', $licenses);
|
$licenses = str_replace(' Users', '', $licenses);
|
||||||
$current = snmp_get($device, '.1.3.6.1.4.1.8741.6.2.1.9.0', '-Ovq');
|
$current = snmp_get($device, '.1.3.6.1.4.1.8741.6.2.1.9.0', '-Ovq');
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
echo ' ENTITY-SENSOR: ';
|
echo ' ENTITY-SENSOR: ';
|
||||||
echo 'Caching OIDs:';
|
echo 'Caching OIDs:';
|
||||||
if (empty($entity_array)) {
|
if (empty($entity_array)) {
|
||||||
@ -47,7 +50,7 @@ if (!empty($entity_oids)) {
|
|||||||
$high_limit = null;
|
$high_limit = null;
|
||||||
|
|
||||||
// Fix for Cisco ASR920, 15.5(2)S
|
// Fix for Cisco ASR920, 15.5(2)S
|
||||||
if ($entry['entPhySensorType'] == 'other' && str_contains($entity_array[$index]['entPhysicalName'], ['Rx Power Sensor', 'Tx Power Sensor'])) {
|
if ($entry['entPhySensorType'] == 'other' && Str::contains($entity_array[$index]['entPhysicalName'], ['Rx Power Sensor', 'Tx Power Sensor'])) {
|
||||||
$entitysensor['other'] = 'dbm';
|
$entitysensor['other'] = 'dbm';
|
||||||
}
|
}
|
||||||
if ($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index)) {
|
if ($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index)) {
|
||||||
@ -131,7 +134,7 @@ if (!empty($entity_oids)) {
|
|||||||
$valid_sensor = false;
|
$valid_sensor = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($current == '-127' || ($device['os'] == 'asa' && ends_with($device['hardware'], 'sc'))) {
|
if ($current == '-127' || ($device['os'] == 'asa' && Str::endsWith($device['hardware'], 'sc'))) {
|
||||||
$valid_sensor = false;
|
$valid_sensor = false;
|
||||||
}
|
}
|
||||||
// Check for valid sensors
|
// Check for valid sensors
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
* @author Neil Lathwood <gh+n@laf.io>
|
* @author Neil Lathwood <gh+n@laf.io>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$serverscheck_oids = [
|
$serverscheck_oids = [
|
||||||
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
||||||
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
||||||
@ -33,10 +35,10 @@ $serverscheck_oids = [
|
|||||||
|
|
||||||
$temp_x = 1;
|
$temp_x = 1;
|
||||||
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
||||||
if (str_contains($oid_name, 'name')) {
|
if (Str::contains($oid_name, 'name')) {
|
||||||
$tmp_oid = 'sensor' . $temp_x . 'Value.0';
|
$tmp_oid = 'sensor' . $temp_x . 'Value.0';
|
||||||
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
||||||
if (str_contains($oid_value, 'Humid')) {
|
if (Str::contains($oid_value, 'Humid')) {
|
||||||
if (is_numeric($current)) {
|
if (is_numeric($current)) {
|
||||||
$index = str_replace('.0', '', $oid_name);
|
$index = str_replace('.0', '', $oid_name);
|
||||||
$descr = $oid_value;
|
$descr = $oid_value;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
// IPMI - We can discover this on poll!
|
// IPMI - We can discover this on poll!
|
||||||
@ -18,7 +19,7 @@ if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
|
|||||||
$results = explode(PHP_EOL, external_exec(array_merge($cmd, ['-I', $ipmi_type, 'sensor'])));
|
$results = explode(PHP_EOL, external_exec(array_merge($cmd, ['-I', $ipmi_type, 'sensor'])));
|
||||||
|
|
||||||
array_filter($results, function ($line) {
|
array_filter($results, function ($line) {
|
||||||
return !str_contains($line, 'discrete');
|
return !Str::contains($line, 'discrete');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!empty($results)) {
|
if (!empty($results)) {
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$temp = snmpwalk_cache_multi_oid($device, 'swIfOperSuspendedStatus', [], 'CISCOSB-rlInterfaces');
|
$temp = snmpwalk_cache_multi_oid($device, 'swIfOperSuspendedStatus', [], 'CISCOSB-rlInterfaces');
|
||||||
$cur_oid = '.1.3.6.1.4.1.9.6.1.101.43.1.1.24.';
|
$cur_oid = '.1.3.6.1.4.1.9.6.1.101.43.1.1.24.';
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ if (is_array($temp)) {
|
|||||||
foreach ($temp as $index => $entry) {
|
foreach ($temp as $index => $entry) {
|
||||||
$port_data = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
$port_data = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_data['ifDescr'] . ' Suspended Status';
|
$descr = $port_data['ifDescr'] . ' Suspended Status';
|
||||||
if (str_contains($descr, ['ethernet','Ethernet']) && $port_data['ifOperStatus'] !== 'notPresent') {
|
if (Str::contains($descr, ['ethernet', 'Ethernet']) && $port_data['ifOperStatus'] !== 'notPresent') {
|
||||||
//Discover Sensors
|
//Discover Sensors
|
||||||
discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['swIfOperSuspendedStatus'], 'snmp', $index);
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['swIfOperSuspendedStatus'], 'snmp', $index);
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
* @author Marcus Pink <mpink@avantgarde-labs.de>
|
* @author Marcus Pink <mpink@avantgarde-labs.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$serverscheck_oids = [
|
$serverscheck_oids = [
|
||||||
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
||||||
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
||||||
@ -32,7 +34,7 @@ $serverscheck_oids = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
||||||
if ((str_contains($oid_name, 'name')) && (str_contains($oid_value, ['Flooding', 'Leckage']))) {
|
if ((Str::contains($oid_name, 'name')) && (Str::contains($oid_value, ['Flooding', 'Leckage']))) {
|
||||||
preg_match("/(\d+)/", $oid_name, $temp_x);
|
preg_match("/(\d+)/", $oid_name, $temp_x);
|
||||||
$tmp_oid = 'sensor' . $temp_x[0] . 'Value.0';
|
$tmp_oid = 'sensor' . $temp_x[0] . 'Value.0';
|
||||||
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* requires snmp extend agent script from librenms-agent
|
* requires snmp extend agent script from librenms-agent
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
$sensor_oid = ".1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.1";
|
$sensor_oid = ".1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.1";
|
||||||
@ -15,7 +16,7 @@ if (is_numeric($value)) {
|
|||||||
discover_sensor($valid['sensor'], 'temperature', $device, $sensor_oid, 1, $sensor_type, $descr, 1, 1, null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'temperature', $device, $sensor_oid, 1, $sensor_type, $descr, 1, 1, null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.232.')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.232.')) {
|
||||||
echo 'HP_ILO ';
|
echo 'HP_ILO ';
|
||||||
$oids = snmp_walk($device, '.1.3.6.1.4.1.232.6.2.6.8.1.2.1', '-Osqn', '');
|
$oids = snmp_walk($device, '.1.3.6.1.4.1.232.6.2.6.8.1.2.1', '-Osqn', '');
|
||||||
$oids = trim($oids);
|
$oids = trim($oids);
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
* @author Neil Lathwood <gh+n@laf.io>
|
* @author Neil Lathwood <gh+n@laf.io>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$serverscheck_oids = [
|
$serverscheck_oids = [
|
||||||
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
||||||
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
||||||
@ -33,10 +35,10 @@ $serverscheck_oids = [
|
|||||||
|
|
||||||
$temp_x = 1;
|
$temp_x = 1;
|
||||||
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
||||||
if (str_contains($oid_name, 'name')) {
|
if (Str::contains($oid_name, 'name')) {
|
||||||
$tmp_oid = 'sensor' . $temp_x . 'Value.0';
|
$tmp_oid = 'sensor' . $temp_x . 'Value.0';
|
||||||
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
||||||
if (str_contains($oid_value, ['Temp', 'BR'])) {
|
if (Str::contains($oid_value, ['Temp', 'BR'])) {
|
||||||
if (is_numeric($current)) {
|
if (is_numeric($current)) {
|
||||||
$index = str_replace('.0', '', $oid_name);
|
$index = str_replace('.0', '', $oid_name);
|
||||||
$descr = $oid_value;
|
$descr = $oid_value;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$regexp = '/
|
$regexp = '/
|
||||||
\.1\.3\.6\.1\.4\.1\.22626\.1\.5\.2\.
|
\.1\.3\.6\.1\.4\.1\.22626\.1\.5\.2\.
|
||||||
(?P<id>\d+)
|
(?P<id>\d+)
|
||||||
@ -51,7 +53,7 @@ if ($oids) {
|
|||||||
$temp_unit = snmp_get($device, 'tempUnit.0', '-OevTQUs', 'T3610-MIB');
|
$temp_unit = snmp_get($device, 'tempUnit.0', '-OevTQUs', 'T3610-MIB');
|
||||||
$user_func = '';
|
$user_func = '';
|
||||||
|
|
||||||
if (str_contains($temp_unit, 'F')) {
|
if (Str::contains($temp_unit, 'F')) {
|
||||||
$user_func = 'fahrenheit_to_celsius';
|
$user_func = 'fahrenheit_to_celsius';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$valid_toner = array();
|
$valid_toner = array();
|
||||||
|
|
||||||
if ($device['os_group'] == 'printer') {
|
if ($device['os_group'] == 'printer') {
|
||||||
@ -37,7 +39,7 @@ if ($device['os_group'] == 'printer') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trim part & serial number from devices that include it
|
// trim part & serial number from devices that include it
|
||||||
if (str_contains($descr, ', PN')) {
|
if (Str::contains($descr, ', PN')) {
|
||||||
$descr = explode(', PN', $descr)[0];
|
$descr = explode(', PN', $descr)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Exceptions\HostExistsException;
|
use LibreNMS\Exceptions\HostExistsException;
|
||||||
use LibreNMS\Exceptions\HostIpExistsException;
|
use LibreNMS\Exceptions\HostIpExistsException;
|
||||||
@ -124,7 +125,7 @@ function parse_modules($type, $options)
|
|||||||
Config::set("{$type}_modules", []);
|
Config::set("{$type}_modules", []);
|
||||||
foreach (explode(',', $options['m']) as $module) {
|
foreach (explode(',', $options['m']) as $module) {
|
||||||
// parse submodules (only supported by some modules)
|
// parse submodules (only supported by some modules)
|
||||||
if (str_contains($module, '/')) {
|
if (Str::contains($module, '/')) {
|
||||||
list($module, $submodule) = explode('/', $module, 2);
|
list($module, $submodule) = explode('/', $module, 2);
|
||||||
$existing_submodules = Config::get("{$type}_submodules.$module", []);
|
$existing_submodules = Config::get("{$type}_submodules.$module", []);
|
||||||
$existing_submodules[] = $submodule;
|
$existing_submodules[] = $submodule;
|
||||||
@ -228,16 +229,16 @@ function checkDiscovery($device, $array)
|
|||||||
{
|
{
|
||||||
// all items must be true
|
// all items must be true
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if ($check = ends_with($key, '_except')) {
|
if ($check = Str::endsWith($key, '_except')) {
|
||||||
$key = substr($key, 0, -7);
|
$key = substr($key, 0, -7);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key == 'sysObjectID') {
|
if ($key == 'sysObjectID') {
|
||||||
if (starts_with($device['sysObjectID'], $value) == $check) {
|
if (Str::startsWith($device['sysObjectID'], $value) == $check) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} elseif ($key == 'sysDescr') {
|
} elseif ($key == 'sysDescr') {
|
||||||
if (str_contains($device['sysDescr'], $value) == $check) {
|
if (Str::contains($device['sysDescr'], $value) == $check) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} elseif ($key == 'sysDescr_regex') {
|
} elseif ($key == 'sysDescr_regex') {
|
||||||
@ -312,17 +313,17 @@ function compare_var($a, $b, $comparison = '=')
|
|||||||
case "<":
|
case "<":
|
||||||
return $a < $b;
|
return $a < $b;
|
||||||
case "contains":
|
case "contains":
|
||||||
return str_contains($a, $b);
|
return Str::contains($a, $b);
|
||||||
case "not_contains":
|
case "not_contains":
|
||||||
return !str_contains($a, $b);
|
return !Str::contains($a, $b);
|
||||||
case "starts":
|
case "starts":
|
||||||
return starts_with($a, $b);
|
return Str::startsWith($a, $b);
|
||||||
case "not_starts":
|
case "not_starts":
|
||||||
return !starts_with($a, $b);
|
return !Str::startsWith($a, $b);
|
||||||
case "ends":
|
case "ends":
|
||||||
return ends_with($a, $b);
|
return Str::endsWith($a, $b);
|
||||||
case "not_ends":
|
case "not_ends":
|
||||||
return !ends_with($a, $b);
|
return !Str::endsWith($a, $b);
|
||||||
case "regex":
|
case "regex":
|
||||||
return (bool)preg_match($b, $a);
|
return (bool)preg_match($b, $a);
|
||||||
case "not regex":
|
case "not regex":
|
||||||
@ -351,7 +352,7 @@ function percent_colour($perc)
|
|||||||
function getLogo($device)
|
function getLogo($device)
|
||||||
{
|
{
|
||||||
$img = getImageName($device, true, 'images/logos/');
|
$img = getImageName($device, true, 'images/logos/');
|
||||||
if (!starts_with($img, 'generic')) {
|
if (!Str::startsWith($img, 'generic')) {
|
||||||
return 'images/logos/' . $img;
|
return 'images/logos/' . $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,14 +1090,14 @@ function is_port_valid($port, $device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (Config::getCombined($device['os'], 'bad_iftype') as $bt) {
|
foreach (Config::getCombined($device['os'], 'bad_iftype') as $bt) {
|
||||||
if (str_contains($ifType, $bt)) {
|
if (Str::contains($ifType, $bt)) {
|
||||||
d_echo("ignored by ifType: $ifType (matched: $bt )\n");
|
d_echo("ignored by ifType: $ifType (matched: $bt )\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Config::getCombined($device['os'], 'bad_ifoperstatus') as $bos) {
|
foreach (Config::getCombined($device['os'], 'bad_ifoperstatus') as $bos) {
|
||||||
if (str_contains($ifOperStatus, $bos)) {
|
if (Str::contains($ifOperStatus, $bos)) {
|
||||||
d_echo("ignored by ifOperStatus: $ifOperStatus (matched: $bos)\n");
|
d_echo("ignored by ifOperStatus: $ifOperStatus (matched: $bos)\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1948,7 +1949,7 @@ function get_toner_levels($device, $raw_value, $capacity)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} elseif ($device['os'] == 'brother') {
|
} elseif ($device['os'] == 'brother') {
|
||||||
if (!str_contains($device['hardware'], 'MFC-L8850')) {
|
if (!Str::contains($device['hardware'], 'MFC-L8850')) {
|
||||||
switch ($raw_value) {
|
switch ($raw_value) {
|
||||||
case '0':
|
case '0':
|
||||||
return 100;
|
return 100;
|
||||||
|
@ -18,13 +18,15 @@ use App\Models\PortsFdb;
|
|||||||
use App\Models\Sensor;
|
use App\Models\Sensor;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Alerting\QueryBuilderParser;
|
use LibreNMS\Alerting\QueryBuilderParser;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Data\Store\Datastore;
|
use LibreNMS\Data\Store\Datastore;
|
||||||
use LibreNMS\Exceptions\InvalidIpException;
|
use LibreNMS\Exceptions\InvalidIpException;
|
||||||
use LibreNMS\Util\IPv4;
|
|
||||||
use LibreNMS\Util\IP;
|
use LibreNMS\Util\IP;
|
||||||
|
use LibreNMS\Util\IPv4;
|
||||||
|
|
||||||
function api_success($result, $result_name, $message = null, $code = 200, $count = null, $extra = null)
|
function api_success($result, $result_name, $message = null, $code = 200, $count = null, $extra = null)
|
||||||
{
|
{
|
||||||
@ -160,7 +162,7 @@ function get_port_stats_by_port_hostname(\Illuminate\Http\Request $request)
|
|||||||
$ifName = $request->route('ifname');
|
$ifName = $request->route('ifname');
|
||||||
|
|
||||||
// handle %2f in paths and pass to get_graph_by_port_hostname if needed
|
// handle %2f in paths and pass to get_graph_by_port_hostname if needed
|
||||||
if (str_contains($ifName, '/')) {
|
if (Str::contains($ifName, '/')) {
|
||||||
$parts = explode('/', $request->path());
|
$parts = explode('/', $request->path());
|
||||||
|
|
||||||
if (isset($parts[5])) {
|
if (isset($parts[5])) {
|
||||||
@ -211,7 +213,7 @@ function get_graph_generic_by_hostname(\Illuminate\Http\Request $request)
|
|||||||
$vars['output'] = $request->get('output', 'display');
|
$vars['output'] = $request->get('output', 'display');
|
||||||
if (isset($sensor_id)) {
|
if (isset($sensor_id)) {
|
||||||
$vars['id'] = $sensor_id;
|
$vars['id'] = $sensor_id;
|
||||||
if (str_contains($vars['type'], '_wireless')) {
|
if (Str::contains($vars['type'], '_wireless')) {
|
||||||
$vars['type'] = str_replace('device_', '', $vars['type']);
|
$vars['type'] = str_replace('device_', '', $vars['type']);
|
||||||
} else {
|
} else {
|
||||||
// If this isn't a wireless graph we need to fix the name.
|
// If this isn't a wireless graph we need to fix the name.
|
||||||
@ -483,7 +485,7 @@ function show_endpoints(\Illuminate\Http\Request $request, Router $router)
|
|||||||
$base = str_replace('api/v0', '', $request->url());
|
$base = str_replace('api/v0', '', $request->url());
|
||||||
foreach ($router->getRoutes() as $route) {
|
foreach ($router->getRoutes() as $route) {
|
||||||
/** @var \Illuminate\Routing\Route $route */
|
/** @var \Illuminate\Routing\Route $route */
|
||||||
if (starts_with($route->getPrefix(), 'api/v0') && $route->getName()) {
|
if (Str::startsWith($route->getPrefix(), 'api/v0') && $route->getName()) {
|
||||||
$output[$route->getName()] = $base . $route->uri();
|
$output[$route->getName()] = $base . $route->uri();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -633,7 +635,7 @@ function get_graph_by_portgroup(\Illuminate\Http\Request $request)
|
|||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$ports = get_ports_from_type(explode(',', $group));
|
$ports = get_ports_from_type(explode(',', $group));
|
||||||
$if_list = implode(',', array_pluck($ports, 'port_id'));
|
$if_list = implode(',', Arr::pluck($ports, 'port_id'));
|
||||||
} else {
|
} else {
|
||||||
$if_list = $id;
|
$if_list = $id;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
* @author Neil Lathwood <gh+n@laf.io>
|
* @author Neil Lathwood <gh+n@laf.io>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Alerting\QueryBuilderParser;
|
use LibreNMS\Alerting\QueryBuilderParser;
|
||||||
|
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
@ -159,9 +160,9 @@ if (is_numeric($rule_id) && $rule_id > 0) {
|
|||||||
$groups = [];
|
$groups = [];
|
||||||
$locations = [];
|
$locations = [];
|
||||||
foreach ((array)$vars['maps'] as $item) {
|
foreach ((array)$vars['maps'] as $item) {
|
||||||
if (starts_with($item, 'l')) {
|
if (Str::startsWith($item, 'l')) {
|
||||||
$locations[] = (int)substr($item, 1);
|
$locations[] = (int)substr($item, 1);
|
||||||
} elseif (starts_with($item, 'g')) {
|
} elseif (Str::startsWith($item, 'g')) {
|
||||||
$groups[] = (int)substr($item, 1);
|
$groups[] = (int)substr($item, 1);
|
||||||
} else {
|
} else {
|
||||||
$devices[] = (int)$item;
|
$devices[] = (int)$item;
|
||||||
@ -176,7 +177,7 @@ if (is_numeric($rule_id) && $rule_id > 0) {
|
|||||||
$transports = [];
|
$transports = [];
|
||||||
$groups = [];
|
$groups = [];
|
||||||
foreach ((array)$vars['transports'] as $item) {
|
foreach ((array)$vars['transports'] as $item) {
|
||||||
if (starts_with($item, 'g')) {
|
if (Str::startsWith($item, 'g')) {
|
||||||
$groups[] = (int)substr($item, 1);
|
$groups[] = (int)substr($item, 1);
|
||||||
} else {
|
} else {
|
||||||
$transports[] = (int)$item;
|
$transports[] = (int)$item;
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
* @author Tony Murray <murraytony@gmail.com>
|
* @author Tony Murray <murraytony@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
if (!Auth::user()->hasGlobalAdmin()) {
|
if (!Auth::user()->hasGlobalAdmin()) {
|
||||||
@ -50,7 +52,7 @@ $new_title = convert_template($vars['title']);
|
|||||||
|
|
||||||
function convert_template($line)
|
function convert_template($line)
|
||||||
{
|
{
|
||||||
if (str_contains($line, '{calc')) {
|
if (Str::contains($line, '{calc')) {
|
||||||
return preg_replace(
|
return preg_replace(
|
||||||
[
|
[
|
||||||
'/{calc[ ]*([\w\d\s\%\.\(\)\*\/\-\+\/]+)}/',// Replaces {calc (something*100)}
|
'/{calc[ ]*([\w\d\s\%\.\(\)\*\/\-\+\/]+)}/',// Replaces {calc (something*100)}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LibreNMS
|
* LibreNMS
|
||||||
*
|
*
|
||||||
@ -126,10 +128,10 @@ if ($sub_type == 'new-maintenance') {
|
|||||||
|
|
||||||
foreach ($_POST['maps'] as $target) {
|
foreach ($_POST['maps'] as $target) {
|
||||||
$type = 'device';
|
$type = 'device';
|
||||||
if (starts_with($target, 'l')) {
|
if (Str::startsWith($target, 'l')) {
|
||||||
$type = 'location';
|
$type = 'location';
|
||||||
$target = substr($target, 1);
|
$target = substr($target, 1);
|
||||||
} elseif (starts_with($target, 'g')) {
|
} elseif (Str::startsWith($target, 'g')) {
|
||||||
$type = 'device_group';
|
$type = 'device_group';
|
||||||
$target = substr($target, 1);
|
$target = substr($target, 1);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Exceptions\InvalidIpException;
|
use LibreNMS\Exceptions\InvalidIpException;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
use LibreNMS\Util\IP;
|
use LibreNMS\Util\IP;
|
||||||
@ -236,7 +237,7 @@ if (\LibreNMS\Config::get('enable_bgp')) {
|
|||||||
foreach ($oid_map as $source => $target) {
|
foreach ($oid_map as $source => $target) {
|
||||||
$v = isset($peer_data_raw[$source]) ? $peer_data_raw[$source] : '';
|
$v = isset($peer_data_raw[$source]) ? $peer_data_raw[$source] : '';
|
||||||
|
|
||||||
if (str_contains($source, 'LocalAddr')) {
|
if (Str::contains($source, 'LocalAddr')) {
|
||||||
try {
|
try {
|
||||||
$v = IP::fromHexString($v)->uncompressed();
|
$v = IP::fromHexString($v)->uncompressed();
|
||||||
} catch (InvalidIpException $e) {
|
} catch (InvalidIpException $e) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
use LibreNMS\Exceptions\JsonAppException;
|
use LibreNMS\Exceptions\JsonAppException;
|
||||||
@ -572,7 +573,7 @@ function update_application($app, $response, $metrics = array(), $status = '')
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($response != '' && $response !== false) {
|
if ($response != '' && $response !== false) {
|
||||||
if (str_contains($response, array(
|
if (Str::contains($response, array(
|
||||||
'Traceback (most recent call last):',
|
'Traceback (most recent call last):',
|
||||||
))) {
|
))) {
|
||||||
$data['app_state'] = 'ERROR';
|
$data['app_state'] = 'ERROR';
|
||||||
|
@ -10,21 +10,23 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
||||||
$temp_mibs = 'ECS4510-MIB';
|
$temp_mibs = 'ECS4510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ECS3528
|
||||||
$temp_mibs = 'ES3528MV2-MIB';
|
$temp_mibs = 'ES3528MV2-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
||||||
$temp_mibs = 'ECS4110-MIB';
|
$temp_mibs = 'ECS4110-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
||||||
$temp_mibs = 'ECS4120-MIB';
|
$temp_mibs = 'ECS4120-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
||||||
$temp_mibs = 'ECS4210-MIB';
|
$temp_mibs = 'ECS4210-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
||||||
$temp_mibs = 'ECS3510-MIB';
|
$temp_mibs = 'ECS3510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11.')) { //ECS3510MA
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11.')) { //ECS3510MA
|
||||||
$temp_mibs = 'ES3510MA-MIB';
|
$temp_mibs = 'ES3510MA-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
||||||
$temp_mibs = 'ECS2100-MIB';
|
$temp_mibs = 'ECS2100-MIB';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$oid = $mempool['mempool_index'];
|
$oid = $mempool['mempool_index'];
|
||||||
|
|
||||||
d_echo('Ironware Mempool'."\n");
|
d_echo('Ironware Mempool'."\n");
|
||||||
|
|
||||||
if (str_contains($device['sysDescr'], array('NetIron', 'MLX', 'CER')) === false) {
|
if (Str::contains($device['sysDescr'], array('NetIron', 'MLX', 'CER')) === false) {
|
||||||
echo 'Ironware Dynamic: ';
|
echo 'Ironware Dynamic: ';
|
||||||
$mempool['total'] = snmp_get($device, 'snAgGblDynMemTotal.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
|
$mempool['total'] = snmp_get($device, 'snAgGblDynMemTotal.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
|
||||||
if ($mempool['total'] < 0) {
|
if ($mempool['total'] < 0) {
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
echo 'SonicWALL-MEMORY-POOL: ';
|
echo 'SonicWALL-MEMORY-POOL: ';
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) {
|
||||||
$usage = snmp_get($device, 'SNWL-SSLVPN-MIB::memoryUtilization.0', '-Ovq');
|
$usage = snmp_get($device, 'SNWL-SSLVPN-MIB::memoryUtilization.0', '-Ovq');
|
||||||
} else {
|
} else {
|
||||||
$usage = snmp_get($device, 'SONICWALL-FIREWALL-IP-STATISTICS-MIB::sonicCurrentRAMUtil.0', '-Ovq');
|
$usage = snmp_get($device, 'SONICWALL-FIREWALL-IP-STATISTICS-MIB::sonicCurrentRAMUtil.0', '-Ovq');
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
if (!Str::startsWith($device['os'], array('Snom', 'asa'))) {
|
||||||
echo ' ICMP';
|
echo ' ICMP';
|
||||||
|
|
||||||
// Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
// Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
if (!Str::startsWith($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' IP';
|
echo ' IP';
|
||||||
|
|
||||||
$oids = [
|
$oids = [
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
if (!Str::startsWith($device['os'], array('Snom', 'asa'))) {
|
||||||
echo ' IP-FORWARD';
|
echo ' IP-FORWARD';
|
||||||
|
|
||||||
$oid = 'ipCidrRouteNumber';
|
$oid = 'ipCidrRouteNumber';
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
if (!Str::startsWith($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' TCP';
|
echo ' TCP';
|
||||||
$oids = [
|
$oids = [
|
||||||
'tcpActiveOpens',
|
'tcpActiveOpens',
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
if (!Str::startsWith($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' UDP';
|
echo ' UDP';
|
||||||
|
|
||||||
$oids = [
|
$oids = [
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
if (strpos($device['sysDescr'], 'Software')) {
|
if (strpos($device['sysDescr'], 'Software')) {
|
||||||
$hardware = str_replace("3Com ", '', substr($device['sysDescr'], 0, strpos($device['sysDescr'], 'Software')));
|
$hardware = str_replace("3Com ", '', substr($device['sysDescr'], 0, strpos($device['sysDescr'], 'Software')));
|
||||||
// Version is the last word in the sysDescr's first line
|
// Version is the last word in the sysDescr's first line
|
||||||
@ -7,7 +10,7 @@ if (strpos($device['sysDescr'], 'Software')) {
|
|||||||
$hardware = str_replace("3Com ", '', $device['sysDescr']);
|
$hardware = str_replace("3Com ", '', $device['sysDescr']);
|
||||||
$version = '';
|
$version = '';
|
||||||
// Old Stack Units
|
// Old Stack Units
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.43.10.27.4.1.')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.43.10.27.4.1.')) {
|
||||||
$oids = ['stackUnitDesc.1', 'stackUnitPromVersion.1', 'stackUnitSWVersion.1', 'stackUnitSerialNumber.1','stackUnitCapabilities.1'];
|
$oids = ['stackUnitDesc.1', 'stackUnitPromVersion.1', 'stackUnitSWVersion.1', 'stackUnitSerialNumber.1','stackUnitCapabilities.1'];
|
||||||
$data = snmp_get_multi($device, $oids, ['-OQUs','--hexOutputLength=0'], 'A3COM0352-STACK-CONFIG');
|
$data = snmp_get_multi($device, $oids, ['-OQUs','--hexOutputLength=0'], 'A3COM0352-STACK-CONFIG');
|
||||||
$hardware .= ' ' . $data[1]['stackUnitDesc'];
|
$hardware .= ' ' . $data[1]['stackUnitDesc'];
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
* option) any later version. Please see LICENSE.txt at the top level of
|
* option) any later version. Please see LICENSE.txt at the top level of
|
||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
if (!ends_with($device['hardware'], 'sc')) {
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (!Str::endsWith($device['hardware'], 'sc')) {
|
||||||
$oids = ['entPhysicalModelName.1', 'entPhysicalSoftwareRev.1', 'entPhysicalSerialNum.1', 'entPhysicalModelName.4', 'entPhysicalSoftwareRev.4'];
|
$oids = ['entPhysicalModelName.1', 'entPhysicalSoftwareRev.1', 'entPhysicalSerialNum.1', 'entPhysicalModelName.4', 'entPhysicalSoftwareRev.4'];
|
||||||
|
|
||||||
$data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB');
|
$data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB');
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$avocent_tmp = snmp_get_multi_oid($device, ['pmProductModel.0', 'pmSerialNumber.0', 'pmFirmwareVersion.0'], '-OUQs', 'PM-MIB');
|
$avocent_tmp = snmp_get_multi_oid($device, ['pmProductModel.0', 'pmSerialNumber.0', 'pmFirmwareVersion.0'], '-OUQs', 'PM-MIB');
|
||||||
|
|
||||||
$hardware = $avocent_tmp['pmProductModel.0'];
|
$hardware = $avocent_tmp['pmProductModel.0'];
|
||||||
@ -7,9 +9,9 @@ $serial = $avocent_tmp['pmSerialNumber.0'];
|
|||||||
$version = $avocent_tmp['pmFirmwareVersion.0'];
|
$version = $avocent_tmp['pmFirmwareVersion.0'];
|
||||||
|
|
||||||
if (empty($hardware)) {
|
if (empty($hardware)) {
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.10418.16')) {
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.10418.16')) {
|
||||||
$avocent_oid = '.1.3.6.1.4.1.10418.16.2.1';
|
$avocent_oid = '.1.3.6.1.4.1.10418.16.2.1';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.10418.26')) {
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.10418.26')) {
|
||||||
$avocent_oid = '.1.3.6.1.4.1.10418.26.2.1';
|
$avocent_oid = '.1.3.6.1.4.1.10418.26.2.1';
|
||||||
}
|
}
|
||||||
if ($avocent_oid) {
|
if ($avocent_oid) {
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.6.')) { //ES3528M0
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.6.')) { //ES3528M0
|
||||||
$tmp_mib = 'ES3528MO-MIB';
|
$tmp_mib = 'ES3528MO-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ES3528MV2
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.22.')) { //ES3528MV2
|
||||||
$tmp_mib = 'ES3528MV2-MIB';
|
$tmp_mib = 'ES3528MV2-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //ECS4510
|
||||||
$tmp_mib = 'ECS4510-MIB';
|
$tmp_mib = 'ECS4510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.39.')) { //ECS4110
|
||||||
$tmp_mib = 'ECS4110-MIB';
|
$tmp_mib = 'ECS4110-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.42.')) { //ECS4210
|
||||||
$tmp_mib = 'ECS4210-MIB';
|
$tmp_mib = 'ECS4210-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.27.')) { //ECS3510
|
||||||
$tmp_mib = 'ECS3510-MIB';
|
$tmp_mib = 'ECS3510-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.45.')) { //ECS4120
|
||||||
$tmp_mib = 'ECS4120-MIB';
|
$tmp_mib = 'ECS4120-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11')) { //ES3510MA
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.8.1.11')) { //ES3510MA
|
||||||
$tmp_mib = 'ES3510MA-MIB';
|
$tmp_mib = 'ES3510MA-MIB';
|
||||||
} elseif (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
} elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100
|
||||||
$tmp_mib = 'ECS2100-MIB';
|
$tmp_mib = 'ECS2100-MIB';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,11 +10,13 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$data = explode(" ", $device['sysDescr']);
|
$data = explode(" ", $device['sysDescr']);
|
||||||
$hardware = $data[0];
|
$hardware = $data[0];
|
||||||
$version = $data[9];
|
$version = $data[9];
|
||||||
|
|
||||||
if (str_contains($device['sysDescr'], 'PLANET IGS-')) {
|
if (Str::contains($device['sysDescr'], 'PLANET IGS-')) {
|
||||||
$hardware = $data[1];
|
$hardware = $data[1];
|
||||||
$version = snmp_get($device, "1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq");
|
$version = snmp_get($device, "1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq");
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
* @copyright 2017 Paul Heinrichs
|
* @copyright 2017 Paul Heinrichs
|
||||||
* @author Paul Heinrichs<pdheinrichs@gmail.com>
|
* @author Paul Heinrichs<pdheinrichs@gmail.com>
|
||||||
*/
|
*/
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
$cambium_type = $device['sysDescr'];
|
$cambium_type = $device['sysDescr'];
|
||||||
$PMP = snmp_get($device, 'boxDeviceType.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
$PMP = snmp_get($device, 'boxDeviceType.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
||||||
@ -47,10 +49,10 @@ $pmp = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($ptp as $desc => $model) {
|
foreach ($ptp as $desc => $model) {
|
||||||
if (str_contains($cambium_type, $desc)) {
|
if (Str::contains($cambium_type, $desc)) {
|
||||||
$hardware = $model;
|
$hardware = $model;
|
||||||
|
|
||||||
if (str_contains($model, 'PTP')) {
|
if (Str::contains($model, 'PTP')) {
|
||||||
$masterSlaveMode = str_replace($filtered_words, "", snmp_get($device, 'bhTimingMode.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB'));
|
$masterSlaveMode = str_replace($filtered_words, "", snmp_get($device, 'bhTimingMode.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB'));
|
||||||
$hardware = $model . ' '. $masterSlaveMode;
|
$hardware = $model . ' '. $masterSlaveMode;
|
||||||
$version = snmp_get($device, 'boxDeviceTypeID.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
$version = snmp_get($device, 'boxDeviceTypeID.0', '-Oqv', 'WHISP-BOX-MIBV2-MIB');
|
||||||
@ -62,15 +64,15 @@ foreach ($ptp as $desc => $model) {
|
|||||||
if (!isset($hardware)) {
|
if (!isset($hardware)) {
|
||||||
$hardware = 'PMP 100';
|
$hardware = 'PMP 100';
|
||||||
foreach ($pmp as $desc => $model) {
|
foreach ($pmp as $desc => $model) {
|
||||||
if (str_contains($PMP, $desc)) {
|
if (Str::contains($PMP, $desc)) {
|
||||||
$hardware = $model;
|
$hardware = $model;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (str_contains($hardware, 'PMP')) {
|
if (Str::contains($hardware, 'PMP')) {
|
||||||
if (str_contains($version, "AP")) {
|
if (Str::contains($version, "AP")) {
|
||||||
$hardware .= ' AP';
|
$hardware .= ' AP';
|
||||||
} elseif (str_contains($version, "SM")) {
|
} elseif (Str::contains($version, "SM")) {
|
||||||
$hardware .= ' SM';
|
$hardware .= ' SM';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,18 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
|
$hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
|
||||||
$version = snmp_get($device, '.1.3.6.1.2.1.54.1.1.1.1.4.1', '-Osqv');
|
$version = snmp_get($device, '.1.3.6.1.2.1.54.1.1.1.1.4.1', '-Osqv');
|
||||||
|
|
||||||
$applist = snmp_walk($device, '.1.3.6.1.2.1.54.1.1.1.1.3', '-OQv');
|
$applist = snmp_walk($device, '.1.3.6.1.2.1.54.1.1.1.1.3', '-OQv');
|
||||||
if (str_contains($applist, "Cisco Unified CCX Database")) {
|
if (Str::contains($applist, "Cisco Unified CCX Database")) {
|
||||||
$features = "UCCX";
|
$features = "UCCX";
|
||||||
} elseif (str_contains($applist, "Cisco CallManager")) {
|
} elseif (Str::contains($applist, "Cisco CallManager")) {
|
||||||
$features = "CUCM";
|
$features = "CUCM";
|
||||||
} elseif (str_contains($applist, "Cisco Emergency Responder")) {
|
} elseif (Str::contains($applist, "Cisco Emergency Responder")) {
|
||||||
$features = "CER";
|
$features = "CER";
|
||||||
} elseif (str_contains($applist, "Connection System Agent")) {
|
} elseif (Str::contains($applist, "Connection System Agent")) {
|
||||||
$features = "CUC";
|
$features = "CUC";
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
// sysDescr.0 = STRING: Hardware: x86 Family 6 Model 1 Stepping 9 AT/AT COMPATIBLE - Software: Windows NT Version 4.0 (Build Number: 1381 Multiprocessor Free )
|
// sysDescr.0 = STRING: Hardware: x86 Family 6 Model 1 Stepping 9 AT/AT COMPATIBLE - Software: Windows NT Version 4.0 (Build Number: 1381 Multiprocessor Free )
|
||||||
// sysDescr.0 = STRING: Hardware: x86 Family 6 Model 3 Stepping 4 AT/AT COMPATIBLE - Software: Windows NT Version 3.51 (Build Number: 1057 Multiprocessor Free )
|
// sysDescr.0 = STRING: Hardware: x86 Family 6 Model 3 Stepping 4 AT/AT COMPATIBLE - Software: Windows NT Version 3.51 (Build Number: 1057 Multiprocessor Free )
|
||||||
// sysDescr.0 = STRING: Hardware: x86 Family 16 Model 4 Stepping 2 AT/AT COMPATIBLE - Software: Windows 2000 Version 5.1 (Build 2600 Multiprocessor Free)
|
// sysDescr.0 = STRING: Hardware: x86 Family 16 Model 4 Stepping 2 AT/AT COMPATIBLE - Software: Windows 2000 Version 5.1 (Build 2600 Multiprocessor Free)
|
||||||
@ -9,106 +11,106 @@
|
|||||||
// sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 23 Stepping 6 AT/AT COMPATIBLE - Software: Windows Version 6.1 (Build 7600 Multiprocessor Free)
|
// sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 23 Stepping 6 AT/AT COMPATIBLE - Software: Windows Version 6.1 (Build 7600 Multiprocessor Free)
|
||||||
// sysDescr.0 = STRING: Hardware: AMD64 Family 16 Model 8 Stepping 0 AT/AT COMPATIBLE - Software: Windows Version 6.1 (Build 7600 Multiprocessor Free)
|
// sysDescr.0 = STRING: Hardware: AMD64 Family 16 Model 8 Stepping 0 AT/AT COMPATIBLE - Software: Windows Version 6.1 (Build 7600 Multiprocessor Free)
|
||||||
|
|
||||||
if (str_contains($device['sysDescr'], 'AMD64')) {
|
if (Str::contains($device['sysDescr'], 'AMD64')) {
|
||||||
$hardware = 'AMD x64';
|
$hardware = 'AMD x64';
|
||||||
} elseif (str_contains($device['sysDescr'], array('EM64', 'Intel64'))) {
|
} elseif (Str::contains($device['sysDescr'], array('EM64', 'Intel64'))) {
|
||||||
$hardware = 'Intel x64';
|
$hardware = 'Intel x64';
|
||||||
} elseif (str_contains($device['sysDescr'], 'x86')) {
|
} elseif (Str::contains($device['sysDescr'], 'x86')) {
|
||||||
$hardware = 'Generic x86';
|
$hardware = 'Generic x86';
|
||||||
} elseif (str_contains($device['sysDescr'], 'ia64')) {
|
} elseif (Str::contains($device['sysDescr'], 'ia64')) {
|
||||||
$hardware = 'Intel Itanium IA64';
|
$hardware = 'Intel Itanium IA64';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') {
|
if ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') {
|
||||||
// Client
|
// Client
|
||||||
if (str_contains($device['sysDescr'], 'Build 14393')) {
|
if (Str::contains($device['sysDescr'], 'Build 14393')) {
|
||||||
$version = '10 AU (NT 6.3)';
|
$version = '10 AU (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 10586')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 10586')) {
|
||||||
$version = '10 U1 (NT 6.3)';
|
$version = '10 U1 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 10240')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 10240')) {
|
||||||
$version = '10 (NT 6.3)';
|
$version = '10 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9600')) {
|
||||||
$version = '8.1 U1 (NT 6.3)';
|
$version = '8.1 U1 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Version 6.3 (Build 9200')) {
|
} elseif (Str::contains($device['sysDescr'], 'Version 6.3 (Build 9200')) {
|
||||||
$version = '8.1 (NT 6.3)';
|
$version = '8.1 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9200')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9200')) {
|
||||||
$version = '8 (NT 6.2)';
|
$version = '8 (NT 6.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7601')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7601')) {
|
||||||
$version = '7 SP1 (NT 6.1)';
|
$version = '7 SP1 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7600')) {
|
||||||
$version = '7 (NT 6.1)';
|
$version = '7 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6002')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6002')) {
|
||||||
$version = 'Vista SP2 (NT 6.0)';
|
$version = 'Vista SP2 (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6001')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6001')) {
|
||||||
$version = 'Vista SP1 (NT 6.0)';
|
$version = 'Vista SP1 (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6000')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6000')) {
|
||||||
$version = 'Vista (NT 6.0)';
|
$version = 'Vista (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 3790')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 3790')) {
|
||||||
$version = 'XP x64 (NT 5.2)';
|
$version = 'XP x64 (NT 5.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 2600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 2600')) {
|
||||||
$version = 'XP (NT 5.1)';
|
$version = 'XP (NT 5.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 2195')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 2195')) {
|
||||||
$version = '2000 (NT 5.0)';
|
$version = '2000 (NT 5.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1381')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1381')) {
|
||||||
$version = 'NT 4.0 Workstation';
|
$version = 'NT 4.0 Workstation';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1057')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1057')) {
|
||||||
$version = 'NT 3.51 Workstation';
|
$version = 'NT 3.51 Workstation';
|
||||||
}
|
}
|
||||||
} elseif ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.2') {
|
} elseif ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.2') {
|
||||||
// Server
|
// Server
|
||||||
if (str_contains($device['sysDescr'], 'Build 14393')) {
|
if (Str::contains($device['sysDescr'], 'Build 14393')) {
|
||||||
$version = 'Server 2016 (NT 6.3)';
|
$version = 'Server 2016 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9600')) {
|
||||||
$version = 'Server 2012 R2 (NT 6.3)';
|
$version = 'Server 2012 R2 (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9200')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9200')) {
|
||||||
$version = 'Server 2012 (NT 6.2)';
|
$version = 'Server 2012 (NT 6.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7601')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7601')) {
|
||||||
$version = 'Server 2008 R2 SP1 (NT 6.1)';
|
$version = 'Server 2008 R2 SP1 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7600')) {
|
||||||
$version = 'Server 2008 R2 (NT 6.1)';
|
$version = 'Server 2008 R2 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6002')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6002')) {
|
||||||
$version = 'Server 2008 SP2 (NT 6.0)';
|
$version = 'Server 2008 SP2 (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6001')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6001')) {
|
||||||
$version = 'Server 2008 (NT 6.0)';
|
$version = 'Server 2008 (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 3790')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 3790')) {
|
||||||
$version = 'Server 2003 (NT 5.2)';
|
$version = 'Server 2003 (NT 5.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 2195')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 2195')) {
|
||||||
$version = '2000 Server (NT 5.0)';
|
$version = '2000 Server (NT 5.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1381')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1381')) {
|
||||||
$version = 'NT Server 4.0';
|
$version = 'NT Server 4.0';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1057')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1057')) {
|
||||||
$version = 'NT Server 3.51';
|
$version = 'NT Server 3.51';
|
||||||
}
|
}
|
||||||
} elseif ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.3') {
|
} elseif ($device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.3') {
|
||||||
// Datacenter
|
// Datacenter
|
||||||
if (str_contains($device['sysDescr'], 'Build 14393')) {
|
if (Str::contains($device['sysDescr'], 'Build 14393')) {
|
||||||
$version = 'Server 2016 Datacenter (NT 6.3)';
|
$version = 'Server 2016 Datacenter (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9600')) {
|
||||||
$version = 'Server 2012 R2 Datacenter (NT 6.3)';
|
$version = 'Server 2012 R2 Datacenter (NT 6.3)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 9200')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 9200')) {
|
||||||
$version = 'Server 2012 Datacenter (NT 6.2)';
|
$version = 'Server 2012 Datacenter (NT 6.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7601')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7601')) {
|
||||||
$version = 'Server 2008 Datacenter R2 SP1 (NT 6.1)';
|
$version = 'Server 2008 Datacenter R2 SP1 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 7600')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 7600')) {
|
||||||
$version = 'Server 2008 Datacenter R2 (NT 6.1)';
|
$version = 'Server 2008 Datacenter R2 (NT 6.1)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6002')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6002')) {
|
||||||
$version = 'Server 2008 Datacenter SP2 (NT 6.0)';
|
$version = 'Server 2008 Datacenter SP2 (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 6001')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 6001')) {
|
||||||
$version = 'Server 2008 Datacenter (NT 6.0)';
|
$version = 'Server 2008 Datacenter (NT 6.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 3790')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 3790')) {
|
||||||
$version = 'Server 2003 Datacenter (NT 5.2)';
|
$version = 'Server 2003 Datacenter (NT 5.2)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build 2195')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build 2195')) {
|
||||||
$version = '2000 Datacenter Server (NT 5.0)';
|
$version = '2000 Datacenter Server (NT 5.0)';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1381')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1381')) {
|
||||||
$version = 'NT Datacenter 4.0';
|
$version = 'NT Datacenter 4.0';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Build Number: 1057')) {
|
} elseif (Str::contains($device['sysDescr'], 'Build Number: 1057')) {
|
||||||
$version = 'NT Datacenter 3.51';
|
$version = 'NT Datacenter 3.51';
|
||||||
}
|
}
|
||||||
}//end version if
|
}//end version if
|
||||||
|
|
||||||
if (str_contains($device['sysDescr'], 'Multiprocessor')) {
|
if (Str::contains($device['sysDescr'], 'Multiprocessor')) {
|
||||||
$features = 'Multiprocessor';
|
$features = 'Multiprocessor';
|
||||||
} elseif (str_contains($device['sysDescr'], 'Uniprocessor')) {
|
} elseif (Str::contains($device['sysDescr'], 'Uniprocessor')) {
|
||||||
$features = 'Uniprocessor';
|
$features = 'Uniprocessor';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
// ESI-MIB::genProductNumber.0 .1.3.6.1.4.1.683.1.4.0
|
// ESI-MIB::genProductNumber.0 .1.3.6.1.4.1.683.1.4.0
|
||||||
// ESI-MIB::genSerialNumber.0 .1.3.6.1.4.1.683.1.5.0
|
// ESI-MIB::genSerialNumber.0 .1.3.6.1.4.1.683.1.5.0
|
||||||
// ESI-MIB::genVersion.0 .1.3.6.1.4.1.683.1.9.0
|
// ESI-MIB::genVersion.0 .1.3.6.1.4.1.683.1.9.0
|
||||||
if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.683')) {
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.683')) {
|
||||||
$oids = array(
|
$oids = array(
|
||||||
'hardware' => '.1.3.6.1.4.1.683.1.4.0',
|
'hardware' => '.1.3.6.1.4.1.683.1.4.0',
|
||||||
'serial' => '.1.3.6.1.4.1.683.1.5.0',
|
'serial' => '.1.3.6.1.4.1.683.1.5.0',
|
||||||
@ -38,7 +40,7 @@ if (starts_with($device['sysObjectID'], '.1.3.6.1.4.1.683')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($device['sysDescr'], 'Wireless')) {
|
if (Str::contains($device['sysDescr'], 'Wireless')) {
|
||||||
$features = 'wireless';
|
$features = 'wireless';
|
||||||
} else {
|
} else {
|
||||||
$features = 'wired';
|
$features = 'wired';
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ function snmp_get_multi($device, $oids, $options = '-OQUs', $mib = null, $mibdir
|
|||||||
$value = trim($value, "\" \n\r");
|
$value = trim($value, "\" \n\r");
|
||||||
list($oid, $index) = explode('.', $oid, 2);
|
list($oid, $index) = explode('.', $oid, 2);
|
||||||
|
|
||||||
if (!str_contains($value, 'at this OID')) {
|
if (!Str::contains($value, 'at this OID')) {
|
||||||
if (is_null($index)) {
|
if (is_null($index)) {
|
||||||
if (empty($oid)) {
|
if (empty($oid)) {
|
||||||
continue; // no index or oid
|
continue; // no index or oid
|
||||||
@ -233,7 +234,7 @@ function snmp_get_multi_oid($device, $oids, $options = '-OUQn', $mib = null, $mi
|
|||||||
$array = array();
|
$array = array();
|
||||||
$oid = '';
|
$oid = '';
|
||||||
foreach ($data as $entry) {
|
foreach ($data as $entry) {
|
||||||
if (str_contains($entry, '=')) {
|
if (Str::contains($entry, '=')) {
|
||||||
list($oid,$value) = explode('=', $entry, 2);
|
list($oid,$value) = explode('=', $entry, 2);
|
||||||
$oid = trim($oid);
|
$oid = trim($oid);
|
||||||
$value = trim($value, "\\\" \n\r");
|
$value = trim($value, "\\\" \n\r");
|
||||||
@ -341,7 +342,7 @@ function snmp_getnext_multi($device, $oids, $options = '-OQUs', $mib = null, $mi
|
|||||||
$oid = trim($oid);
|
$oid = trim($oid);
|
||||||
$value = trim($value, "\" \n\r");
|
$value = trim($value, "\" \n\r");
|
||||||
list($oid, $index) = explode('.', $oid, 2);
|
list($oid, $index) = explode('.', $oid, 2);
|
||||||
if (!str_contains($value, 'at this OID')) {
|
if (!Str::contains($value, 'at this OID')) {
|
||||||
if (empty($oid)) {
|
if (empty($oid)) {
|
||||||
continue; // no index or oid
|
continue; // no index or oid
|
||||||
} else {
|
} else {
|
||||||
@ -390,7 +391,7 @@ function snmp_walk($device, $oid, $options = null, $mib = null, $mibdir = null)
|
|||||||
d_echo("Invalid snmp_walk() data = " . print_r($data, true));
|
d_echo("Invalid snmp_walk() data = " . print_r($data, true));
|
||||||
$data = false;
|
$data = false;
|
||||||
} else {
|
} else {
|
||||||
if (ends_with($data, '(It is past the end of the MIB tree)')) {
|
if (Str::endsWith($data, '(It is past the end of the MIB tree)')) {
|
||||||
$no_more_pattern = '/.*No more variables left in this MIB View \(It is past the end of the MIB tree\)[\n]?/';
|
$no_more_pattern = '/.*No more variables left in this MIB View \(It is past the end of the MIB tree\)[\n]?/';
|
||||||
$data = preg_replace($no_more_pattern, '', $data);
|
$data = preg_replace($no_more_pattern, '', $data);
|
||||||
}
|
}
|
||||||
@ -645,7 +646,7 @@ function snmpwalk_group($device, $oid, $mib = '', $depth = 1, $array = array(),
|
|||||||
|
|
||||||
$line = strtok($data, "\n");
|
$line = strtok($data, "\n");
|
||||||
while ($line !== false) {
|
while ($line !== false) {
|
||||||
if (str_contains($line, 'at this OID')||str_contains($line, 'this MIB View')) {
|
if (Str::contains($line, 'at this OID') || Str::contains($line, 'this MIB View')) {
|
||||||
$line = strtok("\n");
|
$line = strtok("\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -656,7 +657,7 @@ function snmpwalk_group($device, $oid, $mib = '', $depth = 1, $array = array(),
|
|||||||
array_splice($parts, $depth, 0, array_shift($parts)); // move the oid name to the correct depth
|
array_splice($parts, $depth, 0, array_shift($parts)); // move the oid name to the correct depth
|
||||||
|
|
||||||
$line = strtok("\n"); // get the next line and concatenate multi-line values
|
$line = strtok("\n"); // get the next line and concatenate multi-line values
|
||||||
while ($line !== false && !str_contains($line, '=')) {
|
while ($line !== false && !Str::contains($line, '=')) {
|
||||||
$value .= $line . PHP_EOL;
|
$value .= $line . PHP_EOL;
|
||||||
$line = strtok("\n");
|
$line = strtok("\n");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Authentication\LegacyAuth;
|
use LibreNMS\Authentication\LegacyAuth;
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ echo "Authentication Method: " . Config::get('auth_mechanism') . PHP_EOL;
|
|||||||
// if ldap like, check selinux
|
// if ldap like, check selinux
|
||||||
if (Config::get('auth_mechanism') == 'ldap' || Config::get('auth_mechanism') == "active_directory") {
|
if (Config::get('auth_mechanism') == 'ldap' || Config::get('auth_mechanism') == "active_directory") {
|
||||||
$enforce = shell_exec('getenforce 2>/dev/null');
|
$enforce = shell_exec('getenforce 2>/dev/null');
|
||||||
if (str_contains($enforce, 'Enforcing')) {
|
if (Str::contains($enforce, 'Enforcing')) {
|
||||||
// has selinux
|
// has selinux
|
||||||
$output = shell_exec('getsebool httpd_can_connect_ldap');
|
$output = shell_exec('getsebool httpd_can_connect_ldap');
|
||||||
if ($output != "httpd_can_connect_ldap --> on\n") {
|
if ($output != "httpd_can_connect_ldap --> on\n") {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$install_dir = realpath(__DIR__ . '/..');
|
$install_dir = realpath(__DIR__ . '/..');
|
||||||
chdir($install_dir);
|
chdir($install_dir);
|
||||||
@ -36,7 +37,7 @@ if (isset($options['h'])) {
|
|||||||
if (is_numeric($options['h'])) {
|
if (is_numeric($options['h'])) {
|
||||||
$where = "AND `device_id` = ?";
|
$where = "AND `device_id` = ?";
|
||||||
$params = array($options['h']);
|
$params = array($options['h']);
|
||||||
} elseif (str_contains($options['h'], ',')) {
|
} elseif (Str::contains($options['h'], ',')) {
|
||||||
$device_ids = array_map('trim', explode(',', $options['h']));
|
$device_ids = array_map('trim', explode(',', $options['h']));
|
||||||
$device_ids = array_filter($device_ids, 'is_numeric');
|
$device_ids = array_filter($device_ids, 'is_numeric');
|
||||||
$where = 'AND `device_id` in ' . dbGenPlaceholders(count($device_ids));
|
$where = 'AND `device_id` in ' . dbGenPlaceholders(count($device_ids));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Exceptions\InvalidModuleException;
|
use LibreNMS\Exceptions\InvalidModuleException;
|
||||||
use LibreNMS\Util\ModuleTestHelper;
|
use LibreNMS\Util\ModuleTestHelper;
|
||||||
use LibreNMS\Util\Snmpsim;
|
use LibreNMS\Util\Snmpsim;
|
||||||
@ -98,7 +99,7 @@ if (isset($options['v'])) {
|
|||||||
$variant = $options['variant'];
|
$variant = $options['variant'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($variant, '_')) {
|
if (Str::contains($variant, '_')) {
|
||||||
exit("Variant name cannot contain an underscore (_).\n");
|
exit("Variant name cannot contain an underscore (_).\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
$filename = basename(__FILE__);
|
$filename = basename(__FILE__);
|
||||||
$install_dir = realpath(__DIR__ . '/..');
|
$install_dir = realpath(__DIR__ . '/..');
|
||||||
chdir($install_dir);
|
chdir($install_dir);
|
||||||
@ -25,13 +27,13 @@ $map = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($changed_files as $file) {
|
foreach ($changed_files as $file) {
|
||||||
if (starts_with($file, 'doc/')) {
|
if (Str::startsWith($file, 'doc/')) {
|
||||||
$map['docs']++;
|
$map['docs']++;
|
||||||
}
|
}
|
||||||
if (ends_with($file, '.py')) {
|
if (Str::endsWith($file, '.py')) {
|
||||||
$map['python']++;
|
$map['python']++;
|
||||||
}
|
}
|
||||||
if (ends_with($file, '.sh')) {
|
if (Str::endsWith($file, '.sh')) {
|
||||||
$map['bash']++;
|
$map['bash']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +45,10 @@ foreach ($changed_files as $file) {
|
|||||||
// check if os owned file or generic php file
|
// check if os owned file or generic php file
|
||||||
if (!empty($os_name = os_from_file($file))) {
|
if (!empty($os_name = os_from_file($file))) {
|
||||||
$map['os'][] = $os_name;
|
$map['os'][] = $os_name;
|
||||||
if (ends_with($file, '.php')) {
|
if (Str::endsWith($file, '.php')) {
|
||||||
$map['os-php']++;
|
$map['os-php']++;
|
||||||
}
|
}
|
||||||
} elseif (ends_with($file, '.php')) {
|
} elseif (Str::endsWith($file, '.php')) {
|
||||||
$map['php']++;
|
$map['php']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,11 +180,11 @@ exit($return); //return the combined/single return value of tests
|
|||||||
|
|
||||||
function os_from_file($file)
|
function os_from_file($file)
|
||||||
{
|
{
|
||||||
if (starts_with($file, 'includes/definitions/')) {
|
if (Str::startsWith($file, 'includes/definitions/')) {
|
||||||
return basename($file, '.yaml');
|
return basename($file, '.yaml');
|
||||||
} elseif (starts_with($file, ['includes/polling', 'includes/discovery'])) {
|
} elseif (Str::startsWith($file, ['includes/polling', 'includes/discovery'])) {
|
||||||
return os_from_php($file);
|
return os_from_php($file);
|
||||||
} elseif (starts_with($file, 'LibreNMS/OS/')) {
|
} elseif (Str::startsWith($file, 'LibreNMS/OS/')) {
|
||||||
if (preg_match('#LibreNMS/OS/[^/]+.php#', $file)) {
|
if (preg_match('#LibreNMS/OS/[^/]+.php#', $file)) {
|
||||||
// convert class name to os name
|
// convert class name to os name
|
||||||
preg_match_all("/[A-Z][a-z]*/", basename($file, '.php'), $segments);
|
preg_match_all("/[A-Z][a-z]*/", basename($file, '.php'), $segments);
|
||||||
@ -193,7 +195,7 @@ function os_from_file($file)
|
|||||||
}
|
}
|
||||||
return os_from_php(str_replace('-', '_', $osname));
|
return os_from_php(str_replace('-', '_', $osname));
|
||||||
}
|
}
|
||||||
} elseif (starts_with($file, ['tests/snmpsim/', 'tests/data/'])) {
|
} elseif (Str::startsWith($file, ['tests/snmpsim/', 'tests/data/'])) {
|
||||||
list($os,) = explode('_', basename(basename($file, '.json'), '.snmprec'), 2);
|
list($os,) = explode('_', basename(basename($file, '.json'), '.snmprec'), 2);
|
||||||
return $os;
|
return $os;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Tests;
|
namespace LibreNMS\Tests;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
class CommonFunctionsTest extends TestCase
|
class CommonFunctionsTest extends TestCase
|
||||||
@ -33,14 +34,14 @@ class CommonFunctionsTest extends TestCase
|
|||||||
{
|
{
|
||||||
$data = 'This is a test. Just Testing.';
|
$data = 'This is a test. Just Testing.';
|
||||||
|
|
||||||
$this->assertTrue(str_contains($data, 'Just'));
|
$this->assertTrue(Str::contains($data, 'Just'));
|
||||||
$this->assertFalse(str_contains($data, 'just'));
|
$this->assertFalse(Str::contains($data, 'just'));
|
||||||
|
|
||||||
$this->assertTrue(str_i_contains($data, 'juSt'));
|
$this->assertTrue(str_i_contains($data, 'juSt'));
|
||||||
$this->assertFalse(str_i_contains($data, 'nope'));
|
$this->assertFalse(str_i_contains($data, 'nope'));
|
||||||
|
|
||||||
$this->assertTrue(str_contains($data, array('not', 'this', 'This')));
|
$this->assertTrue(Str::contains($data, array('not', 'this', 'This')));
|
||||||
$this->assertFalse(str_contains($data, array('not', 'this')));
|
$this->assertFalse(Str::contains($data, array('not', 'this')));
|
||||||
|
|
||||||
$this->assertTrue(str_i_contains($data, array('not', 'thIs')));
|
$this->assertTrue(str_i_contains($data, array('not', 'thIs')));
|
||||||
$this->assertFalse(str_i_contains($data, array('not', 'anything')));
|
$this->assertFalse(str_i_contains($data, array('not', 'anything')));
|
||||||
@ -50,22 +51,22 @@ class CommonFunctionsTest extends TestCase
|
|||||||
{
|
{
|
||||||
$data = 'This is a test. Just Testing that.';
|
$data = 'This is a test. Just Testing that.';
|
||||||
|
|
||||||
$this->assertTrue(starts_with($data, 'This'));
|
$this->assertTrue(Str::startsWith($data, 'This'));
|
||||||
$this->assertFalse(starts_with($data, 'this'));
|
$this->assertFalse(Str::startsWith($data, 'this'));
|
||||||
|
|
||||||
$this->assertTrue(starts_with($data, array('this', 'Test', 'This')));
|
$this->assertTrue(Str::startsWith($data, array('this', 'Test', 'This')));
|
||||||
$this->assertFalse(starts_with($data, array('this', 'Test')));
|
$this->assertFalse(Str::startsWith($data, array('this', 'Test')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEndsWith()
|
public function testEndsWith()
|
||||||
{
|
{
|
||||||
$data = 'This is a test. Just Testing';
|
$data = 'This is a test. Just Testing';
|
||||||
|
|
||||||
$this->assertTrue(ends_with($data, 'Testing'));
|
$this->assertTrue(Str::endsWith($data, 'Testing'));
|
||||||
$this->assertFalse(ends_with($data, 'testing'));
|
$this->assertFalse(Str::endsWith($data, 'testing'));
|
||||||
|
|
||||||
$this->assertTrue(ends_with($data, array('this', 'Testing', 'This')));
|
$this->assertTrue(Str::endsWith($data, array('this', 'Testing', 'This')));
|
||||||
$this->assertFalse(ends_with($data, array('this', 'Test')));
|
$this->assertFalse(Str::endsWith($data, array('this', 'Test')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRrdDescriptions()
|
public function testRrdDescriptions()
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Tests;
|
namespace LibreNMS\Tests;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use \PHPUnit\Framework\ExpectationFailedException as PHPUnitException;
|
use \PHPUnit\Framework\ExpectationFailedException as PHPUnitException;
|
||||||
|
|
||||||
class DBSetupTest extends DBTestCase
|
class DBSetupTest extends DBTestCase
|
||||||
@ -53,18 +54,18 @@ class DBSetupTest extends DBTestCase
|
|||||||
|
|
||||||
foreach (explode("\n", $content) as $line) {
|
foreach (explode("\n", $content) as $line) {
|
||||||
// skip comments and empty lines
|
// skip comments and empty lines
|
||||||
if (empty($line) || starts_with($line, array('#', '--'))) {
|
if (empty($line) || Str::startsWith($line, array('#', '--'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// each line must end with ;, prevents multiline and makes sql easy to run by hand
|
// each line must end with ;, prevents multiline and makes sql easy to run by hand
|
||||||
// Warning may include whitespace such as space and \r
|
// Warning may include whitespace such as space and \r
|
||||||
if (!ends_with($line, ';')) {
|
if (!Str::endsWith($line, ';')) {
|
||||||
throw new PHPUnitException("Each line must end with a semicolin (;)\n$file: $line");
|
throw new PHPUnitException("Each line must end with a semicolin (;)\n$file: $line");
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot assume user use the librenms database name
|
// cannot assume user use the librenms database name
|
||||||
if (str_contains($line, 'librenms.')) {
|
if (Str::contains($line, 'librenms.')) {
|
||||||
throw new PHPUnitException("Do not include the database name in schema files\n$file: $line");
|
throw new PHPUnitException("Do not include the database name in schema files\n$file: $line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace LibreNMS\Tests;
|
namespace LibreNMS\Tests;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
@ -183,12 +184,12 @@ class MibTest extends TestCase
|
|||||||
while (($line = fgets($handle)) !== false) {
|
while (($line = fgets($handle)) !== false) {
|
||||||
$trimmed = trim($line);
|
$trimmed = trim($line);
|
||||||
|
|
||||||
if (empty($trimmed) || starts_with($trimmed, '--')) {
|
if (empty($trimmed) || Str::startsWith($trimmed, '--')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$header .= " $trimmed";
|
$header .= " $trimmed";
|
||||||
if (str_contains($trimmed, 'DEFINITIONS')) {
|
if (Str::contains($trimmed, 'DEFINITIONS')) {
|
||||||
preg_match('/(\S+)\s+(?=DEFINITIONS)/', $header, $matches);
|
preg_match('/(\S+)\s+(?=DEFINITIONS)/', $header, $matches);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Tests;
|
namespace LibreNMS\Tests;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
class OSDiscoveryTest extends TestCase
|
class OSDiscoveryTest extends TestCase
|
||||||
@ -64,7 +65,7 @@ class OSDiscoveryTest extends TestCase
|
|||||||
return basename($file, '.snmprec');
|
return basename($file, '.snmprec');
|
||||||
}, glob($glob));
|
}, glob($glob));
|
||||||
$files = array_filter($files, function ($file) use ($os_name) {
|
$files = array_filter($files, function ($file) use ($os_name) {
|
||||||
return $file == $os_name || starts_with($file, $os_name . '_');
|
return $file == $os_name || Str::startsWith($file, $os_name . '_');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (empty($files)) {
|
if (empty($files)) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Tests;
|
namespace LibreNMS\Tests;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
use RecursiveRegexIterator;
|
use RecursiveRegexIterator;
|
||||||
@ -43,7 +44,7 @@ class SVGTest extends TestCase
|
|||||||
$svg = file_get_contents($file);
|
$svg = file_get_contents($file);
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
str_contains($svg, 'data:image/'),
|
Str::contains($svg, 'data:image/'),
|
||||||
"$file contains a bitmap image, please use a regular png or valid svg"
|
"$file contains a bitmap image, please use a regular png or valid svg"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ class SVGTest extends TestCase
|
|||||||
$svg = file_get_contents($file);
|
$svg = file_get_contents($file);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
str_contains($svg, 'viewBox'),
|
Str::contains($svg, 'viewBox'),
|
||||||
"$file: SVG files must have the viewBox attribute set"
|
"$file: SVG files must have the viewBox attribute set"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
* @author Tony Murray <murraytony@gmail.com>
|
* @author Tony Murray <murraytony@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
$snmpMockCache = array();
|
$snmpMockCache = array();
|
||||||
@ -167,34 +168,34 @@ function snmp_translate_type($oid, $mib = null, $mibdir = null)
|
|||||||
throw new Exception('Could not translate oid: ' . $oid . PHP_EOL . 'Tried: ' . $cmd);
|
throw new Exception('Could not translate oid: ' . $oid . PHP_EOL . 'Tried: ' . $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($result, 'OCTET STRING')) {
|
if (Str::contains($result, 'OCTET STRING')) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'Integer32')) {
|
if (Str::contains($result, 'Integer32')) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'NULL')) {
|
if (Str::contains($result, 'NULL')) {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'OBJECT IDENTIFIER')) {
|
if (Str::contains($result, 'OBJECT IDENTIFIER')) {
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'IpAddress')) {
|
if (Str::contains($result, 'IpAddress')) {
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'Counter32')) {
|
if (Str::contains($result, 'Counter32')) {
|
||||||
return 65;
|
return 65;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'Gauge32')) {
|
if (Str::contains($result, 'Gauge32')) {
|
||||||
return 66;
|
return 66;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'TimeTicks')) {
|
if (Str::contains($result, 'TimeTicks')) {
|
||||||
return 67;
|
return 67;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'Opaque')) {
|
if (Str::contains($result, 'Opaque')) {
|
||||||
return 68;
|
return 68;
|
||||||
}
|
}
|
||||||
if (str_contains($result, 'Counter64')) {
|
if (Str::contains($result, 'Counter64')) {
|
||||||
return 70;
|
return 70;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,11 +235,10 @@ function snmp_get_multi_oid($device, $oids, $options = '-OUQn', $mib = null, $mi
|
|||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($oids as $index => $oid) {
|
foreach ($oids as $index => $oid) {
|
||||||
if (str_contains($options, 'n')) {
|
if (Str::contains($options, 'n')) {
|
||||||
$oid_name = '.' . snmp_translate_number($oid, $mib, $mibdir);
|
$oid_name = '.' . snmp_translate_number($oid, $mib, $mibdir);
|
||||||
$val = snmp_get($device, $oid_name, $options, $mib, $mibdir);
|
$val = snmp_get($device, $oid_name, $options, $mib, $mibdir);
|
||||||
} elseif (str_contains($options, 's')
|
} elseif (Str::contains($options, 's') && Str::contains($oid, '::')) {
|
||||||
&& str_contains($oid, '::')) {
|
|
||||||
$tmp = explode('::', $oid);
|
$tmp = explode('::', $oid);
|
||||||
$oid_name = $tmp[1];
|
$oid_name = $tmp[1];
|
||||||
$val = snmp_get($device, $oid, $options, $mib, $mibdir);
|
$val = snmp_get($device, $oid, $options, $mib, $mibdir);
|
||||||
@ -263,7 +263,7 @@ function snmp_walk($device, $oid, $options = null, $mib = null, $mibdir = null)
|
|||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach ($dev as $key => $data) {
|
foreach ($dev as $key => $data) {
|
||||||
if (starts_with($key, $num_oid)) {
|
if (Str::startsWith($key, $num_oid)) {
|
||||||
if ($data[0] == 6) {
|
if ($data[0] == 6) {
|
||||||
$output .= '.' . $data[1] . PHP_EOL;
|
$output .= '.' . $data[1] . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\ValidationResult;
|
use LibreNMS\ValidationResult;
|
||||||
use LibreNMS\Validator;
|
use LibreNMS\Validator;
|
||||||
@ -81,18 +82,18 @@ if (!file_exists('config.php')) {
|
|||||||
|
|
||||||
$pre_checks_failed = false;
|
$pre_checks_failed = false;
|
||||||
$syntax_check = `php -ln config.php`;
|
$syntax_check = `php -ln config.php`;
|
||||||
if (!str_contains($syntax_check, 'No syntax errors detected')) {
|
if (!Str::contains($syntax_check, 'No syntax errors detected')) {
|
||||||
print_fail('Syntax error in config.php');
|
print_fail('Syntax error in config.php');
|
||||||
echo $syntax_check;
|
echo $syntax_check;
|
||||||
$pre_checks_failed = true;
|
$pre_checks_failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_line = rtrim(`head -n1 config.php`);
|
$first_line = rtrim(`head -n1 config.php`);
|
||||||
if (!starts_with($first_line, '<?php')) {
|
if (!Str::startsWith($first_line, '<?php')) {
|
||||||
print_fail("config.php doesn't start with a <?php - please fix this ($first_line)");
|
print_fail("config.php doesn't start with a <?php - please fix this ($first_line)");
|
||||||
$pre_checks_failed = true;
|
$pre_checks_failed = true;
|
||||||
}
|
}
|
||||||
if (str_contains(`tail config.php`, '?>')) {
|
if (Str::contains(`tail config.php`, '?>')) {
|
||||||
print_fail("Remove the ?> at the end of config.php");
|
print_fail("Remove the ?> at the end of config.php");
|
||||||
$pre_checks_failed = true;
|
$pre_checks_failed = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user