Personnal project : chrony + network monitoring dashboard lightweight

Hello,

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.

Demo here : Demo Chrony-Stats HTML

The script generates a html file with two main types of graphs:

  1. Chrony Statistics (chrony)

  2. Network Statistics (vnstat + vnstati)

  3. Command Output (tracking sources selectdata sourcestats)

To use it
The project is open-source, feel free to use it ! (Contributions are welcome)
Repo here : GitHub - TheHuman00/chrony-stats: Lightweight : Monitoring Chrony and Network

10 Likes

Very nice, thank you for sharing! I’m gonna try it on my server

1 Like

Hi,

I’m using it for some time on my server and it works well. A small request; if possible, add weekly graphs (and maybe even monthly)

1 Like

Hey @microchip8

Thanks a lot for your message and your suggestion, really appreciated!

I’ve added weekly and monthly graphs like you asked :slightly_smiling_face:
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!

1 Like

Nice, it’s working well. I’m happy for now, no other suggestions.

2 Likes

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.

Here’s a link to my dashboard: NTP Server Statistics & Network Traffic | XLR Security

I’m running an NTP server based out of Toronto on a Digital Ocean droplet and it’s running smoothly so far. Cheers!

3 Likes

This is awesome, thank you very much

2 Likes

Great !

I would suggest that you place a link to your Github Repo :slight_smile: (on the statspage)

Is that what you are looking for? :wink:

Nope…

On the status page itself.

Ah, ok, sorry, that wasn’t clear to me earlier, but now I get the part about “on the statspage”… :flushed_face:

No worries. I’ve added it to my previous post to make it more clearer

1 Like

Hi ! @apuls
As you requested, I just added this feature! You can now optionally show a GitHub link in the footer.

 GITHUB_REPO_LINK_SHOW="no" # Change from "no" to "yes"

When enabled, it adds “Made with :heart: by TheHuman00 | View on GitHub” to the bottom of the page.

It’s completely optional by default - feel free to use it however you want, no credit needed! :+1:

2 Likes

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.

1 Like

@Mpegger Yes absolutely!

I just implemented this feature based on your request.

ENABLE_NETWORK_STATS="no"

Just set it to no in the config, and it’ll skip all the vnStat network monitoring.

And if you want to reduce SD card writes even more, you can also set:
ENABLE_LOGGING="no" too.

Thanks for the suggestion and I’m here if you ever need anything !

3 Likes

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?

Hello @Mpegger,

Logging disabled

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.

1 Like

Love this! Would it be possible to add a config to allow the html page to auto refresh at a selectable time?