Code Monkey home page Code Monkey logo

n-sentinel-client's Introduction

n-sentinel-client

这是服务器监控工具 [n-sentinel] 的客户端;目前用Node.js实现。

Client:n-sentinel-client

Server:n-sentinel-server

ManagerPages:n-sentinel-view

Requirements

Node.js v8 LTS or later.

请先确保你的服务器上安装了Node.js的可执行程序。

whereis node
node: /usr/local/bin/node
# 如果你的路径不是这个,修改一下n_sentinel_alive.sh中的node路径

Quick start

下载源代码

在服务器 /opt 目录下下载源代码:

git clone https://github.com/qinchende/n-sentinel-client.git

或通过FTP工具把项目上传到服务器/opt目录下面

修改监听IP

// vi app.js
// 将host改成自己服务器的IP地址,将来server要通过host:port访问这个HTTP Server.
// 为了 安全考虑,最好监听内网网卡。
let Env = {
    host: '10.10.10.11',
    port: 49119,
    secret: 'n*sentinel*XYz'
};

注意上面的secret字段需要修改一个随机的字符序列,clientserver段一致即可。

配置任务计划自动监控重启

# cat n_sentinel_alive.sh 
# 在上面这个文件中有一句脚本,将其加入cronteb
# */1 * * * * sh /opt/n-sentinel-client/n_sentinel_alive.sh >> /opt/n-sentinel-client/alive.log 2>&1 &
# 使用命令:crontab -e ,加好之后保存退出即可。

这样服务器每一分钟都会检查node进程,如果没有了,就会自动重启。稍等片刻,在项目根目录你能看到两个日志文件:

# cat alive.log
[20201130_163401] CHECK ----------------
[RE] n-sentinel-client done
[20201130_163501] CHECK ----------------
[S] n-sentinel-client exist

# cat log.log
Hi, I am the master process.
Worker express listening on 10.10.10.11:49119 # 看到这个证明你client启动成功

到这里服务器上的收集程序就部署好了,他会一直等着server调用收集他的状态。

n-sentinel-client's People

Contributors

qinchende avatar

Stargazers

 avatar  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.