From 1100106677f2ce023fb8a8e34730726ea5eb3711 Mon Sep 17 00:00:00 2001 From: "Danilo G. Baio (dbaio)" Date: Tue, 3 Feb 2015 20:43:12 -0200 Subject: zabbix2 - update packages - second step --- config/zabbix2/zabbix2.inc | 54 ++++++++++++++++++++++++++++++++-------------- pkg_config.10.xml | 8 +++---- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/config/zabbix2/zabbix2.inc b/config/zabbix2/zabbix2.inc index 13713988..77f1d6e1 100644 --- a/config/zabbix2/zabbix2.inc +++ b/config/zabbix2/zabbix2.inc @@ -2,10 +2,10 @@ /* $Id$ */ /* ========================================================================== */ /* - zabbix2-proxy.inc + zabbix2.inc part of the Zabbix package for pfSense Copyright (C) 2013 Danilo G. Baio - Copyright (C) 2013 Marcello Coutinho + Copyright (C) 2013 Marcello Coutinho All rights reserved. */ @@ -46,16 +46,18 @@ function php_deinstall_zabbix2_agent(){ global $config, $g; conf_mount_rw(); - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + $pfs_version = php_zabbix2_pfs_version(); + $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version); + if ($pfs_version > 2.0){ - define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix22-agent-' . php_uname("m")); + define('ZABBIX_AGENT_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-agent-' . php_uname("m")); } else { define('ZABBIX_AGENT_BASE', '/usr/local'); } exec("/usr/bin/killall zabbix_agentd"); unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/rc.d/zabbix2_agentd.sh"); - unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/zabbix22/zabbix_agentd.conf"); + unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_agentd.conf"); unlink_if_exists("/var/log/zabbix2/zabbix2_agentd.log"); unlink_if_exists("/var/run/zabbix2/zabbix2_agentd.pid"); @@ -73,16 +75,18 @@ function php_deinstall_zabbix2_proxy(){ global $config, $g; conf_mount_rw(); - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + $pfs_version = php_zabbix2_pfs_version(); + $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version); + if ($pfs_version > 2.0){ - define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix22-proxy-' . php_uname("m")); + define('ZABBIX_PROXY_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-proxy-' . php_uname("m")); } else { define('ZABBIX_PROXY_BASE', '/usr/local'); } exec("/usr/bin/killall zabbix_proxy"); unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/rc.d/zabbix2_proxy.sh"); - unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/zabbix22/zabbix_proxy.conf"); + unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_proxy.conf"); unlink_if_exists("/var/log/zabbix2/zabbix_proxy.log"); unlink_if_exists("/var/run/zabbix2/zabbix2_proxy.pid"); @@ -177,11 +181,12 @@ function sync_package_zabbix2(){ global $config, $g; conf_mount_rw(); - #check pfsense version - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + $pfs_version = php_zabbix2_pfs_version(); + $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version); + if ($pfs_version > 2.0){ - define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix22-agent-' . php_uname("m")); - define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix22-proxy-' . php_uname("m")); + define('ZABBIX_AGENT_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-agent-' . php_uname("m")); + define('ZABBIX_PROXY_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-proxy-' . php_uname("m")); } else { define('ZABBIX_AGENT_BASE', '/usr/local'); @@ -210,7 +215,7 @@ ProxyMode={$Mode} {$AdvancedParams} EOF; - file_put_contents(ZABBIX_PROXY_BASE . "/etc/zabbix22/zabbix_proxy.conf", strtr($zbproxy_conf_file, array("\r" => ""))); + file_put_contents(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_proxy.conf", strtr($zbproxy_conf_file, array("\r" => ""))); } } /* check zabbix agent settings*/ @@ -244,7 +249,7 @@ StartAgents={$StartAgents} {$UserParams} EOF; - file_put_contents(ZABBIX_AGENT_BASE . "/etc/zabbix22/zabbix_agentd.conf", strtr($zbagent_conf_file, array("\r" => ""))); + file_put_contents(ZABBIX_AGENT_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_agentd.conf", strtr($zbagent_conf_file, array("\r" => ""))); } } $want_sysctls = array( @@ -293,8 +298,8 @@ EOF; /*check startup script files*/ /* create a few directories and ensure the sample files are in place */ - if (!is_dir(ZABBIX_PROXY_BASE . "/etc/zabbix22")) - exec("/bin/mkdir -p " . ZABBIX_PROXY_BASE . "/etc/zabbix22"); + if (!is_dir(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base)) + exec("/bin/mkdir -p " . ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base); $dir_checks = <<< EOF if [ ! -d /var/log/zabbix2 ] @@ -371,4 +376,21 @@ EOF; conf_mount_ro(); } + +function php_zabbix2_pfs_version(){ + $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + return $pfs_version; +} + +function php_zabbix2_pkg_base($pfs_version){ + if ($pfs_version >= 2.2){ + // pfSense 2.2 with zabbix 2.4 + $zabbix2_pkg_base = "zabbix24"; + }else{ + // pfSense 2.1 with zabbix 2.2 + $zabbix2_pkg_base = "zabbix22"; + } + return $zabbix2_pkg_base; +} + ?> diff --git a/pkg_config.10.xml b/pkg_config.10.xml index f9d22f75..277a71f9 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -1326,7 +1326,7 @@ Monitoring agent. Services https://packages.pfsense.org/packages/config/zabbix2/zabbix2-agent.xml - zabbix2-agent-2.2.7 pkg v0.8.3 + zabbix2-agent-2.4.3 pkg v0.8.3 BETA 2.2 zabbix2-agent.xml @@ -1335,14 +1335,14 @@ zabbix24-agent net-mgmt/zabbix24-agent - zabbix22-agent-2.2.7-##ARCH##.pbi + zabbix24-agent-2.4.3-##ARCH##.pbi Zabbix-2 Proxy Monitoring agent proxy. Services https://packages.pfsense.org/packages/config/zabbix2/zabbix2-proxy.xml - zabbix2-proxy-2.2.7 pkg v0.8.3 + zabbix2-proxy-2.4.3 pkg v0.8.3 BETA 2.2 zabbix2-proxy.xml @@ -1352,7 +1352,7 @@ net-mgmt/zabbix24-proxy OPTIONS_SET+= SQLITE IPV6;OPTIONS_UNSET+= MYSQL JABBER GSSAPI - zabbix22-proxy-2.2.7-##ARCH##.pbi + zabbix24-proxy-2.4.3-##ARCH##.pbi sudo -- cgit v1.2.3