digitemp-rrdgraph
digitemp-rrdgraph is a command-line application for temperature monitoring with 1-Wire sensors. It collects measurements through digitemp, stores them in RRD files, generates graph images, and sends email notifications based on configured schedules and thresholds.
The repository is organized as a Cargo workspace with two crates:
digitemp-rrdgraph: the CLI binary cratedigitemp_rrdgraph_core: the internal library crate used by the CLI commands
Features
- Read temperature data from 1-Wire sensors through
digitemp - Store time-series data in RRD files
- Generate graph images for hourly, daily, weekly, monthly, and yearly views
- Send periodic information emails and threshold-based alert emails
- Configure runtime behavior through JSON and template files
Requirements
- Rust toolchain compatible with edition 2024
- digitemp
- RRDTool
- Access to an SMTP server for email delivery
Project Layout
Cargo.toml: workspace root and CLI package definitionsrc/: CLI entrypoint and command modulescrates/core/: internal library crate shared by the CLI commandscrates/core/src/: shared modules for config loading, DigiTemp access, RRD operations, mail sending, and template renderingetc/: configuration files and cron examplestemplates/: Tera mail templatesdb/: RRD database fileshtml/images/: generated graph images
Setup
- Build the release binary.
cargo build --release
- Choose where to place the application configuration file.
You can always override the default search order with --config /path/to/digitemp-rrdgraph.json.
Recommended locations are checked in this order:
$HOME/.config/digitemp-rrdgraph.json/etc/digitemp-rrdgraph.json<parent directory of the executable>/etc/digitemp-rrdgraph.json$PWD/etc/digitemp-rrdgraph.json
For an installed layout such as /opt/digitemp-rrdgraph/bin/digitemp-rrdgraph, place the file at /opt/digitemp-rrdgraph/etc/digitemp-rrdgraph.json.
For local development from the repository root, create etc/digitemp-rrdgraph.json.
cp etc/digitemp-rrdgraph.sample.json etc/digitemp-rrdgraph.json
- Create a DigiTemp configuration file.
digitemp_DS9097U -i -s /dev/ttyUSB0 -c ./etc/digitemp.conf
- Edit the selected
digitemp-rrdgraph.jsonfile for your environment.
Pass --verbose if you want the CLI to print the selected configuration file path to standard error.
Configure at least these values:
digitempanddigitemp_configdatabase_dir,html_dir, andimages_dirtemplates_dirandhtml_templateroom_name- SMTP server settings
- mail recipients, subjects, and alert thresholds
room_name is required. It is used in mail templates, graph titles, and the generated top page.
The update command renders html_template and writes it under html_dir using the same relative path with the .tera suffix removed. For example, index.html.tera becomes html/index.html.
SMTP settings support these combinations:
mail_smtp_security:smtp,starttls, orsmtpsmail_smtp_auth:trueto send SMTP AUTH credentials,falsefor unauthenticated serversmail_smtp_usernameandmail_smtp_password: required only whenmail_smtp_authistrue
Build
cargo build --release
This builds both workspace members, including the internal digitemp_rrdgraph_core crate.
The release binary is written to target/release/digitemp-rrdgraph.
To build only the CLI package explicitly:
cargo build --release -p digitemp-rrdgraph
To run tests across the workspace:
cargo test --workspace
Commands
The application provides these subcommands:
update: read sensors, update RRD files, and regenerate graph imagescheck-alert: evaluate current data against configured alert thresholds and send an alert email when requiredsend-info: send a periodic information email
Examples:
./target/release/digitemp-rrdgraph update
./target/release/digitemp-rrdgraph --verbose update
./target/release/digitemp-rrdgraph --config /opt/digitemp-rrdgraph/etc/digitemp-rrdgraph.json update
./target/release/digitemp-rrdgraph check-alert
./target/release/digitemp-rrdgraph send-info
Scheduling
Use cron or another scheduler to run the subcommands at appropriate intervals.
- Run
updateon the data collection interval you want to keep in RRD. - Run
send-infoon the reporting interval you want for periodic summaries. - Run
check-alerton the alert polling interval you want for threshold checks.
See etc/crontab.sample for a sample schedule.
Templates
Templates are stored in templates/ and rendered with Tera.
The top page uses html_template, while the mail bodies use mail_info_template and mail_alert_template.
Development Notes
- CLI subcommands live under
src/commands/. - Shared application logic lives under
crates/core/src/and is exposed by thedigitemp_rrdgraph_corecrate. - The root crate depends on the internal core crate through a local path dependency.
License
MIT