in sysinfo-agent/src/main/java/org/jetbrains/teamcity/sysinfo/agent/WinSysInfoProvider.java [21:92]
public Map<String, String> getSysInfo() {
Map<String, String> props = Collections.emptyMap();
try {
final GeneralCommandLine cmd = new GeneralCommandLine();
cmd.setExePath("systeminfo");
cmd.addParameter("/FO");
cmd.addParameter("CSV");
final jetbrains.buildServer.CommandLineExecutor executor = new jetbrains.buildServer.CommandLineExecutor(cmd);
final ExecResult result = executor.runProcess(60);
if(result != null && result.getExitCode() == 0) {
final String[] lines = result.getOutLines();
if(lines.length != 2)
{
return props;
}
final List<String> keys = parseCsvLine(lines[0]);
final List<String> values = parseCsvLine(lines[1]);
if(keys.size() != values.size())
{
return props;
}
props = new HashMap<String, String>();
for(int i = 0; i < keys.size(); i++) {
final String key = "teamcity.agent.os." + normalizeKey(keys.get(i));
final String val = normalizeValue(values.get(i));
props.put(key, val);
}
// Handle mul properties
final HashMap<String, String> mulKeys = new HashMap<String, String>();
for (Map.Entry<String, String> item: props.entrySet()) {
for(String postfix: OurPostfixes) {
if (item.getKey().endsWith(postfix)) {
mulKeys.put(item.getKey(), item.getKey().substring(0, item.getKey().length() - postfix.length()));
}
}
}
for(Map.Entry<String, String> item: mulKeys.entrySet())
{
final String newKeyPrefix = item.getValue();
final String val = props.get(item.getKey());
int pos = 0;
int index = 1;
while(pos >=0 && pos < val.length()) {
final String indexStr = "[" + String.format("%02d", index) + "]: ";
index++;
pos = val.indexOf(indexStr, pos);
if(pos >= 0) {
pos += indexStr.length();
int end = val.indexOf(",", pos);
if (end == -1) {
end = val.length();
}
final String newKey = newKeyPrefix + "." + normalizeKey(val.substring(pos, end));
props.put(newKey, "");
}
}
props.remove(item.getKey());
}
}
}
catch (ExecutionException e) {
LOG.error(e);
}
return props;
}