1
|
package eu.dnetlib.enabling.inspector;
|
2
|
|
3
|
import java.lang.management.ManagementFactory;
|
4
|
import java.lang.management.RuntimeMXBean;
|
5
|
import java.util.LinkedHashMap;
|
6
|
import java.util.Map;
|
7
|
|
8
|
import javax.annotation.Resource;
|
9
|
|
10
|
import org.springframework.stereotype.Controller;
|
11
|
import org.springframework.ui.Model;
|
12
|
import org.springframework.web.bind.annotation.RequestMapping;
|
13
|
|
14
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
15
|
import eu.dnetlib.miscutils.datetime.HumanTime;
|
16
|
|
17
|
/**
|
18
|
* This controller offers generic info about current node (ip, uptime, ...)
|
19
|
*
|
20
|
* @author michele
|
21
|
*
|
22
|
*/
|
23
|
@Controller
|
24
|
public class GenericInfoController extends AbstractInspectorController {
|
25
|
|
26
|
@Resource(name="containerInfo")
|
27
|
Map<String,String> containerInfo;
|
28
|
|
29
|
@RequestMapping(value = "/inspector/info.do")
|
30
|
void query(final Model model) {
|
31
|
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
|
32
|
|
33
|
Map<String,String> sysinfo = new LinkedHashMap<String, String>();
|
34
|
sysinfo.put("Uptime", HumanTime.exactly(mxbean.getUptime()));
|
35
|
sysinfo.put("Start Time", DateUtils.calculate_ISO8601(mxbean.getStartTime()));
|
36
|
|
37
|
sysinfo.put("JVM Name", mxbean.getVmName());
|
38
|
sysinfo.put("JVM Vendor", mxbean.getVmVendor());
|
39
|
sysinfo.put("JVM Version", mxbean.getVmVersion());
|
40
|
sysinfo.put("JVM Spec Name", mxbean.getSpecName());
|
41
|
sysinfo.put("JVM Spec Vendor", mxbean.getSpecVendor());
|
42
|
sysinfo.put("JVM Spec Version", mxbean.getSpecVersion());
|
43
|
|
44
|
sysinfo.put("Running JVM Name", mxbean.getName());
|
45
|
sysinfo.put("Management Spec Version", mxbean.getManagementSpecVersion());
|
46
|
|
47
|
sysinfo.put("Classpath", mxbean.getClassPath().replaceAll(":", " : "));
|
48
|
sysinfo.put("Boot ClassPath", mxbean.getBootClassPath().replaceAll(":", " : "));
|
49
|
sysinfo.put("Input arguments", mxbean.getInputArguments().toString());
|
50
|
sysinfo.put("Library Path", mxbean.getLibraryPath().replaceAll(":", " : "));
|
51
|
|
52
|
sysinfo.put("SystemProperties", mxbean.getSystemProperties().toString());
|
53
|
|
54
|
|
55
|
model.addAttribute("containerInfo", containerInfo);
|
56
|
model.addAttribute("sysInfo", sysinfo);
|
57
|
}
|
58
|
|
59
|
}
|
60
|
|