1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| #!/bin/bash
#the zabbix path you want to install
PREFIX="/usr/local/zabbix"
ConfigFile="/etc/zabbix/zabbix_agentd.conf"
# List of comma delimited IP addresses (or hostnames) of Zabbix servers.
Server="serverName"
#Required for active checks and must match hostname as configured on the server.
Hostname=`hostname`
function checkReturn {
if [ $1 -ne 0 ]; then
echo "fail: $2"
echo "$3"
exit
else
echo "pass: $2"
fi
sleep 3
}
[ -n "$(pidof -s zabbix_agentd)" ] && {
echo "zabbix_agentd process is already running....."
exit 1
}
[ -n "$(which zabbix_agentd 2> /dev/null)" ] && {
echo "zabbix_agentd program has been installed....."
exit 1
}
# check selinux
if [ "`/usr/sbin/sestatus|awk '/status/{print $3}'`" == "enabled" ]; then
checkReturn 1 "Disable SELinux and then retry"
fi
rpm -q gcc make || {
yum install gcc make
RETVAL=$?
checkReturn $RETVAL "Package install"
}
if [ -z "$(id -u zabbix 2> /dev/null)" ]
then
useradd zabbix -s /sbin/nologin
fi
wget http://sourceforge.net/projects/ ... zabbix-2.0.8.tar.gz
RETVAL=$?
checkReturn $RETVAL "downloading source" "check mirror might be down"
tar xvf zabbix-2.0.8.tar.gz
cd zabbix-2.0.8
./configure --prefix=${PREFIX} --enable-agent
RETVAL=$?
checkReturn $RETVAL "Configure"
make
RETVAL=$?
checkReturn $RETVAL "Compile"
make install
RETVAL=$?
checkReturn $RETVAL "make install"
echo "zabbix agentd install ok....!"
mkdir -p /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix
echo "configure zabbix startup script.....!"
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod 755 /etc/init.d/zabbix_agentd
sed -i 's#BASEDIR=/usr/local#&/zabbix#' /etc/init.d/zabbix_agentd
chkconfig --level 345 zabbix_agentd on
echo "copy the configuration file to zabbix installion directory.....!"
if [ -d ${PREFIX}/etc ]
then
/bin/rm -rf ${PREFIX}/etc/*
cp conf/zabbix_agentd.conf ${PREFIX}/etc
fi
echo "add link file.....!"
ln -s /usr/local/zabbix/etc /etc/zabbix
ln -s /usr/local/zabbix/bin/* /usr/bin/
ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[ -f "$ConfigFile" ] && {
sed -i "/^Server=/s#.*#Server=$Server#" $ConfigFile
sed -i "/^ServerActive/s#.*#ServerActive=$Server:10051#" $ConfigFile
sed -i '/^LogFile=/s#.*#LogFile=/var/log/zabbix/zabbix_agentd.log#' $ConfigFile
sed -i '/UnsafeUserParameters=0/aUnsafeUserParameters=1' $ConfigFile
if [ -n $Hostname ]
then
sed -i "/^Hostname=/c\Hostname=${Hostname}" $ConfigFile
fi
}
echo '/etc/services add service port.....!'
cat >> /etc/services << EOF
#zabbix agentd
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
|