zabbix源码安装后,设置为服务启动和关闭
2024-09-30 15:46:43
zabbix源码安装,使用service启动与关闭服务
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 |
最新文章
- php用正则检测某字段开头是否为字母
- SHOPNC占用CPU过高
- uploadfile上传文件时ie浏览器无法弹出窗口
- href脱离iframe显示
- Java [Leetcode 260]Single Number III
- ajax。表单
- Windows消息拦截技术的应用
- 低效的SQL引发的cache buffers chains latch
- Linux2.6内核 -- 编码风格(3)
- Python 2.7 学习笔记 条件与循环语句
- 界面编程与视图(View)组件
- webpack初步介绍
- Centos小白学习
- boost::bad_weak_ptr的原因
- javascript正则表达式中 (?=exp)、(?<;=exp)、(?!exp)
- float导致出现大面积空白
- 解决highCharts导出功能汉化问题
- Docker 安装Hadoop HDFS命令行操作
- 配置httpd支持https
- markdown的试用
热门文章
- bzoj 3398: [Usaco2009 Feb]Bullcow 牡牛和牝牛【dp】
- Luogu P1186 玛丽卡 【最短路】By cellur925
- Luogu P1273 有限电视网【树形Dp/树形背包】
- 【正睿多校联盟Day4 T4 简单的数论题】
- vue按需加载组件,异步组件
- iOS开发系列--通知与消息机制--转
- javaweb-JSP action中附件下载的写法
- webpack 报错:Module build failed: Unknown word (1:1)
- Django model 反向引用中的related_name
- H3C AR28-31路由器组网实验