I could not find a tutorial that showed how to install the precompiled Zabbix 2.0 agents on a 64 bit Debian box, so I'm making one here.
The latest downloads for precompiled agents and source code for building servers is here. http://www.zabbix.com/download.php
On the Debian system that is getting the agent (remember this is for 64 bit version of Debian, go to the Zabbix download site for the link to the 32 bit agent if your system is 32 bit):
We need both the precompiled agent and the source files
You should be logged in to a root sudo or su session for the following
cd $HOME
wget http://www.zabbix.com/downloads/2.0.0/zabbix_agents_2.0.0.linux2_6_23.amd64.tar.gz
wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.0/zabbix-2.0.0.tar.gz
mkdir zabbix
cd zabbix
tar -xzvf ../zabbix_agents_2.0.0.linux2_6_23.amd64.tar.gz
tar -xzvf $HOME/zabbix-2.0.0.tar.gz
cp $HOME/zabbix/bin/* /usr/bin
cp $HOME/zabbix/sbin/* /usr/sbin
groupadd zabbix
useradd -g zabbix zabbix
mkdir /var/log/zabbix-agent
chown zabbix:zabbix /var/log/zabbix-agent
nano /usr/local/etc/zabbix_agent.conf
Change "Server=127.0.0.1" option to the IP address of your Zabbix server, for example:
Server=192.168.1.10
Exit and save the file
nano /usr/local/etc/zabbix_agentd.conf
Change "LogFile=/tmp/zabbix_agentd.log" to:>/P>
LogFile=/var/log/zabbix_agentd.log
Change "Server=127.0.0.1" option to the IP address of your Zabbix server, for example:
Server=192.168.1.10
Change "ServerActive=127.0.0.1" option to the IP address of your Zabbix server, for example:
ServerActive=192.168.1.10
Rem out the "Hostname=Zabbix server" line:
#Hostname=Zabbix server
Exit and save the file
nano /etc/init.d/zabbix-agent
#! /bin/sh
counter=0
zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l)
start(){
echo "-------------------------------------------------------------------"
echo " LAUNCHING ZABBIX AGENT"
if [ $zabbix_counter -gt 0 ]; then
echo " * Zabbix agent was previously running"
echo " * Number of Zabbix agentd instances= $zabbix_counter"
echo "-----------------------------------------------------------------"
fi
# Checking if the user is able to start the agent.... if the user is not able to, script performs su to
# the user zabbix and starts the agent
if [ $(whoami) != "zabbix" ];then
sudo -u zabbix zabbix_agentd
else
# Script is acting as the zabbix user, so it can start the agent.
zabbix_agentd
fi
sleep 10
zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l)
if [ $zabbix_counter -gt 0 ]; then
echo " * Zabbix agent succesfully started"
echo " * Number of zabbix agentd instances= $zabbix_counter"
echo "-------------------------------------------------------------------"
else
echo " * Zabbix agent couldn't be started, check Zabbix logs"
echo "-------------------------------------------------------------------"
fi
}
stop(){
# Checking if the user is able to stop the agent.... if the user is not able to, script performs su to
# the user zabbix and kills the agent. Also script tries to kill zabbix-agent processes 5 times using a counter, if at
# the fith try the agent is still there, script outputs a message to the console.
echo "-------------------------------------------------------------------"
echo " STOPPING ZABBIX AGENT"
if [ $zabbix_counter -eq 0 ]; then
echo " * Zabbix agent was not running on this machine"
echo "-------------------------------------------------------------------"
fi
while [ $zabbix_counter -gt 0 ] && [ $counter -lt 5 ] ; do
let counter=counter+1
echo " * Number of Attempts (Max 5)=$counter"
echo " * Stopping zabbix.."
echo " * Number of zabbix agentd instances= $zabbix_counter"
if [ $(whoami) != "zabbix" ];then
sudo -u zabbix killall zabbix_agentd > /dev/null &
else
killall zabbix_agentd > /dev/null &
fi
sleep 10
# Script has a 10 second delay to avoid attempting to kill a process that is still shutting down. If the script
# can't kill the processes, an error will appear.
# After 10 seconds script checks again the number of zabbix_agentd processes running,
# if it's 0, script will exit the loop and continue on
zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l)
done
if [ $zabbix_counter -gt 0 ]; then
echo " * Zabbix agent couldn't be stopped, check Zabbix logs"
echo "-------------------------------------------------------------------"
fi
if [ $zabbix_counter -eq 0 ]; then
echo " * Zabbix agent successfully stopped"
echo "-------------------------------------------------------------------"
fi
}
restart(){
stop
# Gives system some time to stop processes before script restarts service
sleep 10
# Now script can start the agent again
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: zabbix {start|stop|restart}"
exit 1
esac
exit 0
Exit and save the file
chmod 744 /etc/ini.d/zabbix-agent
ln -s /etc/init.d/zabbix-agent /sbin/zabbix-agent
update-rc.d zabbix-agent defaults
Go to your Zabbix server's web interface and add the new system to hosts as you normally would and configure accordingly and you are done.
References:
http://www.zabbix.com/forum/showthread.php?p=103244#post103244
Recent Comments