1. 用于saltstack自动化部署模式:所有输出全部定向到/dev/null,可以实现在自动化下发配置的时候salt命令全程不卡住
#!/bin/bash

ps aux |grep "filebeat" |grep -v "auto" |awk '{print $2}' |xargs kill -9 >/dev/null 2>&1
nohup /data/filebeat/filebeat -e -c filebeat.yml >/dev/null 2>&1 &

2、简单排错模式:把debug输出重定向追加到文件,适用于判断与ES VIP后端节点的通信情况判断,以及简单的判断filebeat是否启动harvester组件采集某个路径下的日志

#!/bin/bash

ps aux |grep "filebeat" |grep -v "auto" |awk '{print $2}' |xargs kill -9 >/dev/null 2>&1
nohup /data/filebeat/filebeat -e -c filebeat.yml 2>> filebeat.log &

3、全部 debug selector都开启模式:适用于分析filebeat全部采集链路,非特殊情况慎用,用完及时关闭,否者短时间内日志暴涨几十G

#!/bin/bash

ps aux |grep "filebeat" |grep -v "auto" |awk '{print $2}' |xargs kill -9 >/dev/null 2>&1
nohup /data/filebeat/filebeat -e -d "*" -c filebeat.yml 2>> filebeat.log &