GithubHelp home page GithubHelp logo

york618 / nodestatus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cokemine/nodestatus

0.0 0.0 0.0 2.02 MB

Yet another servers monitor written in TypeScript

Home Page: https://nodestatus-production.up.railway.app

License: MIT License

TypeScript 71.50% JavaScript 13.11% Dockerfile 1.87% Shell 0.05% HTML 0.75% CSS 0.36% Vue 12.35%

nodestatus's Introduction

Push

NodeStatus

Yet another servers monitor written in TypeScript.

Current Version: 1.2.2-beta.1

How To Install

If you want to update from v1.1.0 to v1.2.0 or later, you need to rebuild the database to handle the breaking change.

mv /usr/local/NodeStatus/db.sqlite /usr/local/NodeStatus/db.sqlite.bak

Install locally

# Install Node.js
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs

# RHEL, CentOS, CloudLinux, Amazon Linux or Fedora as root
curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -


#Install From NPM, NodeStatus needs prisma-cli to generate db
npm i pm2 prisma -g
npm i nodestatus-server@latest --unsafe-perm -g # will install status-server status-server-run in your computer
status-server # start nodestatus-server
status-server-run # start nodestatus-server with pm2
pm2 status # check running status
pm2 log nodestatus # check logs

# How to Update
npm i nodestatus-server@latest --unsafe-perm -g

Install with Docker (Recommended)

# Install Docker with docker-compose v2
curl -fsSL https://get.docker.com | bash -s docker
docker --version
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose # for x86_64
chmod +x ~/.docker/cli-plugins/docker-compose

# Download docker-compose.yml
mkdir ~/nodestatus
cd ~/nodestatus
wget https://raw.githubusercontent.com/cokemine/nodestatus/master/docker-compose.yml
vim docker-compose.yml #修改环境变量相关配置
docker compose up -d

# How to Update
cd ~/nodestatus
docker compose down
docker pull cokemine/nodestatus:latest
docker compose up -d

Client

Golang Version: https://github.com/cokemine/nodestatus-client-go

Node.js Version: https://github.com/cokemine/nodestatus-client

Environment

关于环境变量的相关配置,如果是使用 Docker 请直接在 docker-compose.yml配置文件中修改。

若为手动安装,则需要在本地用户目录下新建一个.nodestatus/.env.local文件(注意路径),在这个文件填写相关环境变量配置。

INTERVAL: 服务端推送间隔时间, 默认 1500 (1.5秒)

DATABASE: 数据库位置文件存放位置, 默认使用 SQLite (Linux): file:/usr/local/NodeStatus/server/db.sqlite,支持的数据库有 sqliteMySQLPostgreSQL,请使用对应的正确数据源链接格式填写:SQLite应以file:开头, MySQL应以mysql:开头, PostgreSQL应以postgresql:开头。

PORT: NodeStatus 所用端口, 默认 35601

VERBOSE: 是否启动 verbose 模式,启动后会输出更多信息,默认 false

THEME: NodeStatus 前端使用的主题,默认 hotaru-theme

 

USE_PUSH: 是否使用 Telegram 推送, 默认 true

USE_IPC: 是否需要 IPC 修改服务端配置, 默认 true

USE_WEB: 是否需要开启一个小型 web 面板修改服务端配置, 默认 true

 

WEB_USERNAME: WEB 面板用户名,默认 admin

WEB_PASSWORD: WEB 面板密码

WEB_SECRET: 用于 jsonwebtoken, 建议设为一个随机的字符串, 默认不填即和密码相同

 

PUSH_TIMEOUT: 客户端报警推送超时时间 (在这个时间内无论客户端发生了什么只要重新恢复与客户端的连接就不会推送), 默认30 (30秒)

PUSH_DELAY: 报警推送服务启动延迟 (防止重启服务端后导致的集中推送), 默认15 (15秒)

TGBOT_TOKEN: Telegram Bot Token (从 BotFather 申请到)

TGBOT_CHATID: Telegram Bot 需要推送的 chat_id, 如不清楚可以先启动 NodeStatus, 对 Bot 发送 /start 获取这个 id, 多个请用,隔开

TGBOT_PROXY: Telegram 代理服务器配置,例http://127.0.0.1:10808,仅支持 http 代理

TGBOT_WEBHOOK: Telegram Webhook 配置,不填写默认 Polling,例: https://tz.mydomain.com,使用 Webhook 务必需要开启 https,若你使用了https,则建议填写你的域名以开启 Webhook, 而非 Polling

部署到容器服务

如果你需要将 NodeStatus 部署到如 Railway 或 Okteto 等容器服务中。请注意数据持久化问题。你应该使用外部的MySQL或是 PostgreSQL而不是本项目默认的SQLite,因为如果使用SQLite在每次重置服务端都会导致原有的配置失效。使用时注意通过调整环境变量以使用可持续存储的数据库服务。

目前本项目还无法部署到如 Vercel 等 Serverless 服务中,因为目前 Serverless 不支持 WebSocket。

修改客户端配置

NodeStatus 有两种方式修改(添加 / 删除)服务器配置。

NodeStatus-cli

若你启用了 IPC, 则可以通过status-cli修改服务器相关配置。

npm i nodestatus-cli -g
status-cli help # check cli help

Web

若你启用了 Web, 则可以通过 Web 修改服务器相关配置。不需要手动安装,访问http://tz.domain.com/admin即可访问面板。

同时通过 Web 面板你可以很简单的从 ServerStatus 迁移至 NodeStatus, 你可以在面板Import处将 ServerStatus 的 JSON文件粘贴过去一键添加服务器。(需要去除多余的 host 字段)

面板开源地址:https://github.com/cokemine/nodestatus/tree/master/web/hotaru-admin

Telegram Commands

/start 查询当前chat_id,当前 NodeStatus 版本号

/status 查询当前所有服务器状态信息

Reverse Proxy

下面是对几种常见 Web 服务器配置反向代理的实例

Nginx

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /etc/nginx/conf.d/ssl/status.domain.com.crt; # SSL 证书路径
  ssl_certificate_key /etc/nginx/conf.d/ssl/status.domain.com.key; # SSL Key 证书路径
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name status.domain.com; # 需要绑定的域名
  access_log /data/wwwlogs/status.domain.com_nginx.log combined; # 日志位置, 目录如果不存在需要提前创建好

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_pass http://127.0.0.1:35601; # 反代地址
    proxy_http_version 1.1;
  }
}

How To Debug

npm i pnpm -g
mkdir -p /usr/local/nodestatus && cd /usr/local/nodestatus
git clone --recurse-submodules https://github.com/cokemine/nodestatus.git .
pnpm install
pnpm build
pnpm dev

CLI Options

Options:
  -db, --database <db>       the path of database (default: "/usr/local/nodestatus/db.sqlite")
  -p, --port <port>          the port of NodeStatus (default: "35601")
  -i, --interval <interval>  update interval (default: "1500")
  -h, --help                 display help for command

nodestatus's People

Contributors

cokemine avatar renovate[bot] avatar dependabot[bot] avatar york618 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.