zabbix的启动和关闭脚本
生活随笔
收集整理的這篇文章主要介紹了
zabbix的启动和关闭脚本
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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/functionsRETVAL=0 prog="Zabbix Agent" ZABBIX_BIN="/usr/local/sbin/zabbix_agentd"if [ ! -x ${ZABBIX_BIN} ] ; thenecho -n "${ZABBIX_BIN} not installed! "# Tell the user this has skippedexit 5 fistart() {echo -n $"Starting $prog: "daemon $ZABBIX_BINRETVAL=$?[ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentdecho }stop() {echo -n $"Stopping $prog: "killproc $ZABBIX_BINRETVAL=$?[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentdecho }case "$1" instart)start;;stop)stop;;reload|restart)stopsleep 10startRETVAL=$?;;condrestart)if [ -f /var/lock/subsys/zabbix_agentd ]; thenstopstartfi;;status)status $ZABBIX_BINRETVAL=$?;;*)echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"exit 1 esacexit $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/functionsRETVAL=0 prog="Zabbix Server" ZABBIX_BIN="/usr/local/sbin/zabbix_server"if [ ! -x ${ZABBIX_BIN} ] ; thenecho -n "${ZABBIX_BIN} not installed! "# Tell the user this has skippedexit 5 fistart() {echo -n $"Starting $prog: "daemon $ZABBIX_BINRETVAL=$?[ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_serverecho }stop() {echo -n $"Stopping $prog: "killproc $ZABBIX_BINRETVAL=$?[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_serverecho }case "$1" instart)start;;stop)stop;;reload|restart)stopsleep 10startRETVAL=$?;;condrestart)if [ -f /var/lock/subsys/zabbix_server ]; thenstopstartfi;;status)status $ZABBIX_BINRETVAL=$?;;*)echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"exit 1 esacexit $RETVAL
總結
以上是生活随笔為你收集整理的zabbix的启动和关闭脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HeadFirst设计模式篇四:工厂模式
- 下一篇: 6月30日云栖精选夜读:程序员技术与文艺