use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class LoadStats method addContents.
/**
* {@inheritDoc}
*/
@Override
public void addContents(@NonNull Container container) {
Jenkins jenkins = Jenkins.getInstance();
add(container, "no-label", jenkins.unlabeledLoad);
add(container, "overall", jenkins.overallLoad);
for (Label l : jenkins.getLabels()) {
try {
add(container, String.format("label/%s", URLEncoder.encode(l.getName(), "UTF-8")), l.loadStatistics);
} catch (UnsupportedEncodingException e) {
// ignore UTF-8 is required by JLS specification
}
}
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class AdvancedProcFilesRetriever method addUnixContents.
@Override
protected void addUnixContents(@NonNull Container container, @NonNull final Node node) {
Computer c = node.toComputer();
if (c == null || c.isOffline()) {
return;
}
// fast path bailout for Windows
if (!Boolean.TRUE.equals(c.isUnix())) {
return;
}
SystemPlatform nodeSystemPlatform = getSystemPlatform(node);
if (!SystemPlatform.LINUX.equals(nodeSystemPlatform)) {
return;
}
String name;
if (node instanceof Jenkins) {
name = "master";
} else {
name = "slave/" + node.getNodeName();
}
for (ProcFile procDescriptor : getProcFilesToRetrieve()) {
container.add(new FilePathContent("nodes/{0}/proc/{1}", new String[] { name, procDescriptor.getName() }, new FilePath(c.getChannel(), procDescriptor.getFile())) {
@Override
public boolean shouldBeFiltered() {
// Whether this specific file should be filtered or not
return procDescriptor.isFiltered();
}
});
}
afterAddUnixContents(container, node, name);
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class ProcFilesRetriever method addUnixContents.
protected void addUnixContents(@NonNull Container container, @NonNull final Node node) {
Computer c = node.toComputer();
if (c == null || c.isOffline()) {
return;
}
// fast path bailout for Windows
if (!Boolean.TRUE.equals(c.isUnix())) {
return;
}
SystemPlatform nodeSystemPlatform = getSystemPlatform(node);
if (!SystemPlatform.LINUX.equals(nodeSystemPlatform)) {
return;
}
String name;
if (node instanceof Jenkins) {
name = "master";
} else {
name = "slave/" + node.getNodeName();
}
for (Map.Entry<String, String> procDescriptor : getFilesToRetrieve().entrySet()) {
container.add(new FilePathContent("nodes/{0}/proc/{1}", new String[] { name, procDescriptor.getValue() }, new FilePath(c.getChannel(), procDescriptor.getKey())));
}
afterAddUnixContents(container, node, name);
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class ProcFilesRetriever method getNodes.
protected List<Node> getNodes() {
final Jenkins jenkins = Jenkins.get();
final List<Node> agents = jenkins.getNodes();
List<Node> allNodes = new ArrayList<>(agents.size() + 1);
allNodes.add(jenkins);
allNodes.addAll(agents);
return allNodes;
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class OtherConfigFilesComponent method addContents.
@Override
public void addContents(@NonNull Container container) {
Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins != null) {
File dir = jenkins.getRootDir();
File[] files = dir.listFiles((dir1, name) -> name.toLowerCase().endsWith(".xml") && !BLACKLISTED_FILENAMES.contains(name));
if (files != null) {
for (File configFile : files) {
if (configFile.exists()) {
container.add(new XmlRedactedSecretFileContent("jenkins-root-configuration-files/{0}", new String[] { configFile.getName() }, configFile));
}
}
} else {
LOGGER.log(Level.WARNING, "Cannot list files in Jenkins root, probably something is wrong with the path");
}
}
}
Aggregations