> For the complete documentation index, see [llms.txt](https://xn--6o0a585a.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xn--6o0a585a.gitbook.io/devops/jian-kong/fei-shu-ri-zhi-jian-kong.md).

# 飞书日志监控

![](/files/7WWySi9AqPxowUdxZGHb)

Nginx 的log日志文件下载查看配置

```nginx
  server {
     listen 80;
     auth_basic "Nginx";  
     auth_basic_user_file /usr/local/nginx/conf/passwd1;
     autoindex on;
     server_name log.hanye;
     charset utf-8;
     
     location / {
          root  /data/sh/log;
          autoindex_exact_size off; # 关闭计算文件确切大小（单位bytes），只显示大概大小（单位kb、mb、gb）
          autoindex_localtime on; 
          autoindex on;
      }
  }
```

```bash
 #!/bin/bash
 #crontab: * * * * * monitor_failed_log_monitor.sh
 TIME=`date +%Y-%m-%d-%H:%M:%S`
 IP='192.168.31.12'
 FUNC_feishu() {
    Webhook=https://open.feishu.cn/open-apis/bot/v2/hook/$token
    curl -d  '{"msg_type":"text","content":{"text":" 所属集群: '$message' \n 服务地址: '$IP' \n 报错时间: '$TIME' \n 服务类型: '$message1' \n 日志地址: '$message2/$message3' \n 登录账号: \n 登录密码:  "}}' \
   -H 'Content-Type: application/json' \
   -X POST $Webhook
 }
 
 FUNC_msg() {
      Time=`date  +%Y-%m-%d`
      message=华北集群
      message1=php-fpm日志报错
      message2=http://192.168.31.12
      message3=php-fpm-$Time.log
      md5file="/data/sh/log/fpm.txt"
      logfile="/data/sh/log/php-fpm-$Time.log"
      fpmfile="/home/laravel/storage/logs/laravel.log"
      if [ ! -f $fpmfile ]; then
              echo "" > $fpmfile
              chmod -R 777 $fpmfile
              echo "1" > /data/sh/log/line
      fi
      file_new_stat="`stat ${fpmfile}|grep Size|awk -F":" '{print $2}'|awk '{print $1}'`"
      #获取MD5
      SCAN_CMD=`which  md5sum`
      #获取文件最新行
      count=`cat -n $fpmfile |awk '{print $1}' |tail -n1`
      #获取文件上一次的行
      count2=`cat /data/sh/log/line`
      b=`cat $md5file`
      a=`${SCAN_CMD} ${fpmfile}|awk '{print $1}'`
      #if [ $a != $b ]; then
           if [ $count -gt $count2 ]; then
           tail -n +$count2  $fpmfile|grep  -Ei  "ErrorException|QueryException|FatalThrowableError|prod.ERROR" > /dev/null
           if [ $? -eq 0 ]; then
             tail  -n +$count2 $fpmfile|grep -v "INFO" > $logfile
             FUNC_feish
             /usr/bin/scp $logfile root@192.168.31.12:/data/sh/log/ > /dev/null
           fi
           echo "$a" > $md5file
           cat -n $fpmfile |awk '{print $1}' |tail -n1 > /data/sh/log/line
        fi
 }
 FUNC_msg
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xn--6o0a585a.gitbook.io/devops/jian-kong/fei-shu-ri-zhi-jian-kong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
