From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 9A1DB1FF398 for ; Mon, 13 May 2024 12:49:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3323813A4C; Mon, 13 May 2024 12:50:02 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 13 May 2024 12:49:24 +0200 Message-Id: <20240513104926.3113394-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240513104926.3113394-1-d.csapak@proxmox.com> References: <20240513104926.3113394-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 2/4] tape: add drive activity to drive status api X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" and show it in the gui for single drives. Adds the known values for the activity to the UI. Signed-off-by: Dominik Csapak --- pbs-api-types/src/tape/drive.rs | 3 +++ pbs-tape/src/sg_tape.rs | 5 ++++- www/Utils.js | 29 +++++++++++++++++++++++++++++ www/tape/DriveStatus.js | 4 ++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pbs-api-types/src/tape/drive.rs b/pbs-api-types/src/tape/drive.rs index de569980a..caa6b3b3e 100644 --- a/pbs-api-types/src/tape/drive.rs +++ b/pbs-api-types/src/tape/drive.rs @@ -216,6 +216,9 @@ pub struct LtoDriveAndMediaStatus { /// Estimated tape wearout factor (assuming max. 16000 end-to-end passes) #[serde(skip_serializing_if = "Option::is_none")] pub medium_wearout: Option, + /// Current device activity + #[serde(skip_serializing_if = "Option::is_none")] + pub drive_activity: Option, } #[api()] diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs index 85be6b071..d185dd1ac 100644 --- a/pbs-tape/src/sg_tape.rs +++ b/pbs-tape/src/sg_tape.rs @@ -31,7 +31,8 @@ use proxmox_io::{ReadExt, WriteExt}; use proxmox_sys::error::SysResult; use pbs_api_types::{ - Lp17VolumeStatistics, LtoDriveAndMediaStatus, LtoTapeDrive, MamAttribute, TapeDensity, + DeviceActivity, Lp17VolumeStatistics, LtoDriveAndMediaStatus, LtoTapeDrive, MamAttribute, + TapeDensity, }; use crate::linux_list_drives::open_lto_tape_device; @@ -960,6 +961,7 @@ impl SgTape { pub fn get_drive_and_media_status(&mut self) -> Result { let drive_status = self.read_drive_status()?; + let drive_activity = read_device_activity(&mut self.file).ok(); let alert_flags = self .tape_alert_flags() .map(|flags| format!("{:?}", flags)) @@ -983,6 +985,7 @@ impl SgTape { medium_passes: None, medium_wearout: None, volume_mounts: None, + drive_activity, }; if self.test_unit_ready().is_ok() { diff --git a/www/Utils.js b/www/Utils.js index 1d7351a32..df03a4c87 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -659,6 +659,9 @@ Ext.define('PBS.Utils', { if (key === 'bytes-read' || key === 'bytes-written') { val = Proxmox.Utils.format_size(val); } + if (key === 'drive-activity') { + val = PBS.Utils.renderDriveActivity(val); + } list.push({ key: key, value: val }); } @@ -692,6 +695,32 @@ Ext.define('PBS.Utils', { }).show(); }, + tapeDriveActivities: { + 'no-activity': gettext('No Activity'), + 'cleaning': gettext('Cleaning'), + 'loading': gettext('Loading'), + 'unloading': gettext('Unloading'), + 'other': gettext('Other Activity'), + 'reading': gettext('Reading data'), + 'writing': gettext('Writing data'), + 'locating': gettext('Locating'), + 'rewinding': gettext('Rewinding'), + 'erasing': gettext('Erasing'), + 'formatting': gettext('Formatting'), + 'calibrating': gettext('Calibrating'), + 'other-dt': gettext('Other DT Activity'), + 'microcode-update': gettext('Updating Microcode'), + 'reading-encrypted': gettext('Reading encrypted data'), + 'writing-encrypted': gettext('Writing encrypted data'), + }, + + renderDriveActivity: function(value) { + if (!value) { + return Proxmox.Utils.unknownText; + } + return PBS.Utils.tapeDriveActivities[value] ?? value; + }, + renderDriveState: function(value, md) { if (!value) { return gettext('Idle'); diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js index 2c55fc97f..a392202ca 100644 --- a/www/tape/DriveStatus.js +++ b/www/tape/DriveStatus.js @@ -348,6 +348,10 @@ Ext.define('PBS.TapeManagement.DriveStatusGrid', { header: gettext('Compression'), renderer: Proxmox.Utils.format_boolean, }, + 'drive-activity': { + header: gettext('Drive Activity'), + renderer: PBS.Utils.renderDriveActivity, + }, 'file-number': { header: gettext('Tape Position'), renderer: function(value, mD, r, rI, cI, store) { -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel