1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.miloss.fgsms.osagent;
18
19 import java.util.Arrays;
20 import org.hyperic.sigar.SigarException;
21 import org.hyperic.sigar.cmd.CpuInfo;
22 import org.hyperic.sigar.cmd.Free;
23 import org.hyperic.sigar.cmd.Shell;
24 import org.hyperic.sigar.cmd.Ulimit;
25 import org.hyperic.sigar.cmd.Uptime;
26
27
28 import org.hyperic.sigar.cmd.Version;
29
30
31
32
33
34 public class SysInfo extends SigarCommandBase implements Closable{
35
36 public SysInfo(Shell shell) {
37 super(shell);
38 }
39
40 public SysInfo() {
41 super();
42 }
43
44 public String getUsageShort() {
45 return "Display system information";
46 }
47
48 public void output(String[] args) throws SigarException {
49
50 Version.printInfo(this.out);
51 println("");
52
53
54 new Uptime(this.shell).output(args);
55 println("");
56
57
58 CpuInfo cpuinfo = new CpuInfo(this.shell);
59 cpuinfo.displayTimes = false;
60 cpuinfo.output(args);
61 println("");
62
63
64 new Free(this.shell).output(args);
65 println("");
66
67 println("File Systems........." +
68 Arrays.asList(this.sigar.getFileSystemList()));
69 println("");
70
71 println("Network Interfaces..." +
72 Arrays.asList(this.sigar.getNetInterfaceList()));
73 println("");
74
75
76 println("System resource limits:");
77 new Ulimit(this.shell).output(args);
78 }
79
80
81
82
83 @Override
84 public void close() throws Exception{
85 if (sigar != null) {
86 sigar.close();
87 sigar = null;
88 }
89 }
90 @Override
91 protected void finalize() throws Throwable
92 {
93
94 if (sigar != null) {
95 System.out.println("WARN,. finalize called without closing sigar first" + this.getClass().getCanonicalName());
96 sigar.close();
97 }
98 super.finalize();
99 }
100 }