Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sysutils/nut/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PLUGIN_NAME= nut
PLUGIN_VERSION= 1.9
PLUGIN_REVISION= 1
PLUGIN_VERSION= 1.10
PLUGIN_COMMENT= Network UPS Tools
PLUGIN_DEPENDS= nut
PLUGIN_MAINTAINER= m.muenz@gmail.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,30 @@ class DiagnosticsController extends ApiControllerBase
public function upsstatusAction()
{
$mdl = new Nut();
$host = '127.0.0.1';
if (!empty((string)$mdl->netclient->address)) {
$targets = array();
foreach ($mdl->upses->ups->iterateItems() as $ups) {
if ((string)$ups->enabled == '1') {
$targets[] = (string)$ups->name;
}
}
if ((string)$mdl->netclient->enable == '1' && !empty((string)$mdl->netclient->address)) {
$host = (string)$mdl->netclient->address;
if (strpos($host, ':') !== false) {
$host = '[' . $host . ']';
}
if (!empty((string)$mdl->netclient->port)) {
$host .= ':' . (string)$mdl->netclient->port;
}
$targets[] = (string)$mdl->netclient->name . '@' . $host;
}
$upsname = 'UPSName';
if (!empty((string)$mdl->general->name)) {
$upsname = (string)$mdl->general->name;
$items = array();
if (!empty($targets)) {
$backend = new Backend();
$items = json_decode((string)$backend->configdpRun('nut upsstatus', array(implode(',', $targets))), true);
if (!is_array($items)) {
$items = array();
}
}
$backend = new Backend();
$response = $backend->configdpRun('nut upsstatus', array("{$upsname}@{$host}"));
return array("response" => $response);
return array("items" => $items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,34 @@ class SettingsController extends ApiMutableModelControllerBase
{
protected static $internalModelClass = '\OPNsense\Nut\Nut';
protected static $internalModelName = 'nut';

public function searchUpsAction()
{
return $this->searchBase('upses.ups', ['enabled', 'name', 'driver', 'args']);
}

public function getUpsAction($uuid = null)
{
return $this->getBase('ups', 'upses.ups', $uuid);
}

public function addUpsAction()
{
return $this->addBase('ups', 'upses.ups');
}

public function setUpsAction($uuid)
{
return $this->setBase('ups', 'upses.ups', $uuid);
}

public function delUpsAction($uuid)
{
return $this->delBase('upses.ups', $uuid);
}

public function toggleUpsAction($uuid)
{
return $this->toggleBase('upses.ups', $uuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function indexAction()
{
$backend = new Backend();
$this->view->settings = $this->getForm("settings");
$this->view->formDialogUps = $this->getForm("dialogUps");
$this->view->formGridUps = $this->getFormGrid("dialogUps");
$this->view->pick('OPNsense/Nut/index');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<form>
<field>
<id>ups.enabled</id>
<label>Enabled</label>
<type>checkbox</type>
<help>Enable or disable this UPS.</help>
<grid_view>
<width>6em</width>
<type>boolean</type>
<formatter>rowtoggle</formatter>
</grid_view>
</field>
<field>
<id>ups.name</id>
<label>Name</label>
<type>text</type>
<help>Set a name for your UPS.</help>
</field>
<field>
<id>ups.driver</id>
<label>Driver</label>
<type>dropdown</type>
<help>Set the NUT driver used for this UPS. See the NUT hardware compatibility list for the driver matching your device.</help>
</field>
<field>
<id>ups.powervalue</id>
<label>Power Value</label>
<type>text</type>
<help>Set the number of power supplies this UPS feeds on this system. Use 0 to monitor the UPS without shutting down this system.</help>
<grid_view>
<visible>false</visible>
</grid_view>
</field>
<field>
<id>ups.args</id>
<label>Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set arguments for this UPS, e.g. "port=auto". With multiple USB devices of the same driver, pin each UPS with "serial=...", or "vendorid=..." and "productid=...".</help>
</field>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
<type>dropdown</type>
<help>Set the service mode. Currently only standalone and netclient are available.</help>
</field>
<field>
<id>nut.general.name</id>
<label>Name</label>
<type>text</type>
<help>Set a name for your UPS.</help>
</field>
<field>
<id>nut.general.listen</id>
<label>Listen Address</label>
Expand All @@ -43,187 +37,43 @@
</field>
</subtab>
</tab>
<tab id="nut-ups-type" description="UPS Type">
<subtab id="nut-ups-usbhid" description="USBHID-Driver">
<field>
<id>nut.usbhid.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the USBHID driver.</help>
</field>
<field>
<id>nut.usbhid.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-apcsmart" description="APCSMART-Driver">
<field>
<id>nut.apcsmart.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the APCSMART driver.</help>
</field>
<field>
<id>nut.apcsmart.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-apcupsd" description="APCUPSD-Driver">
<field>
<id>nut.apcupsd.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the APCUPSD controlled devices driver.</help>
</field>
<field>
<id>nut.apcupsd.hostname</id>
<label>Hostname</label>
<type>text</type>
<help>Set the hostname or ip of the remote apcupsd server.</help>
</field>
<field>
<id>nut.apcupsd.port</id>
<label>Port</label>
<type>text</type>
<help>Set the port of the remote apcupsd server (optional).</help>
</field>
</subtab>
<subtab id="nut-ups-bcmxcpusb" description="BCMXCPUSB-Driver">
<field>
<id>nut.bcmxcpusb.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the PowerWare BCMXCPUSB driver.</help>
</field>
<field>
<id>nut.bcmxcpusb.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-blazerusb" description="BlazerUSB-Driver">
<field>
<id>nut.blazerusb.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the BlazerUSB driver.</help>
</field>
<field>
<id>nut.blazerusb.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-blazerser" description="BlazerSerial-Driver">
<field>
<id>nut.blazerser.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the BlazerSerial driver. Please be aware that this driver needs to run nut-tools as root.</help>
</field>
<field>
<id>nut.blazerser.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-netclient" description="Netclient">
<field>
<id>nut.netclient.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the Netclient driver.</help>
</field>
<field>
<id>nut.netclient.address</id>
<label>IP Address</label>
<type>text</type>
<help>Set the IP address of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.port</id>
<label>Port</label>
<type>text</type>
<help>Set the TCP port of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.user</id>
<label>Username</label>
<type>text</type>
<help>Set the username of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.password</id>
<label>Password</label>
<type>password</type>
<help>Set the password of the remote NUT server.</help>
</field>
</subtab>
<subtab id="nut-ups-qx" description="QX-Driver">
<field>
<id>nut.qx.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the QX driver.</help>
</field>
<field>
<id>nut.qx.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-riello" description="Riello-Driver">
<field>
<id>nut.riello.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the Riello driver.</help>
</field>
<field>
<id>nut.riello.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
<subtab id="nut-ups-snmp" description="SNMP-Driver">
<field>
<id>nut.snmp.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the SNMP driver.</help>
</field>
<field>
<id>nut.snmp.args</id>
<label>Extra Arguments</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "community=public".</help>
</field>
</subtab>
<tab id="nut-netclient" description="Netclient">
<field>
<id>nut.netclient.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the Netclient driver.</help>
</field>
<field>
<id>nut.netclient.name</id>
<label>Name</label>
<type>text</type>
<help>Set the name of the UPS on the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.address</id>
<label>IP Address</label>
<type>text</type>
<help>Set the IP address of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.port</id>
<label>Port</label>
<type>text</type>
<help>Set the TCP port of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.user</id>
<label>Username</label>
<type>text</type>
<help>Set the username of the remote NUT server.</help>
</field>
<field>
<id>nut.netclient.password</id>
<label>Password</label>
<type>password</type>
<help>Set the password of the remote NUT server.</help>
</field>
</tab>

<activetab>nut-general-settings</activetab>
Expand Down
Loading