Commit ceab6c42 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Added build target for zabbix proxy

parent 73996b30
......@@ -138,3 +138,55 @@ define HTTPD_CONF
#
endef
export HTTPD_CONF
proxy: zabbix-proxy-service zabbix-proxy-config
tar xf zabbix-3.4.14.tar.gz
cd zabbix-3.4.14 && ./configure --prefix=/usr --sysconfdir=/etc --enable-proxy --with-openssl --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
$(MAKE) -C zabbix-3.4.14
$(MAKE) -C zabbix-3.4.14 install
install -v -Dm755 zabbix_proxy-configure /usr/sbin/zabbix_proxy-configure
sed -e 's|.*LogType=.*|LogType=system|' -i /etc/zabbix_proxy.conf
sed -e 's|^LogFile=.*|# LogFile=|' -i /etc/zabbix_proxy.conf
sed -e 's|.*PidFile=.*|PidFile=/run/zabbix/zabbix_proxy.pid|' -i /etc/zabbix_proxy.conf
sed -e 's|^DBName=.*|# DBName=|' -i /etc/zabbix_proxy.conf
sed -e 's|^DBUser=.*|# DBUser=|' -i /etc/zabbix_proxy.conf
sed -e 's|^# Include=/usr/local/etc/zabbix_proxy\.conf\.d/\*\.conf|Include=/etc/zabbix_proxy.conf.d/*.conf|' -i /etc/zabbix_proxy.conf
@echo "d /run/zabbix 755 zabbix zabbix -" > /usr/lib/tmpfiles.d/zabbix.conf
chmod u+s /bin/ping
@echo "$$ZABBIX_PROXY_SERVICE" > /lib/systemd/system/zabbix-proxy.service
systemctl enable zabbix-proxy.service
@echo "$$ZABBIX_PROXY_CONFIG" >> /etc/config/zabbix
install -v -Dm755 zabbix_proxy /usr/share/easycwmp/functions/zabbix
rm -rf zabbix-3.4.14
zabbix-proxy-service:
define ZABBIX_PROXY_SERVICE
[Unit]
Description=Zabbix Proxy
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/usr/sbin/zabbix_proxy-configure
ExecStart=/usr/sbin/zabbix_proxy
ExecReload=/usr/sbin/zabbix_proxy -R config_cache_reload
ExecStartPost=sleep 3
PIDFile=/run/zabbix/zabbix_proxy.pid
Restart=always
RestartSec=100
[Install]
WantedBy=multi-user.target
endef
export ZABBIX_PROXY_SERVICE
zabbix-proxy-config:
define ZABBIX_PROXY_CONFIG
config zabbix 'proxy'
option hostname ''
option name ''
option startpollers '5'
option cachesize '32M'
endef
export ZABBIX_PROXY_CONFIG
#!/bin/sh
#common_execute_method_param "$parameter" "$permission" "$get_cmd" "$set_cmd" "xsd:$type" "$forcedinform"
# $forcedinform should be set to 1 if the parameter is included in the inform message otherwise empty
# Default of $type = string
#############################
# Entry point functuons #
#############################
prefix_list="$prefix_list $DMROOT.Zabbix."
entry_execute_method_list="$entry_execute_method_list entry_execute_method_root_Zabbix"
entry_execute_method_list_forcedinform="$entry_execute_method_list_forcedinform entry_execute_method_root_Zabbix"
entry_execute_method_root_Zabbix() {
case "$1" in ""|"$DMROOT."|"$DMROOT.Zabbix."*)
common_execute_method_obj "$DMROOT.Zabbix." "0"
common_execute_method_obj "$DMROOT.Zabbix.Agent." "0"
common_execute_method_param "$DMROOT.Zabbix.Agent.Server" "1" "zabbix_get_agent_server" "zabbix_set_agent_server"
common_execute_method_obj "$DMROOT.Zabbix.Proxy." "0"
common_execute_method_param "$DMROOT.Zabbix.Proxy.Server" "1" "zabbix_get_proxy_server" "zabbix_set_proxy_server"
common_execute_method_param "$DMROOT.Zabbix.Proxy.Name" "1" "zabbix_get_proxy_name" "zabbix_set_proxy_name"
common_execute_method_param "$DMROOT.Zabbix.Proxy.StartPollers" "1" "zabbix_get_start_pollers" "zabbix_set_start_pollers"
common_execute_method_param "$DMROOT.Zabbix.Proxy.CacheSize" "1" "zabbix_get_cache_size" "zabbix_set_cache_size"
return 0;
;;
esac
return $E_INVALID_PARAMETER_NAME;
}
#######################################
# Data model parameters functions #
#######################################
zabbix_get_agent_server() {
echo `$UCI_GET zabbix.agent.server`
}
zabbix_set_agent_server() {
local server=`$UCI_GET zabbix.agent.server`
if [ "$server" != "$1" ]; then
$UCI_SET zabbix.agent.server="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
zabbix_get_proxy_server() {
echo `$UCI_GET zabbix.proxy.hostname`
}
zabbix_set_proxy_server() {
local hostname=`$UCI_GET zabbix.proxy.hostname`
if [ "$hostname" != "$1" ]; then
$UCI_SET zabbix.proxy.hostname="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
zabbix_get_proxy_name() {
echo `$UCI_GET zabbix.proxy.name`
}
zabbix_set_proxy_name() {
local name=`$UCI_GET zabbix.proxy.name`
if [ "$name" != "$1" ]; then
$UCI_SET zabbix.proxy.name="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
zabbix_get_start_pollers() {
echo `$UCI_GET zabbix.proxy.startpollers`
}
zabbix_set_start_pollers() {
local startpollers=`$UCI_GET zabbix.proxy.startpollers`
if [ "$startpollers" != "$1" ]; then
$UCI_SET zabbix.proxy.startpollers="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
zabbix_get_cache_size() {
echo `$UCI_GET zabbix.proxy.cachesize`
}
zabbix_set_cache_size() {
local cachesize=`$UCI_GET zabbix.proxy.cachesize`
if [ "$cachesize" != "$1" ]; then
$UCI_SET zabbix.proxy.cachesize="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
#!/bin/sh
SERVER=`/sbin/uci -q get mysql.credentials.hostname`
DATABASE=`/sbin/uci -q get mysql.credentials.database`
USER=`/sbin/uci -q get mysql.credentials.username`
PASSWORD=`/sbin/uci -q get mysql.credentials.password`
START_POLLERS=`/sbin/uci -q get zabbix.proxy.startpollers`
CACHE_SIZE=`/sbin/uci -q get zabbix.proxy.cachesize`
if [ ! -z "$SERVER" ] && [ ! -z "$DATABASE" ] && [ ! -z "$USER" ] && [ ! -z "$PASSWORD" ]; then
echo "DBHost=$SERVER" > /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
echo "DBName=$DATABASE" >> /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
echo "DBUser=$USER" >> /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
echo "DBPassword=$PASSWORD" >> /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
if [ ! -z "$START_POLLERS" ]; then
echo "StartPollers=$START_POLLERS" >> /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
fi
if [ ! -z "$CACHE_SIZE" ]; then
echo "CacheSize=$CACHE_SIZE" >> /etc/zabbix_proxy.conf.d/zabbix_proxy.conf
fi
else
exit 1
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment