I’d like to share a small open-source personal project, a script I developed to solve a simple problem: I needed to monitor my Chrony server running on a small machine without consuming a lot of resources.
So i developed a script that uses chronyc and basic network commands with rrdtools to generate useful graphs. It’s designed to be as light on resources as possible, generating a single HTML file that serves as a dashboard.
Thanks a lot for your message and your suggestion, really appreciated!
I’ve added weekly and monthly graphs like you asked
The image files are now named: chrony_delay_[day | week | month].png
I also fixed the bug where restarting Chrony would sometimes create absurd values (like 24M), which messed up the graph scale and made everything unreadable.
All the changes are on my repo (link in the first post)
And the demo is up to date too.
If you ever need anything or have more ideas, feel free to drop me a message here or in DM, I’m happy to help and glad you’re finding it useful!
Thanks for sharing your personal project! I found your instructions easy to follow and was able to get it working within five minutes.
The graphs are super nice to look at and I love how you added dashed lines and a description above the chronyc stats that remind you what the numbers mean.
Would it be possible to add a option to disable the networking portion of the tracking and graph? My NTP server is for the local LAN only, so I have no need for the network statistics and would like to lessen the amount of data gathered and written on my RasPi microsd.
What exactly is the script doing when the logging is disabled? I’m guessing it keeps all data it’s tracking in RAM, but what about the images it needs to display? Are those also kept in RAM? Is anything written to storage?
So when logging is disabled, Log messages are not saved to $LOG_FILE.
The log_message() function still prints to the console, but nothing is written to disk.
The data of tracking
The script always creates and updates the RRD file at $RRD_DIR/chrony.rrd - this is the time-series database that stores all the chrony metrics.
(Maybe I could add an option to purge data older than one month to save disk space?)
Image generation
All graph images are written to $OUTPUT_DIR/img/ directory. And at the update the img is remplaced with the new one.
(All graphs are generated and saved to $OUTPUT_DIR/img/.
Each run overwrites the previous images with updated versions)
Do you have any known limitations where performance could be improved?
Do you see anything that could be improved or optimized for how you’re using it?
I’m just trying to limit writes to the microsd card to extend life span. RaspberryPis aren’t exactly friendly to microsd cards, and I already have log2ram installed to minimize writes. Anything that will constantly write to “disk” is just hastening the microsd death, and on something like a local dedicated NTP server that should just be set it and forget it, I’d rather avoid having to redo and replace the microsd.
I could also go the SSD route, or maybe a remote share symlinked, and not worry about it, but if I can just stick with the microsd I’d prefer that.
@Mpegger To protect your microSD, you can move certain data to RAM.
For example, you can set these parameters to a RAM based directory (for example, /tmp or directory mounted as tmpfs), you can avoid writing to the microSD card:
OUTPUT_DIR="/dev/shm/chrony-network-stats"
RRD_DIR="/dev/shm/chrony-rrd"
ENABLE_LOGGING="no"
# You can use /tmp if it's mounted as tmpfs
This will store HTML files, graphs, and the RRD database in RAM. However, if you store your RRD files in RAM, you will lose all historical data upon reboot.
Also, if you’re using Nginx to serve the stats make sure the permissions are set so it can read the html and img.
Let me know if you need anything, I’ll be glad to help.