elk相关启动脚本-shell编写

Posted immense

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elk相关启动脚本-shell编写相关的知识,希望对你有一定的参考价值。

 

elasticsearch-restart

#!/bin/bash

PID=`ps -ef|grep elasticsearch|grep -vE ‘grep|controller|elasticsearch-restart‘|awk ‘print $2‘`
kill -9 $PID >/dev/null 2>&1
sleep 1
nohup elasticsearch -d >/data/soft/elasticsearch/nohup.out 2>&1 &
if [ ! -z $PID ]
then
echo SUCCESS!
fi

 

filebeat-restart

#!/bin/bash

PID=`ps -ef|grep filebeat|grep -vE ‘grep|filebeat-restart‘|awk ‘print $2‘`
kill -9 $PID >/dev/null 2>&1
sleep 1
nohup filebeat -c /data/soft/filebeat/filebeat.yml >/data/soft/filebeat/nohup.out 2>&1 &
if [ ! -z $PID ]
then
echo SUCCESS!
fi

 

kibana-restart

#!/bin/bash

PID=`ps -ef|grep kibana|grep -vE ‘grep|kibana-restart‘|awk ‘print $2‘`
kill -9 $PID >/dev/null 2>&1
sleep 1
nohup /data/soft/kibana/bin/kibana >/data/soft/logstash/out.log 2>&1 &
if [ ! -z $PID ]
then
echo SUCCESS!
fi

 

logstash-control

#!/bin/bash


pid_exists()
nohup logstash -f /data/soft/logstash/config/logstash.conf >/data/soft/logstash/out.log 2>&1 &
sleep 1
PID=`ps -ef|grep logstash|grep -vE ‘grep|logstash-control|logstash-plain‘|awk ‘print $2‘`
if [ ! -z $PID ]
then
echo SUCCESS!
else
echo FAILED!
fi

pid_not_exists()
PID=`ps -ef|grep logstash|grep -vE ‘grep|logstash-control|logstash-plain‘|awk ‘print $2‘`
if [ ! -z $PID ]
then
kill -9 $PID >/dev/null 2>&1
echo SUCCESS!
else
echo "PID has been killed!..."
fi

case $1 in
start)
echo -n "starting......"
pid_exists
;;
stop)
echo -n "stopping......"
pid_not_exists
;;
*)
echo "sorry,other opera"
;;
esac

 

以上是关于elk相关启动脚本-shell编写的主要内容,如果未能解决你的问题,请参考以下文章

几例实用shell脚本分享

安装apached源码包以及编写shell脚本使其启动更加方便,并且和启动系统服务相同

Linux如何编写自启动shell脚本

Linux - 简易shell脚本编写,以开机日志为例,编写一个用于查看Linux进程启动的脚本

linux shell 之尝试编写 企业级 启动脚本

ELK的启动脚本