Skip to content

Commit

Permalink
total space
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 committed Oct 18, 2023
1 parent aabe063 commit 243a3f8
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends AbstractDiskSpaceMonitor> trigger;
private long threshold;
Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring Configuration}" type="one-column">
<j:set var="readOnlyMode" value="${!app.hasPermission(app.MANAGE)}" />
<l:breadcrumb title="${%Node Monitoring}" />
<l:breadcrumb title="${%Configure Node Monitors}" />
<l:main-panel>
<l:app-bar title="${%Node Monitoring}" />
<l:app-bar title="${%Configure Node Monitors}" />

<!-- to make the form field binding work -->
<j:set var="instance" value="${it}" />
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/ComputerSet/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ THE SOFTWARE.
</j:if>
<j:set var="hasPermission" value="${h.hasAnyPermission(it, app.MANAGE_AND_SYSTEM_READ)}" />
<j:if test="${hasPermission}">
<a class="jenkins-button" href="configure">
${%Node Monitoring}
<a class="jenkins-button" href="configure" tooltip="${%Configure Node Monitors}">
${%Configure Monitors}
</a>
</j:if>
<l:hasAdministerOrManage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
<td align="right" data="-1">N/A</td>
</j:when>
<j:otherwise>
<td align="right" data="${data.freeSize}">
<td align="right" data="${data.freeSize}" data-total="${data.totalSize}">
<j:choose>
<j:when test="${data.triggered}">
<span class="error" tooltip="${data.toString()}">${data.toHtml()}</span>
Expand All @@ -38,7 +38,7 @@ THE SOFTWARE.
<span class="warning" tooltip="${data.toString()}">${data.toHtml()}</span>
</j:when>
<j:otherwise>
${data.toHtml()}
<span tooltip="${data.toString()}">${data.toHtml()}</span>
</j:otherwise>
</j:choose>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
<td align="right" data="-1">N/A</td>
</j:when>
<j:otherwise>
<td align="right" data="${data.freeSize}">
<td align="right" data="${data.freeSize}" data-total="${data.totalSize}">
<j:choose>
<j:when test="${data.triggered}">
<span class="error" tooltip="${data.toString()}">${data.toHtml()}</span>
Expand All @@ -38,7 +38,7 @@ THE SOFTWARE.
<span class="warning" tooltip="${data.toString()}">${data.toHtml()}</span>
</j:when>
<j:otherwise>
${data.toHtml()}
<span tooltip="${data.toString()}">${data.toHtml()}</span>
</j:otherwise>
</j:choose>
</td>
Expand Down

0 comments on commit 243a3f8

Please sign in to comment.