From 243a3f82f609308ddd62ba8bdf123e583332f32f Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Wed, 18 Oct 2023 14:58:13 +0200 Subject: [PATCH] total space --- .../DiskSpaceMonitorDescriptor.java | 33 +++++++++++++++---- .../node_monitors/TemporarySpaceMonitor.java | 4 ++- .../hudson/model/ComputerSet/configure.jelly | 4 +-- .../hudson/model/ComputerSet/index.jelly | 4 +-- .../DiskSpaceMonitor/column.jelly | 4 +-- .../hudson/node_monitors/Messages.properties | 4 +-- .../node_monitors/Messages_de.properties | 3 +- .../TemporarySpaceMonitor/column.jelly | 4 +-- 8 files changed, 41 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java b/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java index e3affbd5a573..1e0084edcd08 100644 --- a/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java +++ b/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java @@ -103,6 +103,8 @@ public static final class DiskSpace extends MonitorOfflineCause implements Seria @Exported public final long size; + private long totalSize; + private boolean triggered; private Class trigger; private long threshold; @@ -117,22 +119,37 @@ public DiskSpace(String path, long size) { this.size = size; } + @Restricted(NoExternalUse.class) + public void setTotalSize(long totalSize) { + this.totalSize = totalSize; + } + + @Restricted(NoExternalUse.class) + @Exported + public long getTotalSize() { + return totalSize; + } + @Override public String toString() { if (triggered) { if (threshold >= 0) { return Messages.DiskSpaceMonitorDescriptor_DiskSpace_FreeSpaceTooLow( - getGbLeft(), path, Functions.humanReadableByteSize(threshold)); + getGbLeft(), path, Functions.humanReadableByteSize(threshold), + Functions.humanReadableByteSize(totalSize)); } else { return Messages.DiskSpaceMonitorDescriptor_DiskSpace_FreeSpaceTooLow( - getGbLeft(), path, "unset"); + getGbLeft(), path, "unset", + Functions.humanReadableByteSize(totalSize)); } } if (isWarning()) { return Messages.DiskSpaceMonitorDescriptor_DiskSpace_FreeSpaceTooLow( - getGbLeft(), path, Functions.humanReadableByteSize(warningThreshold)); + getGbLeft(), path, Functions.humanReadableByteSize(warningThreshold), + Functions.humanReadableByteSize(totalSize)); } - return Messages.DiskSpaceMonitorDescriptor_DiskSpace_FreeSpace(getGbLeft(), path); + return Messages.DiskSpaceMonitorDescriptor_DiskSpace_FreeSpace(getGbLeft(), path, + Functions.humanReadableByteSize(totalSize)); } /** @@ -246,9 +263,11 @@ public GetUsableSpace() {} @Override public DiskSpace invoke(File f, VirtualChannel channel) throws IOException { - long s = f.getUsableSpace(); - if (s <= 0) return null; - return new DiskSpace(f.getCanonicalPath(), s); + long s = f.getUsableSpace(); + if (s <= 0) return null; + DiskSpace ds = new DiskSpace(f.getCanonicalPath(), s); + ds.setTotalSize(f.getTotalSpace()); + return ds; } private static final long serialVersionUID = 1L; diff --git a/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java b/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java index f0afc3690414..b07df4e19ecf 100644 --- a/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java +++ b/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java @@ -149,7 +149,9 @@ public DiskSpace invoke(File f, VirtualChannel channel) throws IOException { f = new File(System.getProperty("java.io.tmpdir")); long s = f.getUsableSpace(); if (s <= 0) return null; - return new DiskSpace(f.getCanonicalPath(), s); + DiskSpace ds = new DiskSpace(f.getCanonicalPath(), s); + ds.setTotalSize(f.getTotalSpace()); + return ds; } private static final long serialVersionUID = 1L; diff --git a/core/src/main/resources/hudson/model/ComputerSet/configure.jelly b/core/src/main/resources/hudson/model/ComputerSet/configure.jelly index e97bbc31489d..4bbd52b4c4dc 100644 --- a/core/src/main/resources/hudson/model/ComputerSet/configure.jelly +++ b/core/src/main/resources/hudson/model/ComputerSet/configure.jelly @@ -29,9 +29,9 @@ THE SOFTWARE. - + - + diff --git a/core/src/main/resources/hudson/model/ComputerSet/index.jelly b/core/src/main/resources/hudson/model/ComputerSet/index.jelly index ff8a8e288075..ec4d2ab97883 100644 --- a/core/src/main/resources/hudson/model/ComputerSet/index.jelly +++ b/core/src/main/resources/hudson/model/ComputerSet/index.jelly @@ -41,8 +41,8 @@ THE SOFTWARE. - - ${%Node Monitoring} + + ${%Configure Monitors} diff --git a/core/src/main/resources/hudson/node_monitors/DiskSpaceMonitor/column.jelly b/core/src/main/resources/hudson/node_monitors/DiskSpaceMonitor/column.jelly index 7be30db658d3..3d3ca8b23c2b 100644 --- a/core/src/main/resources/hudson/node_monitors/DiskSpaceMonitor/column.jelly +++ b/core/src/main/resources/hudson/node_monitors/DiskSpaceMonitor/column.jelly @@ -29,7 +29,7 @@ THE SOFTWARE. N/A - + ${data.toHtml()} @@ -38,7 +38,7 @@ THE SOFTWARE. ${data.toHtml()} - ${data.toHtml()} + ${data.toHtml()} diff --git a/core/src/main/resources/hudson/node_monitors/Messages.properties b/core/src/main/resources/hudson/node_monitors/Messages.properties index 2a9a32492881..7e741347f073 100644 --- a/core/src/main/resources/hudson/node_monitors/Messages.properties +++ b/core/src/main/resources/hudson/node_monitors/Messages.properties @@ -31,7 +31,7 @@ ResponseTimeMonitor.TimeOut=Timed out for last {0} attempts SwapSpaceMonitor.DisplayName=Free Swap Space TemporarySpaceMonitor.DisplayName=Free Temp Space AbstractNodeMonitorDescriptor.NoDataYet=Not yet -DiskSpaceMonitorDescriptor.DiskSpace.FreeSpaceTooLow=Disk space is below threshold of {2}. Only {0} left on {1}. -DiskSpaceMonitorDescriptor.DiskSpace.FreeSpace={0} left on {1}. +DiskSpaceMonitorDescriptor.DiskSpace.FreeSpaceTooLow=Disk space is below threshold of {2}. Only {0} out of {3} left on {1}. +DiskSpaceMonitorDescriptor.DiskSpace.FreeSpace={0} out of {2} used on {1}. MonitorMarkedNodeOffline.DisplayName=Node Marked Offline Due to Health Check DiskSpaceMonitorNodeProperty.DisplayName=Disk Space Monitoring Thresholds diff --git a/core/src/main/resources/hudson/node_monitors/Messages_de.properties b/core/src/main/resources/hudson/node_monitors/Messages_de.properties index da9939bd95ad..79253a8afa04 100644 --- a/core/src/main/resources/hudson/node_monitors/Messages_de.properties +++ b/core/src/main/resources/hudson/node_monitors/Messages_de.properties @@ -28,7 +28,8 @@ ResponseTimeMonitor.DisplayName=Antwortzeit ResponseTimeMonitor.TimeOut= {0} mal keine Antwort SwapSpaceMonitor.DisplayName=Freier Swap Space TemporarySpaceMonitor.DisplayName=Freier TEMP-Platz -DiskSpaceMonitorDescriptor.DiskSpace.FreeSpaceTooLow=Festplattenplatz unterhalb der Schwelle von {2}. Nur noch {0} frei in {1}. +DiskSpaceMonitorDescriptor.DiskSpace.FreeSpaceTooLow=Festplattenplatz unterhalb der Schwelle von {2}. Nur noch {0} von {3} frei in {1}. +DiskSpaceMonitorDescriptor.DiskSpace.FreeSpace={0} von {2} benutzt in {1}. DiskSpaceMonitor.MarkedOnline=Nehme {0} wieder online, da wieder genug Festplattenplatz verfügbar ist. MonitorMarkedNodeOffline.DisplayName=Knoten durch Health-Check-Prüfung offline ResponseTimeMonitor.MarkedOffline=Nehme {0} offline, da er nicht antwortet. diff --git a/core/src/main/resources/hudson/node_monitors/TemporarySpaceMonitor/column.jelly b/core/src/main/resources/hudson/node_monitors/TemporarySpaceMonitor/column.jelly index e40f0aa91a39..8655fc2aadc6 100644 --- a/core/src/main/resources/hudson/node_monitors/TemporarySpaceMonitor/column.jelly +++ b/core/src/main/resources/hudson/node_monitors/TemporarySpaceMonitor/column.jelly @@ -29,7 +29,7 @@ THE SOFTWARE. N/A - + ${data.toHtml()} @@ -38,7 +38,7 @@ THE SOFTWARE. ${data.toHtml()} - ${data.toHtml()} + ${data.toHtml()}