Giter VIP home page Giter VIP logo

monitor's Introduction

Monitor from es

Elastic stack 中的 Metricbeat 会将系统数据放到 ES 中,但是 Kibana不能设置密码,而且无法实现报警功能.这个项目就是通过pythonrequestsES中将需要的数据读出来,通过接口返回.

image-20200109100520853

run

export ES_URL=http://10.x.x.x:9200
pip install -r requirements.txt
python index.py

默认监听5000端口

docker

dockerfile

覆盖 ES_URL,修改为自己的 ES 地址

FROM python:3.6-alpine

EXPOSE 5000
WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
ENV ES_URL http://127.0.0.1:9200

CMD [ "python", "./index.py" ]

API

根据硬盘剩余百分比查询

curl -H "Content-type: application/json" -X POST -d '{"warn":0.7}' x.x.x.88:5000/hdbypct                                                 
{"data":[{"doc_count":2,"key":"Log-Server-x.x.x.88","mountpoint":{"buckets":[{"doc_count":2,"key":"/","mount_pec":{"buckets":[{"doc_count":2,"key":0.902}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"BigData001-x.x.x.124","mountpoint":{"buckets":[{"doc_count":1,"key":"/var/www/html/yum","mount_pec":{"buckets":[{"doc_count":1,"key":1.0}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"DB-Link-x.x.x.82","mountpoint":{"buckets":[{"doc_count":1,"key":"/","mount_pec":{"buckets":[{"doc_count":1,"key":0.895}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"Java-sunyard-x.x.x.99","mountpoint":{"buckets":[{"doc_count":1,"key":"/boot","mount_pec":{"buckets":[{"doc_count":1,"key":0.764}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"MQ-sunyard-x.x.x.16","mountpoint":{"buckets":[{"doc_count":1,"key":"/boot","mount_pec":{"buckets":[{"doc_count":1,"key":0.764}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"MariaDB-x.x.x.105","mountpoint":{"buckets":[{"doc_count":1,"key":"/","mount_pec":{"buckets":[{"doc_count":1,"key":0.704}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"Minio-x.x.x.121","mountpoint":{"buckets":[{"doc_count":1,"key":"/boot","mount_pec":{"buckets":[{"doc_count":1,"key":0.764}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"Outside-x.x.x.180","mountpoint":{"buckets":[{"doc_count":1,"key":"/","mount_pec":{"buckets":[{"doc_count":1,"key":0.839}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}},{"doc_count":1,"key":"UAT-x.x.x.162","mountpoint":{"buckets":[{"doc_count":1,"key":"/boot","mount_pec":{"buckets":[{"doc_count":1,"key":0.741}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"status_code":200}

根据硬盘剩余容量(bytes)查询

curl -H "Content-type: application/json" -X POST -d '{"bytes":5368709120}' x.x.x.88:5000/hdbybyte                                                
{"data":[{"doc_count":2,"key":"Log-Server-x.x.x.88","mountpoint":{"buckets":[{"doc_count":2,"key":"/","mount_free":{"buckets":[{"doc_count":1,"key":5143040000},{"doc_count":1,"key":5162508288}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"doc_count_error_upper_bound":0,"sum_other_doc_count":0}}],"status_code":200}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.