mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-11 19:16:42 +00:00
- Added a slave monitor that records the architecture and OS of saves.
- Tweaked the NodeMonitor abstraction a little bit. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6922 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
ab3a7d813e
commit
0de29bd9f8
9 files changed
+87
-17
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package hudson.node_monitors;
|
||||
|
||||
import hudson.model.Computer;
|
||||
import hudson.remoting.Callable;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Discovers the architecture of the system to display in the slave list page.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ArchitectureMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
public static final AbstractNodeMonitorDescriptor<String> DESCRIPTOR = new AbstractNodeMonitorDescriptor<String>(ArchitectureMonitor.class) {
|
||||
protected String monitor(Computer c) throws IOException, InterruptedException {
|
||||
return c.getChannel().call(new GetArchTask());
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return Messages.ArchitectureMonitor_displayName();
|
||||
}
|
||||
|
||||
public NodeMonitor newInstance(StaplerRequest req, JSONObject formData) throws FormException {
|
||||
return new ArchitectureMonitor();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Obtains the string that represents the architecture.
|
||||
*/
|
||||
private static class GetArchTask implements Callable<String,RuntimeException> {
|
||||
public String call() {
|
||||
String os = System.getProperty("os.name");
|
||||
String arch = System.getProperty("os.arch");
|
||||
return os+" ("+arch+')';
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.io.IOException;
|
||||
* @since 1.123
|
||||
*/
|
||||
public class ClockMonitor extends NodeMonitor {
|
||||
public Descriptor<NodeMonitor> getDescriptor() {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,15 @@ public class ClockMonitor extends NodeMonitor {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return "Clock Difference";
|
||||
return Messages.ClockMonitor_displayName();
|
||||
}
|
||||
|
||||
public NodeMonitor newInstance(StaplerRequest req) throws FormException {
|
||||
return new ClockMonitor();
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.math.BigDecimal;
|
||||
* @since 1.123
|
||||
*/
|
||||
public class DiskSpaceMonitor extends NodeMonitor {
|
||||
public Descriptor<NodeMonitor> getDescriptor() {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class DiskSpaceMonitor extends NodeMonitor {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return "Free Disk Space";
|
||||
return Messages.DiskSpaceMonitor_displayName();
|
||||
}
|
||||
|
||||
public NodeMonitor newInstance(StaplerRequest req) throws FormException {
|
||||
@@ -65,4 +65,8 @@ public class DiskSpaceMonitor extends NodeMonitor {
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,14 @@ package hudson.node_monitors;
|
||||
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Functions;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.ComputerSet;
|
||||
import hudson.model.Describable;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Node;
|
||||
import hudson.util.DescriptorList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Extension point for managing and monitoring {@link Node}s.
|
||||
@@ -38,16 +37,24 @@ public abstract class NodeMonitor implements ExtensionPoint, Describable<NodeMon
|
||||
return getDescriptor().getDisplayName();
|
||||
}
|
||||
|
||||
public abstract AbstractNodeMonitorDescriptor<?> getDescriptor();
|
||||
|
||||
public Object data(Computer c) {
|
||||
return getDescriptor().get(c);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* All registered {@link NodeMonitor}s.
|
||||
*/
|
||||
public static final List<Descriptor<NodeMonitor>> LIST = new ArrayList<Descriptor<NodeMonitor>>();
|
||||
public static final DescriptorList<NodeMonitor> LIST = new DescriptorList<NodeMonitor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
LIST.add(ClockMonitor.DESCRIPTOR);
|
||||
LIST.load(ClockMonitor.class);
|
||||
if(Functions.isMustangOrAbove())
|
||||
LIST.add(DiskSpaceMonitor.DESCRIPTOR);
|
||||
LIST.load(DiskSpaceMonitor.class);
|
||||
LIST.load(ArchitectureMonitor.class);
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(NodeMonitor.class.getName()).log(Level.SEVERE, "Failed to load built-in monitors",e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user