background
A monitoring system built by pure nodejs.
rely
client
- shelljs
- node-schedule
- socket.io-client
server
- nuxt
- also
- element-ui
- mongoose
- echarts
- socket.io
client
By configuring timed tasks, execute shell execution, and then send monitoring information (websocket) to the server.
Collected data
cpu
Collect cpu usage.
Using top
instruction.
Specific instructions:top -b -n 1 | grep Cpu | awk '{print $2}'|cut -f 1
RAM
Including: total memory, used memory, free memory, buffer, cache
Using free
instruction.
Specific instructions:free -wm | grep "Mem" | awk '{print $2,$3,$4,$6,$7}' OFS=","
Log information
Mainly by monitoring file changes, sending logs to the server.
Mainly based fs
instruction.
The internet
Mainly monitor the download bandwidth and upload bandwidth of the network.
Using iftop
instruction.
Specific instructions:iftop -Pp -Nn -t -L 100 -s 1 -B|grep "Total send rate:"|awk '{print $4}'
Basic situation of the system
Mainly monitor currentTime, runningTime, users and other information.
Using uptime
instruction.
Specific instructions: uptime
Monitor the status of the running program
The main monitoring is the cpu occupancy rate and memory occupancy of the monitor program.
Specific instructions:top -b -n 1 |grep ${programName}|awk '{print $6,$9}' OFS=","
server
The main function
dashboard
Display client real-time information (data uploaded by websocket in real time).
Node configuration
Mainly configure the client information, the IP information of the client that needs to be monitored.
history record
Mainly record the history of the dashboard
Log
The log log of the main recording program
DOC
Monitoring indicators
- The amount of PV and UV for accessing a specific domain name
- The hardware of the machine (CPU, memory, disk, etc.)
- Information about the number of requests and response time for each URL under a specific domain name
Core functions
- Collect information, there are programs dedicated to collecting information to collect information
- Store information, store the collected information in the mongo database
- Display information, use echarts to graph the information
- Clear information, no need to clear long-term stored information regularly
Access to information
Nginx information acquisition uses the open source project OpenResty
Partial screenshot
github address
client: https://github.com/bosscheng/node-monitor-client
server: https://github.com/bosscheng/node-monitor-server