From: <abe...@us...> - 2012-08-29 19:12:41
|
Revision: 5651 http://astlinux.svn.sourceforge.net/astlinux/?rev=5651&view=rev Author: abelbeck Date: 2012-08-29 19:12:35 +0000 (Wed, 29 Aug 2012) Log Message: ----------- zabbix, add proxy support to zabbix.init, three new variables: ZABBIX_PROXY, ZABBIX_PROXY_AGENT and ZABBIX_PROXY_HOSTNAME Modified Paths: -------------- branches/1.0/package/zabbix/zabbix.init branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf Modified: branches/1.0/package/zabbix/zabbix.init =================================================================== --- branches/1.0/package/zabbix/zabbix.init 2012-08-29 16:20:13 UTC (rev 5650) +++ branches/1.0/package/zabbix/zabbix.init 2012-08-29 19:12:35 UTC (rev 5651) @@ -9,6 +9,9 @@ if [ -f /tmp/etc/zabbix_agentd.conf ]; then rm /tmp/etc/zabbix_agentd.conf fi + if [ -f /tmp/etc/zabbix_proxy.conf ]; then + rm /tmp/etc/zabbix_proxy.conf + fi exit fi @@ -17,6 +20,15 @@ exit fi + proxy_enabled=0 + if [ "$ZABBIX_PROXY" = "yes" ] || [ -f /mnt/kd/zabbix_proxy.conf ]; then + if [ -x /usr/bin/zabbix_proxy ]; then + proxy_enabled=1 + else + echo "zabbix: zabbix_proxy not installed." + fi + fi + # Allow space/comma in ZABBIX_SERVER, but zabbix requires comma's IFS=' ,' for i in $ZABBIX_SERVER; do @@ -30,7 +42,50 @@ startagents="${ZABBIX_STARTAGENTS:-3}" debuglevel="${ZABBIX_DEBUGLEVEL:-3}" timeout="${ZABBIX_TIMEOUT:-3}" + proxyhostname="${ZABBIX_PROXY_HOSTNAME:-proxy-$HOSTNAME}" + proxylistenport=$(($listenport + 1)) + if [ $proxy_enabled -eq 1 ]; then + + # Generate /etc/zabbix_proxy.conf configuration file + if [ -f /mnt/kd/zabbix_proxy.conf ]; then + echo "# Autogenerated. Edit /mnt/kd/zabbix_proxy.conf file. +" >/tmp/etc/zabbix_proxy.conf + cat /mnt/kd/zabbix_proxy.conf >>/tmp/etc/zabbix_proxy.conf + else + echo "# Autogenerated. Do not edit. +# A manually generated zabbix_proxy config will use /mnt/kd/zabbix_proxy.conf if it exists. +Server=$server +ServerPort=$serverport +Hostname=$proxyhostname +ListenPort=$proxylistenport +DebugLevel=$debuglevel +Timeout=$timeout +DBName=/var/db/zabbix/zabbix_proxy.db +PidFile=/var/run/zabbix_proxy.pid +LogFile=/var/log/zabbix_proxy.log +" >/tmp/etc/zabbix_proxy.conf + fi + chown zabbix:zabbix /tmp/etc/zabbix_proxy.conf + + if [ ! -d /var/db/zabbix ]; then + mkdir /var/db/zabbix + chown zabbix:zabbix /var/db/zabbix + fi + + touch /var/log/zabbix_proxy.log + chown zabbix:zabbix /var/log/zabbix_proxy.log + + # Set zabbix_agentd server to localhost unless ZABBIX_PROXY_AGENT="no" + if [ "$ZABBIX_PROXY_AGENT" != "no" ]; then + server="127.0.0.1" + fi + else + if [ -f /tmp/etc/zabbix_proxy.conf ]; then + rm /tmp/etc/zabbix_proxy.conf + fi + fi + # Generate /etc/zabbix_agentd.conf configuration file if [ -f /mnt/kd/zabbix_agentd.conf ]; then echo "# Autogenerated. Edit /mnt/kd/zabbix_agentd.conf file. @@ -40,7 +95,6 @@ echo "# Autogenerated. Do not edit. # A manually generated zabbix_agentd config will use /mnt/kd/zabbix_agentd.conf if it exists. Server=$server -ServerPort=$serverport Hostname=$hostname ListenPort=$listenport StartAgents=$startagents @@ -59,6 +113,15 @@ start () { + if [ -f /etc/zabbix_proxy.conf ]; then + echo "Starting Zabbix Proxy..." + + touch /var/run/zabbix_proxy.pid + chown zabbix:zabbix /var/run/zabbix_proxy.pid + + zabbix_proxy -c /etc/zabbix_proxy.conf + fi + if [ -f /etc/zabbix_agentd.conf ]; then echo "Starting Zabbix Agent Daemon..." @@ -77,6 +140,13 @@ kill $(cat /var/run/zabbix_agentd.pid) >/dev/null 2>&1 rm -f /var/run/zabbix_agentd.pid fi + + if [ -f /var/run/zabbix_proxy.pid ]; then + echo "Stopping Zabbix Proxy..." + + kill $(cat /var/run/zabbix_proxy.pid) >/dev/null 2>&1 + rm -f /var/run/zabbix_proxy.pid + fi } case $1 in Modified: branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf =================================================================== --- branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2012-08-29 16:20:13 UTC (rev 5650) +++ branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2012-08-29 19:12:35 UTC (rev 5651) @@ -917,12 +917,15 @@ ## Zabbix Agent Daemon ## Zabbix is enabled if ZABBIX_SERVER is defined. #ZABBIX_SERVER="" # Comma/space separated list of IP addresses or hostnames for zabbix servers -#ZABBIX_SERVER_PORT="10051" # TCP port used for retrieving/sending active check data +#ZABBIX_SERVER_PORT="10051" # TCP port used for retrieving/sending active check data (proxy-only) #ZABBIX_HOSTNAME="" # Unique, case sensitive hostname, required for active checks -#ZABBIX_LISTENPORT="10050" # TCP port that zabbix_agentd listens on locally +#ZABBIX_LISTENPORT="10050" # TCP port that zabbix_agentd listens on locally, proxy if enabled uses one port higher #ZABBIX_STARTAGENTS="3" # Number of pre-forked instances of zabbix_agentd, must be between 1-16 #ZABBIX_DEBUGLEVEL="3" # "0" is no debug, "1" is critical, "2" is errors, "3" is warnings, "4" is full debugging #ZABBIX_TIMEOUT="3" # Processing limit in seconds, must be between 1-30 +#ZABBIX_PROXY="yes" # "yes" is to enable proxy, disabled by default +#ZABBIX_PROXY_AGENT="no" # By default the zabbix_agentd is routed via the proxy if enabled, set to "no" to disable +#ZABBIX_PROXY_HOSTNAME="" # Unique, case sensitive Proxy name. Make sure the Proxy name is known to the server. ## NFS Server support (read only exports) #NFS_EXPORTS_RO="/tftpboot" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |