Crate chrony_candm

Crate chrony_candm 

Source
Expand description

This crate is a library for communicating with Chrony’s control & monitoring interface. It provides programmatic access to information that you’d otherwise have to scrape from the output of chronyc.

For simple use cases which involve non-privileged queries to the locally-running Chrony daemon, your main entry-point into the library will be the blocking_query function with a server argument of &LOCAL_SERVER_ADDR. For privileged commands, use blocking_query_uds instead (this will require permissions to write to the /var/run/chrony directory).

use chrony_candm::request::RequestBody;
use chrony_candm::reply::ReplyBody;
use chrony_candm::{blocking_query,LOCAL_SERVER_ADDR};

let request_body = RequestBody::Tracking;
let options = Default::default();
let reply = blocking_query(request_body, options, &LOCAL_SERVER_ADDR)?;
if let ReplyBody::Tracking(tracking) = reply.body {
    println!("The current RMS offset is {} seconds.", tracking.rms_offset);
}

Asynchronous applications can use Client instead of the standalone blocking_query and blocking_query_uds functions.

Modules§

common
Data structures occurring both in requests and in replies
reply
Data structures representing replies
request
Data structures representing requests

Structs§

ClientDeprecated
Asynchronously sends requests and receives replies
ClientOptions
Options for configuring a Chrony client
ReplyFuture
A future which can be awaited to obtain the reply to a sent query
UnixDatagramClient

Constants§

DEFAULT_PORT

Functions§

blocking_query
Sends a request to a server via UDP and waits for a reply
blocking_query_uds
Sends a request to a server via a domain socket and waits for a reply
query_uds
Query chronyd using a Unix Domain Socket