background

Pure NodeJS built monitoring system.

Rely on

client

  • shelljs
  • node-schedule
  • socket.io-client

server

  • nuxt
  • koa
  • element-ui
  • mongoose
  • echarts
  • socket.io

client

You can configure scheduled tasks to perform shell execution and send monitoring information (WebSocket) to the server.

Collected data

cpu

Collect CPU usage.

The top directive is used.

Specific instructions: top – b – 1 n | | grep Cpu awk ‘{print $2}’ | the cut – 1 f

memory

These include: total memory, used memory, free memory, buffer, cache

The free directive is used.

Specific instructions: free – wm | grep “Mem” | awk ‘{print $2, $3, $4, $6, $7}’ OFS = “,”

Log information

By listening for file changes, logs are sent to the server.

Mainly based on fs instructions.

network

Monitor the download bandwidth and upload bandwidth of the network.

The iftop directive is used.

Specific instructions: iftop – Pp – Nn – t – 100-1 – B s L | grep “Total send rate:” | awk ‘{print $4}’

Basic System Information

Monitor currentTime, runningTime, Users, etc.

The uptime directive is used.

Specific instruction: uptime

Listen for running programs

The listener is listening for CPU usage and memory usage.

Specific instructions: top – b – 1 n | grep ${programName} | awk ‘{print $6, $9}’ OFS = “,”

server

The main function

dashboard

Displays real-time client information (data uploaded by websocket in real time).

Node configuration

This section describes how to configure client information, including the IP address of the client to be monitored.

The historical record

Records the dashboard history

The log

Records the program log

DOC

Monitoring indicators

  • The amount of PV and UV access to a specific domain name
  • The hardware condition of the machine (CPU, memory, disk, etc.)
  • Number of requests and response time for each URL in a specific domain name

The core function

  • Collect information. There are procedures for collecting information
  • Store information and store the collected information in mongo database
  • Present the information, diagramming it using Echarts
  • You do not need to periodically clear the information stored in the long-term storage

Access to information

Nginx information retrieval uses the open source project OpenResty

Part of the screenshot

Making the address

Client: github.com/bosscheng/n…

Server: github.com/bosscheng/n…