diff --git a/net-mgmt/telegraf/Makefile b/net-mgmt/telegraf/Makefile index 06a8f497b..dda18ec0e 100644 --- a/net-mgmt/telegraf/Makefile +++ b/net-mgmt/telegraf/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= telegraf -PLUGIN_VERSION= 1.5.1 +PLUGIN_VERSION= 1.7.0 PLUGIN_COMMENT= Agent for collecting metrics and data PLUGIN_DEPENDS= telegraf PLUGIN_MAINTAINER= m.muenz@gmail.com 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/controllers/OPNsense/Telegraf/forms/input.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/input.xml index a9d55c3fc..5c80739a0 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/input.xml +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/input.xml @@ -79,6 +79,12 @@ checkbox Read network interface metrics. + + input.pf + + checkbox + Read PF values via pfctl. + input.ping @@ -93,4 +99,10 @@ true Set the Hosts to ping in a CSV list. + + input.haproxy + + checkbox + Enable the collection of HAProxy statistics. + diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/output.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/output.xml index 120056dfb..6da1ce813 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/output.xml +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/controllers/OPNsense/Telegraf/forms/output.xml @@ -101,4 +101,28 @@ text Set the index name. + + output.prometheus_enable + + checkbox + This will enable Prometheus as output. + + + output.prometheus_listen + + text + Port to listen on. + + + output.prometheus_exclude + + text + Collectors to enable, valid entries are "gocollector" and "process". If unset, both are enabled. + + + output.prometheus_stringaslabel + + checkbox + Send string metrics as Prometheus labels. + diff --git a/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Input.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Input.xml index dfb2e2465..04956316d 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Input.xml +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Input.xml @@ -1,7 +1,7 @@ //OPNsense/telegraf/input Telegraf inputs configuration - 1.0.0 + 1.0.1 1 @@ -55,6 +55,10 @@ 0 N + + 0 + N + 0 N @@ -62,5 +66,9 @@ N + + 0 + N + 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/models/OPNsense/Telegraf/Output.xml b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Output.xml index 53f0a26fd..a188c8d32 100644 --- a/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Output.xml +++ b/net-mgmt/telegraf/src/opnsense/mvc/app/models/OPNsense/Telegraf/Output.xml @@ -66,5 +66,20 @@ telegraf-%Y.%m.%d N + + 0 + N + + + 9273 + N + + + N + + + 1 + N + 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/scripts/OPNsense/Telegraf/setup.sh b/net-mgmt/telegraf/src/opnsense/scripts/OPNsense/Telegraf/setup.sh new file mode 100755 index 000000000..ecd3ab44f --- /dev/null +++ b/net-mgmt/telegraf/src/opnsense/scripts/OPNsense/Telegraf/setup.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +mkdir -p /var/log/telegraf +chown -R telegraf:telegraf /var/log/telegraf +chmod 750 /var/log/telegraf 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 8a7e66360..3d4575e7a 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" @@ -26,7 +34,6 @@ precision = "" debug = false quiet = true - logfile = "/var/log/telegraf.log" {% if helpers.exists('OPNsense.telegraf.general.hostname') and OPNsense.telegraf.general.hostname != '' %} hostname = "{{ OPNsense.telegraf.general.hostname }}" {% endif %} @@ -96,6 +103,21 @@ {% endif %} {% endif %} +{% if helpers.exists('OPNsense.telegraf.output.prometheus_enable') and OPNsense.telegraf.output.prometheus_enable == '1' %} +[[outputs.prometheus_client]] +{% if helpers.exists('OPNsense.telegraf.output.prometheus_listen') and OPNsense.telegraf.output.prometheus_listen != '' %} + listen = ":{{ OPNsense.telegraf.output.prometheus_listen }}" +{% endif %} +{% if helpers.exists('OPNsense.telegraf.output.prometheus_exclude') and OPNsense.telegraf.output.prometheus_exclude != '' %} + collectors_exclude = [{{ "'" + ("','".join(OPNsense.telegraf.output.prometheus_exclude.split(','))) + "'" }}] +{% endif %} +{% if helpers.exists('OPNsense.telegraf.output.prometheus_stringaslabel') and OPNsense.telegraf.output.prometheus_stringaslabel == '1' %} + string_as_label = true +{% else %} + string_as_label = false +{% endif %} +{% endif %} + {% if helpers.exists('OPNsense.telegraf.input.cpu') and OPNsense.telegraf.input.cpu == '1' %} [[inputs.cpu]] {% if helpers.exists('OPNsense.telegraf.input.cpu_percpu') and OPNsense.telegraf.input.cpu_percpu == '1' %} @@ -149,6 +171,10 @@ [[inputs.net]] {% endif %} +{% if helpers.exists('OPNsense.telegraf.input.pf') and OPNsense.telegraf.input.pf == '1' %} +[[inputs.pf]] +{% endif %} + {% if helpers.exists('OPNsense.telegraf.input.ping') and OPNsense.telegraf.input.ping == '1' %} [[inputs.ping]] {% if helpers.exists('OPNsense.telegraf.input.ping_hosts') and OPNsense.telegraf.input.ping_hosts != '' %} @@ -156,4 +182,9 @@ {% endif %} {% endif %} +{% if helpers.exists('OPNsense.telegraf.input.haproxy') and OPNsense.telegraf.input.haproxy == '1' %} +[[inputs.haproxy]] + servers = ["socket:/var/run/haproxy.socket"] +{% endif %} + {% endif %}