mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net-mgmt/zabbix-agent: add support for Item Key Aliases
This commit is contained in:
+31
@@ -73,4 +73,35 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
return $this->toggleBase('userparameters.userparameter', $uuid);
|
||||
}
|
||||
|
||||
public function searchAliasesAction()
|
||||
{
|
||||
return $this->searchBase('aliases.alias', array("enabled", "key", "sourceKey"));
|
||||
}
|
||||
|
||||
public function getAliasAction($uuid = null)
|
||||
{
|
||||
$this->sessionClose();
|
||||
return $this->getBase('alias', 'aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
public function addAliasAction()
|
||||
{
|
||||
return $this->addBase('alias', 'aliases.alias');
|
||||
}
|
||||
|
||||
public function delAliasAction($uuid)
|
||||
{
|
||||
return $this->delBase('aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
public function setAliasAction($uuid)
|
||||
{
|
||||
return $this->setBase('alias', 'aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
public function toggleAliasAction($uuid)
|
||||
{
|
||||
return $this->toggleBase('aliases.alias', $uuid);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -45,6 +45,8 @@ class IndexController extends \OPNsense\Base\IndexController
|
||||
$this->view->settingsForm = $this->getForm("settings");
|
||||
// link userparameter dialog
|
||||
$this->view->formDialogUserparameter = $this->getForm("dialogUserparameter");
|
||||
// link alias dialog
|
||||
$this->view->formDialogAlias = $this->getForm("dialogAlias");
|
||||
// pick the template to serve
|
||||
$this->view->pick('OPNsense/ZabbixAgent/index');
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>alias.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable this alias.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.key</id>
|
||||
<label>Alias Item Key</label>
|
||||
<type>text</type>
|
||||
<help>Enter a unique item key of your choice.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.sourceKey</id>
|
||||
<label>Source Item Key</label>
|
||||
<type>text</type>
|
||||
<help>Enter the name of an existing item key.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.acceptParams</id>
|
||||
<label>Accept Parameters</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable to accept parameters for this alias.</help>
|
||||
</field>
|
||||
</form>
|
||||
+25
@@ -155,5 +155,30 @@
|
||||
</acceptParams>
|
||||
</userparameter>
|
||||
</userparameters>
|
||||
<aliases>
|
||||
<alias type="ArrayField">
|
||||
<id type="UniqueIdField">
|
||||
<Required>Y</Required>
|
||||
</id>
|
||||
<enabled type="BooleanField">
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<key type="TextField">
|
||||
<mask>/^[^\t^,^;^\.^\[^\]^\{^\}]{1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters.</ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
</key>
|
||||
<sourceKey type="TextField">
|
||||
<mask>/^[^\t]{1,4096}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 4096 characters.</ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
</sourceKey>
|
||||
<acceptParams type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</acceptParams>
|
||||
</alias>
|
||||
</aliases>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@@ -53,6 +53,19 @@ $( document ).ready(function() {
|
||||
}
|
||||
);
|
||||
|
||||
$("#grid-aliases").UIBootgrid(
|
||||
{ search:'/api/zabbixagent/settings/searchAliases',
|
||||
get:'/api/zabbixagent/settings/getAlias/',
|
||||
set:'/api/zabbixagent/settings/setAlias/',
|
||||
add:'/api/zabbixagent/settings/addAlias/',
|
||||
del:'/api/zabbixagent/settings/delAlias/',
|
||||
toggle:'/api/zabbixagent/settings/toggleAlias/',
|
||||
options: {
|
||||
rowCount:[10,25,50,100,500,1000]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/***********************************************************************
|
||||
* Commands
|
||||
**********************************************************************/
|
||||
@@ -137,6 +150,7 @@ $( document ).ready(function() {
|
||||
<a data-toggle="tab" onclick="$('#userparameters-tab').click();" class="visible-lg-inline-block visible-md-inline-block visible-xs-inline-block visible-sm-inline-block" style="border-right:0px;"><b>{{ lang._('Advanced') }}</b></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a data-toggle="tab" id="userparameters-tab" href="#userparameters">{{ lang._('User Parameters') }}</a></li>
|
||||
<li><a data-toggle="tab" id="aliases-tab" href="#aliases">{{ lang._('Item Key Aliases') }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -178,7 +192,40 @@ $( document ).ready(function() {
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="aliases" class="tab-pane fade">
|
||||
<!-- tab page "aliases" -->
|
||||
<table id="grid-aliases" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAlias">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="key" data-type="string">{{ lang._('Alias Key') }}</th>
|
||||
<th data-column-id="sourceKey" data-type="string">{{ lang._('Alias Source Key') }}</th>
|
||||
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
|
||||
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
|
||||
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<!-- apply button -->
|
||||
<div class="col-md-12">
|
||||
<hr/>
|
||||
<button class="btn btn-primary" id="reconfigureAct-aliases" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# include dialogs #}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogUserparameter,'id':'DialogUserparameter','label':lang._('Edit User Parameter')]) }}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogAlias,'id':'DialogAlias','label':lang._('Edit Alias')]) }}
|
||||
|
||||
+10
-1
@@ -165,7 +165,16 @@ MaxLinesPerSecond={{OPNsense.ZabbixAgent.settings.tuning.maxLinesPerSecond}}
|
||||
# Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1]
|
||||
# Now shorthand key zabbix.userid may be used to retrieve data.
|
||||
# Aliases can be used in HostMetadataItem but not in HostnameItem parameters.
|
||||
#
|
||||
{% if helpers.exists('OPNsense.ZabbixAgent.aliases') %}
|
||||
{% for alias in helpers.toList('OPNsense.ZabbixAgent.aliases.alias') %}
|
||||
{% if alias.enabled == '1' %}
|
||||
{% if alias.acceptParams == '1' %}
|
||||
{% set alias_opts = '[*]' %}
|
||||
{% endif %}
|
||||
Alias={{alias.key}}{{alias_opts}}:{{alias.sourceKey}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
### Option: Timeout
|
||||
# Spend no more than Timeout seconds on processing
|
||||
|
||||
Reference in New Issue
Block a user