zoukankan      html  css  js  c++  java
  • 脚本采集数据插入到influxdb数据库里

    #!/bin/bash
    # 定时收集java服务metrics
    # curl http://10.7.16.42:6301/metrics  demo
    # 参数:
     
    post_influxdb_write='http://10.19.186.40:8086/write?db=livedb'
    array=(
    "job|server1|job-server"
    "projectservice-server|server1|projectservice-server"
    "accountservice-server|server1|accountservice-server"
    "accountservice-listener|server1|accountservice-listener"
    "loanservice-listener|server1|loanservice-listener"
    "tradeservice-listener|server1|tradeservice-listener"
    "messageservice-server|server1|messageservice-server"
    "tradeservice-server|server1|tradeservice-server"
    "loanservice-server|server1|loanservice-server"
    "jxbankservice-server|server1|jxbankservice-server"
    )
     
    for data in ${array[@]}  
    do  
        process_name=`echo $data |awk -F"|" '{print $1}'` 
        java_host_name=`echo $data |awk -F"|" '{print $2}'`
        java_service_name=`echo $data |awk -F"|" '{print $3}'`
        currentTime=`date "+%Y-%m-%d %H:%M:%S"` 
        currentTimeStamp=`date -d "$currentTime" +%s`
        process=`ps aux | grep spring.profiles.active=live | grep -i APPID=$process_name | wc -l`
        insert_sql="java_service_monitor,rack=${java_host_name},service_name=${java_service_name} value=${process} ${currentTimeStamp}000000000"
    done  
     
    #echo "$insert_sql"
    echo "insert data"
    curl -i -X POST "$post_influxdb_write" --data-binary "$insert_sql"
     
    #echo "querying data"
    #curl -G http://localhost:8086/query  --data-urlencode "q=SELECT * FROM test1..zgh_test_write limit 2"
     
    exit
  • 相关阅读:
    jquery.autocomplete 使用解析
    《SEO实战密码》
    Thinkphp 生成的验证码不显示问题解决
    css去除li的小圆点
    css隐藏input边框阴影
    HBuilde 申请密钥证书
    请求筛选模块被配置为拒绝包含 hiddenSegment 节的 URL 中的路径
    js 判断屏幕下拉上滑操作
    gis 从WGS84转百度
    GIS个坐标系转换
  • 原文地址:https://www.cnblogs.com/kcxg/p/10969255.html
Copyright © 2011-2022 走看看