#!/bin/sh
# Zabbix
# Copyright (C) 2001-2015 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Start/Stop the Zabbix server daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
. /etc/rc.d/init.d/functions
BASEDIR=/usr/local/zabbix-server
exec="${BASEDIR}/sbin/zabbix_server"
prog=zabbix_server
pidfile=/var/run/zabbix_server.pid
config="${BASEDIR}/etc/zabbix_server.conf"
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon $exec -c $config
retval=$?
echo
if [ $retval -eq 0 ]; then
touch $lockfile || retval=4
fi
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status -p ${pidfile} $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
exit 2
esac说明
(zabbix系统服务启动脚本默认存放在源码解压包下的/misc/init.d子目录下,也可以使用自带的系统服务启动脚本)
mysql -u root -p123.com
> create database zabbix;
> grant all on zabbix.* to zabbix@localhost identified by '123.com';
> flush privileges;
2.导入zabbix监控模板数据到zabbix数据库
cd /usr/local/src/zabbix-2.4.6/database/mysql/
mysql -uzabbix -p123.com zabbix < schema.sql
mysql -uzabbix -p123.com zabbix < images.sql
mysql -uzabbix -p123.com zabbix < data.sql
tar zxvf zabbix-2.4.6.tar.gz -C /usr/local/src
cd /usr/local/src/zabbix-2.4.6
./configure \
--prefix=/usr/local/zabbix-agent \
--enable-agent \ #开启zabbix agentd
make && make install * 安装完成后(如有报错请根据错误提示排错)还需要将创建zabbix_agentd系统服务启动脚本,内容如下:
#!/bin/sh
# Zabbix
# Copyright (C) 2001-2015 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Start/Stop the Zabbix server daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
. /etc/rc.d/init.d/functions
BASEDIR=/usr/local/zabbix-agent
exec="${BASEDIR}/sbin/zabbix_agentd"
prog=zabbix_agentd
pidfile=/var/run/zabbix_agentd.pid
config="${BASEDIR}/etc/zabbix_agentd.conf"
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon $exec -c $config
retval=$?
echo
if [ $retval -eq 0 ]; then
touch $lockfile || retval=4
fi
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status -p ${pidfile} $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
exit 2
esac
说明
(zabbix系统服务启动脚本默认存放在源码解压包下的/misc/init.d子目录下,也可以使用自带的系统服务启动脚本)
2.添加zabbix_agentd侦听状态: