net-mgmt/zabbix-agent: incorporate changes & fixes (#97)

This commit is contained in:
Frank Wall 2017-03-27 14:26:39 +02:00
parent ee0bb8ea6d
commit 76233e1d0d
11 changed files with 35 additions and 39 deletions

View file

@ -1,7 +1,8 @@
PLUGIN_NAME= zabbix-agent
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent
PLUGIN_NAME= zabbix-agent
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent
PLUGIN_DEPENDS= zabbix32-agent
PLUGIN_MAINTAINER= opnsense@moov.de
PLUGIN_DEVEL= yes
PLUGIN_MAINTAINER= opnsense@moov.de
.include "../../Mk/plugins.mk"

View file

@ -0,0 +1 @@
Manage the Zabbix Agent to allow OPNsense to be monitored by a Zabbix Server.

View file

@ -76,14 +76,11 @@ function zabbixagent_services()
* @return array
*/
/**
XXX: needs investigation, hostname must be unique/replaced/excluded on secondary node(s)
function zabbixagent_xmlrpc_sync()
{
$result = array();
$result['id'] = 'zabbixagent';
$result['section'] = 'OPNsense.zabbixagent';
$result['section'] = 'OPNsense.zabbixagent.settings';
$result['description'] = gettext('Enterprise-class open source distributed monitoring agent');
return array($result);
}
*/

View file

@ -96,14 +96,14 @@ class ServiceController extends ApiControllerBase
$response = $backend->configdRun("zabbixagent status");
if (strpos($response, "not running") > 0) {
if ($mdlAgent->settings->main->enabled->__toString() == 1) {
if ($mdlAgent->settings->main->enabled->__toString() == "1") {
$status = "stopped";
} else {
$status = "disabled";
}
} elseif (strpos($response, "is running") > 0) {
$status = "running";
} elseif ($mdlAgent->settings->main->enabled->__toString() == 0) {
} elseif ($mdlAgent->settings->main->enabled->__toString() == "0") {
$status = "disabled";
} else {
$status = "unkown";
@ -129,7 +129,7 @@ class ServiceController extends ApiControllerBase
// stop zabbix agent when disabled
if ($runStatus['status'] == "running" &&
($mdlAgent->settings->main->enabled->__toString() == 0 || $force_restart)) {
($mdlAgent->settings->main->enabled->__toString() == "0" || $force_restart)) {
$this->stopAction();
}
@ -137,7 +137,7 @@ class ServiceController extends ApiControllerBase
$backend->configdRun('template reload OPNsense/ZabbixAgent');
// (res)start daemon
if ($mdlAgent->settings->main->enabled->__toString() == 1) {
if ($mdlAgent->settings->main->enabled->__toString() == "1") {
if ($runStatus['status'] == "running" && !$force_restart) {
$backend->configdRun("zabbixagent reconfigure");
} else {

View file

@ -42,7 +42,7 @@ class IndexController extends \OPNsense\Base\IndexController
public function indexAction()
{
// set page title
$this->view->title = "Zabbix Agent Settings";
$this->view->title = gettext('Zabbix Agent Settings');
// include form definitions
$this->view->settingsForm = $this->getForm("settings");
// pick the template to serve

View file

@ -7,7 +7,7 @@
<help><![CDATA[Enable Zabbix Agent service.]]></help>
</field>
<field>
<id>zabbixagent.settings.main.hostname</id>
<id>zabbixagent.local.hostname</id>
<label>Hostname</label>
<type>text</type>
<help><![CDATA[Usually the FQDN. Required for active checks and must match hostname as configured on the Zabbix server.]]></help>

View file

@ -5,21 +5,24 @@
Enterprise-class open source distributed monitoring agent
</description>
<items>
<!-- local settings that should NOT be synced to another node -->
<local>
<hostname type="TextField">
<Required>Y</Required>
<mask>/^.{1,255}$/u</mask>
<ValidationMessage>Should be a string between 1 and 255 characters.</ValidationMessage>
</hostname>
</local>
<settings>
<main>
<enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enabled>
<hostname type="TextField">
<Required>Y</Required>
<mask>/^.{1,255}$/u</mask>
<ValidationMessage>Should be a string between 1 and 255 characters.</ValidationMessage>
</hostname>
<serverList type="CSVListField">
<Required>Y</Required>
<multiple>Y</multiple>
<mask>/^([a-zA-Z0-9\.:\[\]\s\-]*?,)*([a-zA-Z0-9\.:\[\]\s\-]*)$/</mask>
<mask>/^([a-zA-Z0-9\.:\[\]\-]*?,)*([a-zA-Z0-9\.:\[\]\-]*)$/</mask>
<ChangeCase>lower</ChangeCase>
<ValidationMessage>Please provide valid Zabbix server addresses, i.e. 10.0.0.1 or zabbix.example.com.</ValidationMessage>
</serverList>
@ -50,12 +53,12 @@
<debugLevel type="OptionField">
<default>val_3</default>
<OptionValues>
<val_0>0 - basic information</val_0>
<val_1>1 - critical information</val_1>
<val_2>2 - error information</val_2>
<val_3>3 - warnings [default]</val_3>
<val_4>4 - debugging</val_4>
<val_5>5 - extended debugging</val_5>
<val_0>basic information (0)</val_0>
<val_1>critical information (1)</val_1>
<val_2>error information (2)</val_2>
<val_3>warnings (3, default)</val_3>
<val_4>debugging (4)</val_4>
<val_5>extended debugging (5)</val_5>
</OptionValues>
<Required>Y</Required>
</debugLevel>
@ -105,7 +108,7 @@
<activeCheckServers type="CSVListField">
<Required>N</Required>
<multiple>Y</multiple>
<mask>/^([a-zA-Z0-9\.:\[\]\s\-]*?,)*([a-zA-Z0-9\.:\[\]\s\-]*)$/</mask>
<mask>/^([a-zA-Z0-9\.:\[\]\-]*?,)*([a-zA-Z0-9\.:\[\]\-]*)$/</mask>
<ChangeCase>lower</ChangeCase>
<ValidationMessage>Please provide valid active check receivers, i.e. 10.0.0.1:10051, zabbix.example.com or [::1]:30051.</ValidationMessage>
</activeCheckServers>

View file

@ -1,6 +1,6 @@
#!/bin/sh
AGENT_DIRS="/var/run/zabbix /var/log/zabbix /usr/local/etc/zabbix_agentd.d"
AGENT_DIRS="/var/run/zabbix /var/log/zabbix /usr/local/etc/zabbix_agentd.conf.d"
for directory in ${AGENT_DIRS}; do
mkdir -p ${directory}

View file

@ -1,8 +1,3 @@
[setup]
command:/usr/local/opnsense/scripts/OPNsense/ZabbixAgent/setup.sh
parameters:
type:script_output
[start]
command:/usr/local/opnsense/scripts/OPNsense/ZabbixAgent/setup.sh; /usr/local/etc/rc.d/zabbix_agentd start
parameters:
@ -22,7 +17,7 @@ type:script
message:restarting zabbix_agentd
[status]
command:/usr/local/etc/rc.d/zabbix_agentd status || exit 0
command:/usr/local/etc/rc.d/zabbix_agentd status
parameters:
type:script_output
message:requesting zabbix_agentd status

View file

@ -1,5 +1,6 @@
{% if helpers.exists('OPNsense.ZabbixAgent.settings.main.enabled') and OPNsense.ZabbixAgent.settings.main.enabled|default("0") == "1" %}
zabbix_agentd_enable=YES
zabbix_agentd_opnsense_bootup_run="/usr/local/opnsense/scripts/OPNsense/ZabbixAgent/setup.sh"
{% else %}
zabbix_agentd_enable=NO
{% endif %}

View file

@ -102,8 +102,6 @@ StartAgents={{OPNsense.ZabbixAgent.settings.tuning.startAgents}}
#
{% if OPNsense.ZabbixAgent.settings.features.enableActiveChecks == '1' and OPNsense.ZabbixAgent.settings.features.activeCheckServers|default("") != "" %}
ServerActive={{OPNsense.ZabbixAgent.settings.features.activeCheckServers}}
{% else %}
# NOTE: Active checks are disabled
{% endif %}
### Option: Hostname
@ -111,8 +109,8 @@ ServerActive={{OPNsense.ZabbixAgent.settings.features.activeCheckServers}}
# Required for active checks and must match hostname as configured on the server.
# Value is acquired from HostnameItem if undefined.
#
{% if OPNsense.ZabbixAgent.settings.main.hostname|default("") != "" %}
Hostname={{OPNsense.ZabbixAgent.settings.main.hostname}}
{% if OPNsense.ZabbixAgent.local.hostname|default("") != "" %}
Hostname={{OPNsense.ZabbixAgent.local.hostname}}
{% endif %}
### Option: HostnameItem
@ -193,7 +191,7 @@ User=zabbix
# You may include individual files or all files in a directory in the configuration file.
# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
Include=/usr/local/etc/zabbix_agentd.d
Include=/usr/local/etc/zabbix_agentd.conf.d
####### USER-DEFINED MONITORED PARAMETERS #######