diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile index 8c48430bf..78c165f62 100644 --- a/sysutils/nut/Makefile +++ b/sysutils/nut/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= nut -PLUGIN_VERSION= 1.1 +PLUGIN_VERSION= 1.2 PLUGIN_COMMENT= Network UPS Tools PLUGIN_DEPENDS= nut PLUGIN_MAINTAINER= m.muenz@gmail.com diff --git a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/DiagnosticsController.php b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/DiagnosticsController.php new file mode 100644 index 000000000..fe002451e --- /dev/null +++ b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/DiagnosticsController.php @@ -0,0 +1,53 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Nut\Api; + +use OPNsense\Base\ApiControllerBase; +use OPNsense\Core\Backend; +use OPNsense\Nut\Nut; + +class DiagnosticsController extends ApiControllerBase +{ + public function upsstatusAction() + { + $this->sessionClose(); + $mdl = new Nut(); + $host = '127.0.0.1'; + if (!empty((string)$mdl->netclient->address)) { + $host = (string)$mdl->netclient->address; + } + $upsname = 'UPSName'; + if (!empty((string)$mdl->general->name)) { + $upsname = (string)$mdl->general->name; + } + $backend = new Backend(); + $response = $backend->configdpRun('nut upsstatus', array("{$upsname}@{$host}")); + return array("response" => $response); + } +} diff --git a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/ServiceController.php b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/ServiceController.php index b3cd99fc4..6b939c5a6 100644 --- a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/ServiceController.php +++ b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/ServiceController.php @@ -29,7 +29,6 @@ namespace OPNsense\Nut\Api; use OPNsense\Base\ApiMutableServiceControllerBase; -use OPNsense\Core\Backend; use OPNsense\Nut\Nut; class ServiceController extends ApiMutableServiceControllerBase @@ -38,21 +37,4 @@ class ServiceController extends ApiMutableServiceControllerBase static protected $internalServiceTemplate = 'OPNsense/Nut'; static protected $internalServiceEnabled = 'general.enable'; static protected $internalServiceName = 'nut'; - - public function upsstatusAction() - { - $this->sessionClose(); - $mdl = new Nut(); - $host = '127.0.0.1'; - if (!empty((string)$mdl->netclient->address)) { - $host = (string)$mdl->netclient->address; - } - $upsname = 'UPSName'; - if (!empty((string)$mdl->general->name)) { - $upsname = (string)$mdl->general->name; - } - $backend = new Backend(); - $response = $backend->configdpRun('nut upsstatus', array("{$upsname}@{$host}")); - return array("response" => $response); - } } diff --git a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/DiagnosticsController.php b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/DiagnosticsController.php new file mode 100644 index 000000000..b153a8b53 --- /dev/null +++ b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/DiagnosticsController.php @@ -0,0 +1,44 @@ + + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +namespace OPNsense\Nut; + +use \OPNsense\Nut; + +/** +* Class DiagnosticsController +* @package OPNsense/Nut +*/ +class DiagnosticsController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->pick('OPNsense/Nut/diagnostics'); + } +} diff --git a/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Menu/Menu.xml b/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Menu/Menu.xml index 1011f45de..1e89fcc99 100644 --- a/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Menu/Menu.xml +++ b/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Menu/Menu.xml @@ -1,5 +1,8 @@ - + + + + diff --git a/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/diagnostics.volt b/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/diagnostics.volt new file mode 100644 index 000000000..4cfd8aadf --- /dev/null +++ b/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/diagnostics.volt @@ -0,0 +1,53 @@ +{# + # Copyright (C) 2018 Michael Muenz + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions and the following disclaimer in the + # documentation and/or other materials provided with the distribution. + # + # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + # POSSIBILITY OF SUCH DAMAGE. + #} + + + +
+
+

+    
+
+ + diff --git a/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/index.volt b/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/index.volt index 9910cb990..f91b000c6 100644 --- a/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/index.volt +++ b/sysutils/nut/src/opnsense/mvc/app/views/OPNsense/Nut/index.volt @@ -1,5 +1,5 @@ {# - # Copyright (C) 2017 Michael Muenz + # Copyright (C) 2017-2018 Michael Muenz # Copyright (C) 2014-2017 Deciso B.V. # All rights reserved. # @@ -27,13 +27,6 @@