diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/Api/KeyController.php b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/Api/KeyController.php new file mode 100644 index 000000000..a60c33101 --- /dev/null +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/Api/KeyController.php @@ -0,0 +1,64 @@ + + * + * 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\Telegraf\Api; + +use \OPNsense\Base\ApiMutableModelControllerBase; + +class KeyController extends ApiMutableModelControllerBase +{ + static protected $internalModelName = 'key'; + static protected $internalModelClass = '\OPNsense\Telegraf\Key'; + + public function searchKeyAction() + { + return $this->searchBase('keys.key', array("enabled", "name", "value")); + } + public function getKeyAction($uuid = null) + { + $this->sessionClose(); + return $this->getBase('key', 'keys.key', $uuid); + } + public function addKeyAction() + { + return $this->addBase('key', 'keys.key'); + } + public function delKeyAction($uuid) + { + return $this->delBase('keys.key', $uuid); + } + public function setKeyAction($uuid) + { + return $this->setBase('key', 'keys.key', $uuid); + } + public function toggleKeyAction($uuid) + { + return $this->toggleBase('keys.key', $uuid); + } +} diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/GeneralController.php b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/GeneralController.php index 8e4ae931d..b77ff77ce 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/GeneralController.php +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/GeneralController.php @@ -33,6 +33,7 @@ class GeneralController extends \OPNsense\Base\IndexController public function indexAction() { $this->view->generalForm = $this->getForm("general"); + $this->view->formDialogEditTelegrafKey = $this->getForm("dialogEditTelegrafKey"); $this->view->pick('OPNsense/Telegraf/general'); } } diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/dialogEditTelegrafKey.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/dialogEditTelegrafKey.xml new file mode 100644 index 000000000..ce7b19d0e --- /dev/null +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/dialogEditTelegrafKey.xml @@ -0,0 +1,20 @@ +
+ + key.enabled + + checkbox + This will enable or disable the key mapping. + + + key.name + + text + Set the name of this mapping. + + + key.value + + text + Set the value of the defined key. + +
diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.php b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.php new file mode 100644 index 000000000..9eee9e90d --- /dev/null +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.php @@ -0,0 +1,31 @@ + + 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\Telegraf; + +use OPNsense\Base\BaseModel; + +class Key extends BaseModel +{ +} diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.xml new file mode 100644 index 000000000..f1ed05a5d --- /dev/null +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Key.xml @@ -0,0 +1,25 @@ + + //OPNsense/telegraf/key + Telegraf key configuration + 1.0.0 + + + + + 1 + Y + + + + N + /^([0-9a-zA-Z._\-]){1,128}$/u + + + + N + /^([0-9a-zA-Z._\-]){1,128}$/u + + + + + diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/views/OPNsense/Telegraf/general.volt b/net-mgmt/telegraf/src/opnsense/mvc/app/views/OPNsense/Telegraf/general.volt index eb7b2c0fe..91a096f6b 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/views/OPNsense/Telegraf/general.volt +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/views/OPNsense/Telegraf/general.volt @@ -29,6 +29,7 @@ POSSIBILITY OF SUCH DAMAGE.
@@ -40,8 +41,38 @@ POSSIBILITY OF SUCH DAMAGE.
+
+ + + + + + + + + + + + + + + + + + +
{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Value') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ +
+
+
+ +

+
+
+{{ partial("layout_partials/base_dialog",['fields':formDialogEditTelegrafKey,'id':'dialogEditTelegrafKey','label':lang._('Edit Mapping')])}} + diff --git a/net-mgmt/telegraf/src/opnsense/service/templates/OPNsense/Telegraf/telegraf.conf b/net-mgmt/telegraf/src/opnsense/service/templates/OPNsense/Telegraf/telegraf.conf index 5c0224050..29748b9e3 100644 --- a/net-mgmt/telegraf/src/opnsense/service/templates/OPNsense/Telegraf/telegraf.conf +++ b/net-mgmt/telegraf/src/opnsense/service/templates/OPNsense/Telegraf/telegraf.conf @@ -2,6 +2,14 @@ [global_tags] +{% if helpers.exists('OPNsense.telegraf.key.keys.key') %} +{% for key_list in helpers.toList('OPNsense.telegraf.key.keys.key') %} +{% if key_list.enabled == '1' %} +{{ key_list.name }} = "{{ key_list.value }}" +{% endif %} +{% endfor %} +{% endif %} + [agent] {% if helpers.exists('OPNsense.telegraf.general.interval') and OPNsense.telegraf.general.interval != '' %} interval = "{{ OPNsense.telegraf.general.interval }}s"