Skip to content

TheHuman00/chrony-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chrony & Network Stats

A lightweight Bash script that monitors Chrony and network traffic, generates visual graphs, and produces an HTML report ideal for low-resource servers.

Live demo here!


Features

Feature Description
Lightweight Minimal system resources required
Chrony monitoring Tracks offset, stratum, RMS, frequency, and more
Network monitoring Traffic stats via vnStat
Multi-period views Day, week, and month graphs for Chrony stats
HTML report Visual graphs + raw chronyc output in one page

Prerequisites

Choose one option :

1. Full monitoring (Chrony + Network):

sudo apt update && sudo apt install vnstat vnstati rrdtool

Configure vnStat to monitor your network interface:

vnstat --iflist          # find your interface name
sudo vnstat -i eth0      # replace eth0 with your interface

If not eth0 : ⚠️ Change your network interface in the Configuration section.

2. Chrony only

sudo apt update && sudo apt install rrdtool

Set ENABLE_NETWORK_STATS="no" in config


Installation

curl -O https://raw.githubusercontent.com/TheHuman00/chrony-stats/master/chrony-network-stats.sh
sudo chmod +x ./chrony-network-stats.sh

Then schedule it to run every 5 minutes open the root crontab:

sudo crontab -e

Add this line:

*/5 * * * * /path/to/chrony-network-stats.sh

Configuration

Open the script to edit its settings : nano chrony-network-stats.sh

The configuration block is at the top of the file:

####################### Configuration ######################

ENABLE_NETWORK_STATS="yes"

# Replace with your actual interface (e.g., ens33, enp0s3, wlan0)
INTERFACE="eth0" ## CHANGE HERE ⚠️

PAGE_TITLE="Network Traffic and Chrony Statistics for ${INTERFACE}"
OUTPUT_DIR="/var/www/html/chrony-network-stats"
HTML_FILENAME="index.html"

RRD_DIR="/var/lib/chrony-rrd"
RRD_FILE="$RRD_DIR/chrony.rrd"

ENABLE_LOGGING="no"
LOG_FILE="/var/log/chrony-network-stats.log"

# Auto-refresh in seconds (0 = disabled)
AUTO_REFRESH_SECONDS=0

# Show a link to this GitHub repo in the HTML page (optional, disabled by default)
GITHUB_REPO_LINK_SHOW="no"

###### Advanced Configuration ######

# DNS reverse lookups for chronyc: "no" is faster and reduces network traffic
CHRONY_ALLOW_DNS_LOOKUP="no"

# Screen preset: default | 2k | 4k
# Adjusts container width, font size, and graph resolution
DISPLAY_PRESET="default"

TIMEOUT_SECONDS=5

# Filters abnormally high values caused by Chrony restarts (e.g. spikes of 12M packets)
# Values above this threshold are replaced with gaps in the graph
SERVER_STATS_UPPER_LIMIT=100000

##############################################################
WIDTH=800
HEIGHT=300
##############################################################

Display presets

Set DISPLAY_PRESET to 2k or 4k if the page looks too small on high-resolution screens. Each preset increases the container width, base font size, and graph resolution accordingly.


Usage

Run the script:

sudo ./chrony-network-stats.sh

View the report:

The HTML file is generated at /var/www/html/chrony-network-stats/index.html. Serve it with a web server such as Apache or Nginx. → Nginx local setup guide

Check logs (requires ENABLE_LOGGING="yes" in config):

tail -f /var/log/chrony-network-stats.log

License

Free to use however you want without restriction. See LICENSE for details.

Built with

  • vnStat — network traffic monitor
  • RRDtool — data storage and graph generation
  • Chrony — NTP implementation

About

Lightweight : Monitoring Chrony and Network

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages