Skip to content

Commit

Permalink
feat(dgw): add recording_storage_is_writeable in heartbeat (#835)
Browse files Browse the repository at this point in the history
Issue: DGW-175
  • Loading branch information
CBenoit authored May 2, 2024
1 parent 0965f4e commit a209dc6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions devolutions-gateway/src/api/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub(crate) struct Heartbeat {
version: &'static str,
/// Number of running sessions
running_session_count: usize,
/// Whether the recording storage is writteable or not.
recording_storage_is_writteable: bool,
/// The total space of the disk used to store recordings, in bytes.
#[serde(skip_serializing_if = "Option::is_none")]
recording_storage_total_space: Option<u64>,
Expand Down Expand Up @@ -54,6 +56,18 @@ pub(super) async fn get_heartbeat(
.await
.map_err(HttpError::internal().err())?;

let recording_storage_is_writteable = {
let probe_file = conf.recording_path.join("probe");

let is_ok = std::fs::write(&probe_file, ".").is_ok();

if is_ok {
let _ = std::fs::remove_file(probe_file);
}

is_ok
};

let (recording_storage_total_space, recording_storage_available_space) = if sysinfo::IS_SUPPORTED_SYSTEM {
trace!("System is supporting listing storage disks");

Expand Down Expand Up @@ -98,6 +112,7 @@ pub(super) async fn get_heartbeat(
hostname: conf.hostname.clone(),
version: env!("CARGO_PKG_VERSION"),
running_session_count,
recording_storage_is_writteable,
recording_storage_total_space,
recording_storage_available_space,
}))
Expand Down

0 comments on commit a209dc6

Please sign in to comment.