. * * @package LibreNMS * @link http://librenms.org * @copyright 2018 Tony Murray * @author Tony Murray */ namespace App\Http\Controllers\Widgets; use App\Models\Device; use App\Models\Port; use App\Models\Service; use Illuminate\Http\Request; use LibreNMS\Config; use LibreNMS\Util\ObjectCache; abstract class DeviceSummaryController extends WidgetController { protected $title = 'Device Summary'; public function __construct() { // init defaults we need to check config, so do it in construct $this->defaults = [ 'show_services' => (int)Config::get('show_services', 1), 'summary_errors' => (int)Config::get('summary_errors', 0) ]; } public function getSettingsView(Request $request) { $settings = $this->getSettings(); return view('widgets.settings.device-summary', $settings); } protected function getData(Request $request) { $data = $this->getSettings(); $data['devices'] = ObjectCache::deviceCounts(['total', 'up', 'down', 'ignored', 'disabled']); $data['ports'] = $data['summary_errors'] ? ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown', 'errored']) : ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown']); if ($data['show_services']) { $data['services'] = ObjectCache::serviceCounts(['total', 'ok', 'critical', 'ignored', 'disabled']); } return $data; } }