Module status cleanups (#15461)

* Module status helper

* Correct reference

* Rename function to make it more explicit

* Same for exists checks, normalize argument names

* Use new functions
This commit is contained in:
Tony Murray
2023-10-16 05:03:32 -07:00
committed by GitHub
parent abf4fa0004
commit fb59cfec1c
16 changed files with 60 additions and 52 deletions

View File

@@ -25,6 +25,8 @@
namespace LibreNMS\Polling;
use App\Models\Device;
class ModuleStatus
{
public function __construct(
@@ -69,6 +71,15 @@ class ModuleStatus
return 'globally';
}
public function isEnabledAndDeviceUp(Device $device, bool $check_snmp = true): bool
{
if ($check_snmp && $device->snmp_disable) {
return false;
}
return $this->isEnabled() && $device->status;
}
public function __toString(): string
{
return sprintf('Module %s: Global %s | OS %s | Device %s | Manual %s',