1. zabbix客户端的系统服务脚本

1.1 拷贝启动脚本

zabbix的源码提供了系统服务脚本,在/usr/local/src/zabbix-3.2.6/misc/init.d目录下,我的系统是CentOS的,所以选择fedora下的脚本复制到/etc/init.d下

[root@lanmp core5]# pwd
/usr/local/src/zabbix-3.2.6/misc/init.d/fedora/core5 [root@lanmp core5]# cp -a zabbix_agentd /etc/init.d/

  这里需要添加一个软链接,否则会报错退出

ln -s /usr/local/zabbix-3.2.6/sbin/zabbix_agentd /usr/local/sbin/

 1.2 添加到开机自启动

[root@lanmp init.d]# chkconfig --add zabbix_agentd
[root@lanmp init.d]# chkconfig zabbix_agentd on
[root@lanmp init.d]# chkconfig --list|grep zabbix_agentd
zabbix_agentd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  脚本内容

#!/bin/bash
#
# /etc/rc.d/init.d/zabbix_agentd
#
# Starts the zabbix_agentd daemon
#
# chkconfig: - 95 5
# description: Zabbix Monitoring Agent
# processname: zabbix_agentd
# pidfile: /tmp/zabbix_agentd.pid # Modified for Zabbix 2.0.0
# May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0
prog="Zabbix Agent"
ZABBIX_BIN="/usr/local/sbin/zabbix_agentd" if [ ! -x ${ZABBIX_BIN} ] ; then
echo -n "${ZABBIX_BIN} not installed! "
# Tell the user this has skipped
exit 5
fi start() {
echo -n $"Starting $prog: "
daemon $ZABBIX_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd
echo
} stop() {
echo -n $"Stopping $prog: "
killproc $ZABBIX_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd
echo
} case "$1" in
start)
start
;;
stop)
stop
;;
reload|restart)
stop
sleep 10
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/zabbix_agentd ]; then
stop
start
fi
;;
status)
status $ZABBIX_BIN
RETVAL=$?
;;
*)
echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"
exit 1
esac exit $RETVAL

  

2.2 服务端的系统服务脚本

 同样的方法,这里就不演示了

#!/bin/bash
#
# /etc/rc.d/init.d/zabbix_server
#
# Starts the zabbix_server daemon
#
# chkconfig: - 95 5
# description: Zabbix Monitoring Server
# processname: zabbix_server
# pidfile: /tmp/zabbix_server.pid # Modified for Zabbix 2.0.0
# May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0
prog="Zabbix Server"
ZABBIX_BIN="/usr/local/sbin/zabbix_server" if [ ! -x ${ZABBIX_BIN} ] ; then
echo -n "${ZABBIX_BIN} not installed! "
# Tell the user this has skipped
exit 5
fi start() {
echo -n $"Starting $prog: "
daemon $ZABBIX_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server
echo
} stop() {
echo -n $"Stopping $prog: "
killproc $ZABBIX_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_server
echo
} case "$1" in
start)
start
;;
stop)
stop
;;
reload|restart)
stop
sleep 10
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/zabbix_server ]; then
stop
start
fi
;;
status)
status $ZABBIX_BIN
RETVAL=$?
;;
*)
echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"
exit 1
esac exit $RETVAL

  

