falcon-agent one-click installation script

Original link: https://chegva.com/5516.html

  • Production Practice:

falcon-agent one-click installation script

  • Study Skills:

Shell EOF use and add timed tasks

  • Script content:

Many of the three-party project machines in the isolation area are unmaintained, and there is no unified monitoring. It is necessary to converge all the basic monitoring to the company’s falcon monitoring, and get a one-click installation script to make the installation more convenient. Regardless of the robustness, it can be used.

 #!/bin/bash # # install_falcon_agent.sh # # create by [email protected] 20221011 #   INSTALL_DIR="/home/anzhihe/app" FALCON_DIR="/home/anzhihe/app/falcon_agentd" CONFIG_FILE="${FALCON_DIR}/cfg.json"   # falcon-agent download download_agent() { if [ ! -d ${FALCON_DIR} ]; then mkdir -p ${INSTALL_DIR} && cd ${INSTALL_DIR} && wget https://file.chegva.com/sre/install_package/falcon_agentd.tar.gz && tar -zxf falcon_agentd.tar.gz else echo "The falcon_agentd directory already exists, exit the installation!" exit 1 fi }  # Add configuration file add_config() { hostname=`hostname` cat << EOF > ${CONFIG_FILE} { "debug": false, "filter": true, "hostname": "${hostname}", "safeguard": { "maxMemMByte": 5000 }, "plugin": { "enabled": false, "dir": "${FALCON_DIR}/plugin", "tarball": "http://file.chegva.com/plugin.tar.gz", "logs": "/home/work/falcon_agentd_plugins/logs" }, "heartbeat": { "enabled": false, "addr": "falcon.chegva.com:8443", "isHttpReporter": false, "httpAddr": "http://falcon.chegva.com:8080", "interval": 60, "timeout": 300000 }, "transfer": { "enabled": true, "isGrpcBackend": false, "addr": "transfer.falcon.chegva.com:80", "isHttpSender": true, "httpAddr": "http://falcon.chegva.com:6060/api/push", "interval": 60, "timeout": 5000, "batch": 200 }, "http": { "enabled": true, "listen": ":1988" }, "collector": { "ifacePrefix": ["eth", "em", "vlan", "p4p"] } } EOF }  # Start falcon-agent start_agent() { PROCESS_NUM=`ps -ef | grep "falcon-agent" | wc -l` TIME=`date +%Y-%m-%d\ %H:%M:%S` #echo $PROCESS_NUM if [ $PROCESS_NUM -eq 2 ]; then echo $TIME "Falcon agent is runningnning" else echo $TIME "Falcon agent is down, will start..." && nohup ${FALCON_DIR}/falcon-agent -c ${CONFIG_FILE} 2>${FALCON_DIR}/var/stderr.log & ps -ef | grep -v grep | grep "falcon-agent" fi }  # Add falcon-agent process monitor timer task add_cron() { # Add crontab timed tasks to timed tasks, the agent sometimes stops by itself if grep -q "falcon_agentd" /var/spool/cron/root; then echo "falcon monitor timer task has been added!" else echo "*/5 * * * * ${FALCON_DIR}/monitor.sh >> ${FALCON_DIR}/var/app.log" >> /var/spool/cron/root echo "Add falcon monitor timer task completed" fi }  main() { echo "Start installing falcon-agent...."s download_agent && add_config && start_agent && add_cron echo "falcon-agent installation is complete, please verify whether there is data displayed: https://falcon.chegva.com/#/dashboard \n" }  main

This article is reprinted from: https://chegva.com/5516.html
This site is for inclusion only, and the copyright belongs to the original author.