zoukankan      html  css  js  c++  java
  • 查询elasticsearch索引日志条数

    只是用来记录一些简单的报警脚本

    看看就行

    ]# cat es_index_count.sh 
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    #dhger的2台服务器
    for i in {2008,2008-2};
    do
    curl -u elastic:elk_123 -X GET http://127.0.0.1:9200/dhger-*/_count -H 'Content-Type: application/json' -d '
    {
      "query": {
        "bool": {
          "must": [],
          "filter": [
            { "match_phrase": 
            {"agent.hostname.keyword": {"query": "'$i'" }
            }
            },
            {"range": {
                "@timestamp": {"from": "now-15m"}
            }
            }
          ]
        }
      }
    }' > /soft/ecc-${i}.txt
    y=`awk -F '[:,]' '{print $2}' /soft/ecc-${i}.txt`
    if [ $y -eq 0 ];then
    #/bin/bash /soft/alert.sh "dhgner-$i" "$y"
    /usr/bin/python /soft/python3 "`date +%H:%M` dhger服务 $i" "$y"
    sleep 10
    echo $y
    fi
    done
    #dher的2台服务器
    for i in {dh-2008,ct-2008-2};
    do
    curl -u elastic:elk_123 -X GET http://127.0.0.1:9200/dher-*/_count -H 'Content-Type: application/json' -d '
    {
      "query": {
        "bool": {
          "must": [],
          "filter": [
            { "match_phrase": 
            {"agent.hostname.keyword": {"query": "'$i'" }
            }
            },
            {"range": {
                "@timestamp": {"from": "now-15m"}
            }
            }
          ]
        }
      }
    }' > /soft/signer-${i}.txt
    y=`awk -F '[:,]' '{print $2}' /soft/dher-${i}.txt`
    if [ $y -eq 0 ];then
    #/bin/bash /soft/alert.sh "dher-$i" "$y"
    /usr/bin/python /soft/python3 "`date +%H:%M` siger服务 $i" "$y"
    sleep 10
    echo $y
    fi
    done
    You have mail in /var/spool/mail/root
    

    配置定时任务

    */5 8-19 * * * /bin/bash  /soft/es_index_count.sh &>/var/es_count.log
    
  • 相关阅读:
    mysql 数据迁移方案
    tomcat:run 指定端口号
    idea open gradle project
    tomcat:run命令执行端口号
    域名代理
    stackoverflow慢问题
    chrome 添加 vue tools
    深度学习——结构化机器学习项目(学习策略2)[9]
    深度学习——超参数调试[7]
    深度学习——优化算法[6]
  • 原文地址:https://www.cnblogs.com/dinghc/p/13176749.html
Copyright © 2011-2022 走看看