原文链接:https://www.cnblogs.com/zydev/p/6888805.html

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

1.1 拷贝启动脚本

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

1
2
3
4
[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/

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

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

 1.2 添加到开机自启动

1
2
3
4
[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

  脚本内容

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
#!/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 服务端的系统服务脚本

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

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
#!/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

最新文章

  1. .NET平台开源项目速览(4).NET文档生成工具ADB及使用
  2. MATLAB绘图
  3. Oracle数据库,序列、索引、视图
  4. Window 通过cmd查看端口占用、相应进程、杀死进程等的命令【转】
  5. sublime text 3安装package console
  6. LaTeX 有哪些「新手须知」的内容?
  7. [翻译]了解ASP.NET底层架构(八)
  8. jQuery easyui 提示框
  9. 搭建Spring + SpringMVC + Mybatis框架之三(整合Spring、Mybatis和Spring MVC)
  10. 防止IE缓存jquery ajax 内容
  11. C++赋值运算符、函数调用运算符、下标运算符(“=”、“()”、“[]”)重载
  12. UNIX基础--进程和守护进程
  13. vsftpd 安装
  14. MongoDb进阶实践之三 Mongodb基本命令详解
  15. python元类理解2
  16. HDFS的一些重要流程
  17. BZOJ1835 [ZJOI2010] 基站选址 【动态规划】【线段树】
  18. 学生与部门管理app-产品功能与界面的简单设计
  19. Python开发【Django】:图片验证码、KindEditor
  20. Quartz-作业调度框架

热门文章

  1. 9-Perl 条件语句
  2. Python(八) —— 异常(概念、捕获、传递、抛出)
  3. sql当前时间往后半年
  4. # 风险定性(Qualitative)分析
  5. JS基础_流程控制语句
  6. ado.net 断开 非断开
  7. php底层的运行机制和原理
  8. shell查询MySQL并将结果写入文件中
  9. Delphi ActiveX编程
  10. 【安徽集训】Emerald