Recommend: There is a platform that also integrates server monitor, and mainly used for performance test, Welcome to use it.
- Monitoring the CPU usage, CPU Load, IO wait, Memory, Disk IO, Network, and TCP connections of the server.
- Monitoring the CPU usage, Context switching, Memory, Disk read and write, and TCP connections of the specified port.
- For Java applications, monitoring size of JVM and Garbage collection; when the frequency of Full GC is too high, an email alert will be sent.
- When the Server CPU usage is too high, or free memory is too low, an email alert will be sent; And can clear the cache automatically.
- Start or Stop monitoring specified port at any time.
- When the port restarts, it can automatically re-monitor.
- Support Operational monitoring, when the port stopped, an email alert will be sent.
- Stopping the Agent directly on the Server.
- Monitoring data can be visualized according to the specified time period.
- Calculate the percentiles of the CPU, Disk IO, and Network.
- Monitoring data sampling frequency is up to about 1 time/sec, and any frequency can be set.
- The real-time usage of server(CPU, Memory, and Disk) can be viewed directly on the page.
- A Server can manager multiple Agents at the same time.
- If Server is stopped, it doesn't affect the monitoring of Agent.
- Framework:
aiohttp
. - Template rendering:
jinja2
. - Visualization:
echarts
. - Thread pool and queue to monitor.
- Database:
InfluxDB
. - In order to ensure the accuracy of the monitoring data, use Linux's commands to get data directly, and there is no curve fitting during visualization.
-
Clone performance_monitor
git clone https://github.com/leeyoshinari/performance_monitor.git
The server folder is the Server, and only one needs to be deployed; the agent folder is Agent, and deployed on the servers that need to be monitored.
-
Deploy
InfluxDB2
, the latest version is recommended. -
Respectively modify the configuration files
config.ini
in the server and agent folders. -
Install packages
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
-
Check the version of
sysstat
. Respectively use commandsiostat -V
andpidstat -V
, the version of12.4.0
has been tested, if not, please click me to download it. -
Respectively run
server.py
in server and agent folders.nohup python3 server.py &
-
Visit pages
(1) After Agent is started, visithttp://ip:port
, you can see the server's data(CPU, Meeory, Disk, Network, etc.).
(2) After server is started, visit
http://ip:port/'context'
, you can see some informations about Agents.
(3) Click MonitorList tab to see the monitoring page. Select server and enter the port, then click the startMonitor button to start monitoring the port on the selected server; click the stopMonitor button to stop monitoring the port on the selected server.
(4) Click Visualize tab to see the visualization page. Select server, type, disk, startTime and endTime, then click the Visualize button to visualize the monitoring data.
Using pyinstaller
to package python code. After packaging, it can be quickly deployed agent on other Agents without installing python3.7+ and third-party packages.
Before packaging, you must ensure that the python code can run normally.
-
Package server
(1) Enter the server folder, run:pyinstaller -F server.py -p draw_performance.py -p config.py -p Email.py -p logger.py -p process.py -p request.py -p __init__.py --hidden-import draw_performance --hidden-import config --hidden-import logger --hidden-import Email --hidden-import process --hidden-import request
(2) Enter
dist
folder, find the executable fileserver
,
(3) Copyconfig.ini
to thedist
folder,
(4) Copytemplates
andstatic
to thedist
folder,
(5) Start servernohup ./server &
-
Package agent
(1) Enter agent folder, run:pyinstaller -F server.py -p performance_monitor.py -p logger.py -p config.py -p common.py -p __init__.py --hidden-import logger --hidden-import performance_monitor --hidden-import common --hidden-import config
(2) Enter
dist
folder, find the executable fileserver
,
(3) Copyconfig.ini
to thedist
folder,
(4) Copy thedist
folder to other servers, and start servernohup ./server &
NOTE: Since the
agent
needs to run on the server to be monitored, the executable file packaged on the server of the CentOS system X86 architecture can only run on the server of the CentOS system X86 architecture; servers of other system and architecture need to be repackagedagent
.
-
The server must support the following commands:
ps
,jstat
,iostat
,pidstat
andnetstat
, if not, please install them. -
The network card of server must be in full duplex mode, if not, the network usage will be incorrect.
-
The version of sysstat must be 12+, the 12 version has been tested, other versions have not been tested, and using old version may cause data abnormalities; please click me to download the latest version.
-
The code can be run on almost any linux system that can run python. The tested systems have
CentOS
,Ubuntu
,KylinOS
,NeoKylin
, supportX86_64
andARM
architecture.