Merge pull request #1262 from fraenki/zabbixagent_15

net-mgmt/zabbix-agent: release 1.5
This commit is contained in:
Frank Wall
2019-03-18 16:39:57 +01:00
committed by GitHub
3 changed files with 11 additions and 124 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
PLUGIN_NAME= zabbix-agent
PLUGIN_VERSION= 1.4
PLUGIN_VERSION= 1.5
PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent
PLUGIN_DEPENDS= zabbix4-agent
PLUGIN_MAINTAINER= opnsense@moov.de
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (C) 2017 Frank Wall
* Copyright (C) 2017-2019 Frank Wall
* Copyright (C) 2015 Deciso B.V.
*
* All rights reserved.
@@ -29,7 +29,7 @@
*/
namespace OPNsense\ZabbixAgent\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Base\ApiMutableServiceControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\ZabbixAgent\ZabbixAgent;
@@ -37,123 +37,10 @@ use \OPNsense\ZabbixAgent\ZabbixAgent;
* Class ServiceController
* @package OPNsense\ZabbixAgent
*/
class ServiceController extends ApiControllerBase
class ServiceController extends ApiMutableServiceControllerBase
{
/**
* start zabbix agent service (in background)
* @return array
*/
public function startAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("zabbixagent start");
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* stop zabbix agent service
* @return array
*/
public function stopAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("zabbixagent stop");
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* restart zabbix agent service
* @return array
*/
public function restartAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("zabbixagent restart");
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* retrieve status of zabbix agent service
* @return array
* @throws \Exception
*/
public function statusAction()
{
$backend = new Backend();
$mdlAgent = new ZabbixAgent();
$response = $backend->configdRun("zabbixagent status");
if (strpos($response, "not running") > 0) {
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") {
$status = "disabled";
} else {
$status = "unkown";
}
return array("status" => $status);
}
/**
* reconfigure zabbix agent, generate config and reload
*/
public function reconfigureAction()
{
if ($this->request->isPost()) {
$force_restart = false;
// close session for long running action
$this->sessionClose();
$mdlAgent = new ZabbixAgent();
$backend = new Backend();
$runStatus = $this->statusAction();
// stop zabbix agent when disabled
if ($runStatus['status'] == "running" &&
($mdlAgent->settings->main->enabled->__toString() == "0" || $force_restart)) {
$this->stopAction();
}
// generate template
$backend->configdRun('template reload OPNsense/ZabbixAgent');
// (res)start daemon
if ($mdlAgent->settings->main->enabled->__toString() == "1") {
if ($runStatus['status'] == "running" && !$force_restart) {
$backend->configdRun("zabbixagent reconfigure");
} else {
$this->startAction();
}
}
return array("status" => "ok");
} else {
return array("status" => "failed");
}
}
protected static $internalServiceClass = '\OPNsense\ZabbixAgent\ZabbixAgent';
protected static $internalServiceTemplate = 'OPNsense/ZabbixAgent';
protected static $internalServiceEnabled = 'settings.main.enabled';
protected static $internalServiceName = 'zabbixagent';
}
@@ -1,6 +1,6 @@
<model>
<mount>//OPNsense/ZabbixAgent</mount>
<version>1.2.0</version>
<version>1.2.1</version>
<description>Enterprise-class open source distributed monitoring agent</description>
<items>
<!-- local settings that should NOT be synced to another node -->
@@ -140,12 +140,12 @@
<Required>Y</Required>
</enabled>
<key type="TextField">
<mask>/^[^\t^,^;^\.^\[^\]^\{^\}]{1,255}$/u</mask>
<mask>/^[^\t^,^;^\[^\]^\{^\}]{1,255}$/u</mask>
<ValidationMessage>Should be a string between 1 and 255 characters.</ValidationMessage>
<Required>Y</Required>
</key>
<command type="TextField">
<mask>/^[^\t^,^;^\.^\[^\]^\{^\}]{1,4096}$/u</mask>
<mask>/^[^\t]{1,4096}$/u</mask>
<ValidationMessage>Should be a string between 1 and 4096 characters.</ValidationMessage>
<Required>Y</Required>
</command>