zabbix的启动和关闭脚本的更多相关文章

  1. MySQL 多实例启动和关闭脚本

    DB: 5.5.14 OS:CentOS 6.3 在MySQL多实例中,一个一个启动灰常麻烦,因此写个简单的启动和关闭脚本 启动脚本:start.sh #!/bin/bash for port in ...

  2. redis集群启动和关闭脚本

    创建startall.sh /usr/local/redis/bin/redis-server /usr/local/redis/redis-cluster/7001/redis.conf /usr/ ...

  3. redis启动、关闭脚本

    #!/bin/bash PORT= NAME=redis-server ID=`ps -ef | grep "$NAME" | grep -v "grep" | ...

  4. EBS R12.2 创建应用层的启动和关闭脚本

    Create the following files to start and stop R12. application tier. Change the apps and weblogic pas ...

  5. tomcat 启动和关闭脚本

    start.sh #!/bin/sh . ~/.bash_profile echo "" > ${TOMCAT_HOME}/logs/catalina.out; sh ${T ...

  6. zabbix源码安装后,设置为服务启动和关闭

    zabbix源码安装,使用service启动与关闭服务 1. zabbix客户端的系统服务脚本 1.1 拷贝启动脚本 zabbix的源码提供了系统服务脚本,在/usr/local/src/zabbix ...

  7. 使用dbstart 和dbshut 脚本来自动化启动和关闭数据库

    使用dbstart 和dbshut 脚本来自动化启动和关闭数据库:1. 登录用户root.2. 编辑你的平台的oratab 文件.打开文件/etc/oratab:文件里数据库条目为以下格式:SID:O ...

  8. 启动和关闭JBoss As 7.1.1脚本

    启动和关闭JBoss As 7.1.1,脚本例如以下djboss.sh: #!/bin/sh #JBOSS_HOME JBOSS_HOME=/opt/jboss case "$1" ...

  9. 【springboot】之利用shell脚本优雅启动,关闭springboot服务

    springbot开发api接口服务,生产环境中一般都是运行独立的jar,在部署过程中涉及到服务的优雅启动,关闭, springboot官方文档给出的有两种方式, 1.使用http shutdown ...

随机推荐

  1. Android ListView实现单击item出现删除按钮以及滑动出现删除按钮

    我自己一个人弄的公司的产品客户端,所以还是想记录下来以免忘记或者丢失... 在我的上一篇博文(点击打开链接)是一个文件管理的东西,基础组件也是ListView所以在此只是改动一下而已. 单击: 点击出 ...

  2. 网络中TCP、IP、MAC、UDP的头部格式信息

    TCP头部格式 字段名称 长度(比特) 含义 TCP头部(20字节~) 发送方端口号 16 发送网络包的程序的端口号 接收方端口号 16 网络包的接收方程序的端口号 序号(发送数据的顺序编号) 32 ...

  3. JDBC创建表实例

    在本教程将演示如何在JDBC应用程序中创建一个数据库表. 在执行以下示例之前,请确保您已经准备好以下操作: 具有数据库管理员权限,以在给定模式中创建数据库表. 要执行以下示例,需要用实际用户名和密码替 ...

  4. e587. Filling Basic Shapes

    There are two ways to fill basic shapes like lines and rectangles. The first is to use specific draw ...

  5. Python——eventlet.wsgi

    eventlet 的 wsgi 模块提供了一种启动事件驱动的WSGI服务器的简洁手段,可以将其作为某个应用的嵌入web服务器,或作为成熟的web服务器,一个这样的web服务器的例子就是 Spawnin ...

  6. firefox插件-HackBar介绍与试用

    This toolbar will help you in testing sql injections, XSS holes and site security. It is NOT a tool ...

  7. git 出错 bad index file sha1 signature

    error: bad index file sha1 signature fatal: index file corrupt 解决方法:使用git命令执行: $ rm -f .git/index $ ...

  8. <转>Win8.1+CentOS7 双系统 U盘安装

    0.准备工作 1.宏碁 Aspire 4752G 笔记本 2.Win8.1 企业版操作系统 3.8G 以上 U 盘 4.UltraISO(当然也可以选择其他的U盘制作工具,看个人喜好) 5.下载 Ce ...

  9. 关于WSDL的理解

    WSDL是由types, message, portType组成. 而binding, service则是具体的绑定. portType有哪些operation. 然后是portType的Endpoi ...

  10. TradeStation简介

        TradeStation是美国一款经典程序化交易软件,支持股票.期货.外汇.期权等交易品种.它是由美国TradeStation公司开发,主要服务于美股.     TradeStation的设计 ...