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. (笔记)arm-linux-gcc/ld/objcopy/objdump参数总结

    说明:gcc是编译器,负责对c代码的编译, ld是连接器 负责将多个*.o的目标文件链接成elf可执行文件.elf可执行文件是unix常用的可执行文件类型,就像windows的exe文件.elf文件中 ...

  2. Aizu_Insertion Sort

    原题链接:https://vjudge.net/problem/Aizu-ALDS1_1_A 题目描述 Write a program of the Insertion Sort algorithm ...

  3. 我的openwrt开发相关文章

    openwrt学习笔记: 在openwrt的学习过程中,走了非常多的弯路.一直以来有个期盼.希望能够出个简易教程,希望openwrt的同仁们能够更加高速的入手. . openwrt学习笔记(三十二): ...

  4. python_smtplib

    import smtplib smtpserver = 'smtp.qq.com' fromaddr = 'fromaddr@qq.com' toaddrs = 'toaddr@qq.com' msg ...

  5. wapp HTTP Error 404. The requested resource is not found.

    原因: 本地80端口被占用,需要修改WAMP的默认端口 修改设置: 找到 bin/apache/apache***/conf/httpd.conf文件 将文件中的80修改为8088 修改这两个地方端口 ...

  6. TCP三次握手建立关系

    三次握手(three times handshake:three-way handshake)所谓的“三次握手”即对每次发送的数据量是怎样跟踪进行协商使数据段的 发送和接收同步,根据所接收到的数据量而 ...

  7. CentOS系统基础优化16条知识汇总

    1.不用root管理,以普通用户的名义通过sudo授权管理: 2.更改默认的远程连接服务端,禁止root用户远程连接,甚至要更改只监听内网ip: 3.定时自动更新服务器时间,使其和互联网时间同步: 4 ...

  8. C# 判断两张图片是否一致,极快速

    #region 判断图片是否一致 /// <summary> /// 判断图片是否一致 /// </summary> /// <param name="img& ...

  9. 【转】IOS 学习之 NSPredicate 模糊、精确、查询

    转自:http://blog.csdn.net/lianbaixue/article/details/10579117   简述:Cocoa框架中的NSPredicate用于查询,原理和用法都类似于S ...

  10. struts实现国际化

    上篇博客学习了Java国际化的一些基础知识,了解了这些知识之后,我们可以更好的过度到struts国际化. 本篇博客主要学习struts国际化的实现: 1.配置环境设置baseName. 在struts ...