Giter Site home page Giter Site logo

jwping / node_exporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prometheus/node_exporter

0.0 1.0 0.0 9.04 MB

Exporter for machine metrics

Home Page: https://prometheus.io/

License: Apache License 2.0

Go 95.76% Makefile 0.66% Shell 2.56% C 0.96% Dockerfile 0.06%

node_exporter's Introduction

Node exporter

1. 简述

该项目是在官方主分支202ecf9基础上进行定制,主要为我们从open-falcon迁移到Prometheus监控平台中端口以及URL监控策略适应而进行的二次开发。

2. 安装

2.1 预编译版本

对于发布版本预编译的二进制是可用的,下载方式如下,可参考releases

wget https://github.com/jwping/node_exporter/releases/download/v0.0.1/node_exporter

---or---

curl -o node_exporter https://github.com/jwping/node_exporter/releases/download/v0.0.1/node_exporter

./node_exporter <flags>

2.2 源码编译安装

2.2.1 前置条件:

  • GO环境
  • RHEL/CentOS: glibc-static 依赖.

2.2.2 编译

这里编译可以直接go build或者是使用官方的make

注意,如果使用官方的方式来进行编译的话,需要安装有golangci-lint

go get github.com/jwping/node_exporter
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/node_exporter

# go build
# make

./node_exporter <flags>

2.2.3 运行测试

make test

2.3 Docker部署

node_exporter设计用于监控主机系统。不建议将其部署为Docker容器,因为它需要访问主机系统。请注意,您要监视的所有非root挂载点都需要绑定挂载到容器中。如果启动用于宿主机监视的容器,请指定path.rootfs参数。此参数必须与主机/中挂载安装的路径匹配。node_exporter将 path.rootfs用作访问主机文件系统的前缀。

docker run -d \
  --net="host" \
  --pid="host" \
  -v "/:/host:ro,rslave" \
  quay.io/prometheus/node-exporter \
  --path.rootfs=/host

在某些系统上,timex收集器需要附加的Docker标志: --cap-add=SYS_TIME才能访问所需的syscall。

3. 新增功能

3.1 支持端口连通性采集

新增collector/port_checking.go

需要在Prometheus上配置params:

params:
  portlist:
    - 127.0.0.1:22
    - :9100

上列配置相当于告诉Prometheus在请求该Target时附带URL参数,如下:

http://192.168.14.130:9100/metrics?portlist=127.0.0.1:22&&portlist=:9100

node_export接收到附加portlist参数的请求后,会使用probeTCP函数对目标端口的连通性进行采集,具体源码实现请参考collector/port_checking.go#L29行。

3.2 支持GET请求状态码和请求耗时采集

新增http_checking.go

基本同上,需要在Prometheus上配置params:

params:
  httplist:
    - https://www.baidu.com
    - https://aliyun.com

上列配置相当于告诉Prometheus在请求该Target时附带URL参数,如下:

http://192.168.14.130:9100/metrics?httplist=https://www.baidu.com&&httplist=https://aliyun.com

node_export接收到附加httplist参数的请求后,会使用probeHTTP函数对目标端口的连通性进行采集,具体源码实现请参考collector/http_checking.go#L29行。

3.3 修改node_export.go以支持上述修改

node_export.go

// L75新增url参数解析,用于http、port参数获取

3.4 返回数据

...
# HELP port_connectivity_detection Running on each node
# TYPE port_connectivity_detection gauge
port_connectivity_detection{port="127.0.0.1:22"} 1
port_connectivity_detection{port=":9100"} 1
...
# HELP http_connectivity_detection Running on each node
# TYPE http_connectivity_detection gauge
http_connectivity_detection{http="https://aliyun.com",httpStatusCode="200"} 399
http_connectivity_detection{http="https://www.baidu.com",httpStatusCode="200"} 130
...

另请注意,URL请求的超时时间为3秒,返回数据的耗时单位为毫秒

node_exporter's People

Contributors

aleksi avatar bdrung avatar beorn7 avatar brian-brazil avatar derekmarcotte avatar discordianfish avatar dominikh avatar grobie avatar juergenhoetzel avatar juliusv avatar knweiss avatar mattbostock avatar matthiasr avatar mdlayher avatar metalmatze avatar mischief avatar nighttsarina avatar pborzenkov avatar pgier avatar problame avatar prombot avatar ra1fh avatar roidelapluie avatar rtreffer avatar sdurrheimer avatar siavashs avatar simonpasquier avatar stuartnelson3 avatar superq avatar tomwilkie avatar

Watchers

 avatar

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.