This commit is contained in:
Tienan Chen 2013-09-24 21:26:53 +08:00
commit bf00538642
4 changed files with 7 additions and 6 deletions

View File

@ -6,7 +6,7 @@ public class MonitorContorlEntity {
private int idleTime;
public MonitorContorlEntity(){
this.osNameString=System.getProperty("os.name").toLowerCase();
this.idleTime=2000;
this.idleTime=3000;
}
public String getOsNameString() {
return osNameString;

View File

@ -75,7 +75,7 @@ public class MemoryMonitor extends LinuxFileRead {
public MemoryModel getMemoryInfo(int idleTime) throws IOException{
MemoryModel memoryModel=new MemoryModel();
Runtime rt = Runtime.getRuntime();
String time=new Integer(idleTime).toString();
String time=new Integer(idleTime/1000).toString();
Process p = rt.exec("vmstat "+time+" 2");
BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
StringTokenizer token ;

View File

@ -70,7 +70,7 @@ public class NetworkInterfaceMonitor extends LinuxFileRead {
while ((nextline = br.readLine()) != null) {
if (nextline.contains("eth")) {
token = new StringTokenizer(nextline);
String instance = token.nextToken();// instance
String instance = token.nextToken().replace(":", "");// instance
instances.add(instance);
String str = token.nextToken();// received bytes
bytesReceived.put(instance, Double.parseDouble(str));
@ -88,7 +88,7 @@ public class NetworkInterfaceMonitor extends LinuxFileRead {
while ((nextline = br.readLine()) != null) {
if (nextline.contains("eth")) {
token = new StringTokenizer(nextline);
String instance = token.nextToken();// instance
String instance = token.nextToken().replace(":", "");// instance
String str = token.nextToken();// received bytes
bytesReceived.put(instance, Double.parseDouble(str)

View File

@ -147,14 +147,15 @@ public class ProcessorMonitor extends LinuxFileRead {
+ sys1 + nice1))
/ (double) ((user2 + sys2 + idle2 + nice2 + iowait2) - (user1
+ sys1 + idle1 + nice1 + iowait1)) * 100;
if(processorTimePercent_temp.equals("NaN")) processorTimePercent_temp=0.0;
Double userTimePercent_temp = (double) ((user2) - (user1))
/ (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1
+ sys1 + iowait1 + nice1 + idle1)) * 100;
if(userTimePercent_temp.equals("NaN")) userTimePercent_temp=0.0;
Double privilegedTimePercent_temp = (double) ((sys2) - (sys1))
/ (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1
+ sys1 + iowait1 + nice1 + idle2)) * 100;
if(privilegedTimePercent_temp.equals("NaN")) privilegedTimePercent_temp=0.0;
privilegedTimePercent.put(instance, privilegedTimePercent_temp);
processorTimePercent.put(instance, processorTimePercent_temp);
userTimePercent.put(instance, userTimePercent_temp);