diff --git a/net-mgmt/zabbix-agent/Makefile b/net-mgmt/zabbix-agent/Makefile index 14cb883d5..217e9c047 100644 --- a/net-mgmt/zabbix-agent/Makefile +++ b/net-mgmt/zabbix-agent/Makefile @@ -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 diff --git a/net-mgmt/zabbix-agent/src/opnsense/mvc/app/controllers/OPNsense/ZabbixAgent/Api/ServiceController.php b/net-mgmt/zabbix-agent/src/opnsense/mvc/app/controllers/OPNsense/ZabbixAgent/Api/ServiceController.php index 008956b17..70545400b 100644 --- a/net-mgmt/zabbix-agent/src/opnsense/mvc/app/controllers/OPNsense/ZabbixAgent/Api/ServiceController.php +++ b/net-mgmt/zabbix-agent/src/opnsense/mvc/app/controllers/OPNsense/ZabbixAgent/Api/ServiceController.php @@ -1,6 +1,6 @@ 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'; } diff --git a/net-mgmt/zabbix-agent/src/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml b/net-mgmt/zabbix-agent/src/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml index 510dd8527..c903e10cc 100644 --- a/net-mgmt/zabbix-agent/src/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml +++ b/net-mgmt/zabbix-agent/src/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml @@ -1,6 +1,6 @@ //OPNsense/ZabbixAgent - 1.2.0 + 1.2.1 Enterprise-class open source distributed monitoring agent @@ -140,12 +140,12 @@ Y - /^[^\t^,^;^\.^\[^\]^\{^\}]{1,255}$/u + /^[^\t^,^;^\[^\]^\{^\}]{1,255}$/u Should be a string between 1 and 255 characters. Y - /^[^\t^,^;^\.^\[^\]^\{^\}]{1,4096}$/u + /^[^\t]{1,4096}$/u Should be a string between 1 and 4096 characters. Y