Monitoring Liquidsoap server metrics #3631
vitoyucepi
started this conversation in
Show and tell
Replies: 3 comments 3 replies
-
Awesome one, again. Thanks so much! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just a FYI i get this when running the stats script
|
Beta Was this translation helpful? Give feedback.
3 replies
-
` Additional libraries
Got mem_trace and mem_usage both installed via opam so .. yeah i'm not sure. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
Effectively monitoring server health and resource usage is crucial for maintaining optimal performance and reliability of any system. Liquidsoap is no exception.
As a powerful audio streaming server, Liquidsoap has many moving parts that need monitoring, including CPU usage, memory consumption, and garbage collection activity. Keeping tabs on these key metrics allows you to:
In this post, I will cover how to monitor core Liquidsoap server health metrics by:
Monitoring these indicators will provide invaluable visibility into the inner workings of your Liquidsoap server. Let's get started!
Keeping Tabs on Resource Usage
To start collecting data on Liquidsoap's resource usage, I can write a monitoring script that will:
Here is an example script:
This script:
Next I can visualize this data to monitor usage trends...
Visualizing Metrics with Matplotlib
Now that I have metrics being logged to a JSON file, I can load and visualize the data in Python with matplotlib.
1. Loading the JSON Data
To start, I'll open the JSON log file and parse the data into dictionaries for each metric category:
This:
dicts
for CPU, memory, and GC.dicts
.Now the metrics are loaded into memory and ready for preparation and visualization.
2. Preparing and Plotting the Data
With the metrics loaded, I can now process the data and visualize it.
First I define some helper functions:
Next I can plot the metrics:
This:
In addition to the overall memory usage plot, I can also visualize specific memory metrics.
I can also visualize Liquidsoap's GC activity over time.
3. Bringing It All Together
Finally, I can call the parsing, preparation, and plotting functions to generate the visualizations:
Now when executed, the script will read the Liquidsoap JSON metrics log, and output a set of insightful graphs for monitoring server resource usage and health over time.
The different visualizations provide granular visibility into how CPU, memory, and GC are behaving in Liquidsoap.
Full Script
Setting Up the Python Environment
Before running the metrics visualization script, I'll need to set up a Python virtual environment.
This keeps the script's dependencies isolated from the rest of the system.
Creating the Virtualenv
First create the virtualenv directory:
Next activate the environment:
. .env/bin/activate
The virtual environment is now ready to install packages into.
Installing Dependencies
With the venv active, install the required packages:
This will download matplotlib and scipy into the virtual environment.
Running the Script
Finally, with the venv activated you can run the metrics visualization script:
This ensures a clean, reproducible environment for the script.
Now the metrics graphs will render correctly!
Beta Was this translation helpful? Give feedback.
All reactions