renaming proc_time.{utime,stime} to proc_time.{user,sys}
'utime' and 'stime' are common within system structures, but with lots of other stuff in the structure unrelated to time. having 'time' in both the structure/class name and the field at the sigar level is just lame.
This commit is contained in:
1 parent
641253b359
commit
606275fc36
16 files changed
+46
-30
No files matched your search
@@ -269,14 +269,14 @@ my %classes = (
|
||||
plat => 'ADHLSW'
|
||||
},
|
||||
{
|
||||
name => 'utime', type => 'Long',
|
||||
name => 'user', type => 'Long',
|
||||
desc => 'Process cpu user time',
|
||||
plat => 'AHLSW'
|
||||
plat => 'ADHLSW'
|
||||
},
|
||||
{
|
||||
name => 'stime', type => 'Long',
|
||||
name => 'sys', type => 'Long',
|
||||
desc => 'Process cpu kernel time',
|
||||
plat => 'AHLSW'
|
||||
plat => 'ADHLSW'
|
||||
},
|
||||
],
|
||||
ProcState => [
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ProcCpu extends ProcTime {
|
||||
private void getValues(Sigar sigar, long pid)
|
||||
throws SigarException {
|
||||
this.nativeGet(sigar, pid);
|
||||
this.time = this.utime + this.stime;
|
||||
this.time = this.user + this.sys;
|
||||
}
|
||||
|
||||
static synchronized ProcCpu get(Sigar sigar, long pid)
|
||||
@@ -69,7 +69,7 @@ public class ProcCpu extends ProcTime {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Sum of Utime and Stime.
|
||||
* @return Sum of User and Sys.
|
||||
*/
|
||||
public long getTotal() {
|
||||
return this.time;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class SigarInvoker {
|
||||
|
||||
private static HashMap attrCache = new HashMap();
|
||||
private static HashMap compatTypes = new HashMap();
|
||||
private static HashMap compatAttrs = new HashMap();
|
||||
|
||||
static {
|
||||
//XXX backwards compat for HQ because metric template
|
||||
@@ -23,6 +24,8 @@ public class SigarInvoker {
|
||||
compatTypes.put("NetIfconfig", "NetInterfaceConfig");
|
||||
compatTypes.put("NetIfstat", "NetInterfaceStat");
|
||||
compatTypes.put("DirStats", "DirStat");
|
||||
compatAttrs.put("Utime", "User");
|
||||
compatAttrs.put("Stime", "Sys");
|
||||
}
|
||||
|
||||
//avoid object creation as much as possible
|
||||
@@ -279,6 +282,10 @@ public class SigarInvoker {
|
||||
private Method getAttributeMethod(String attr)
|
||||
throws SigarException {
|
||||
|
||||
String alias = (String)compatAttrs.get(attr);
|
||||
if (alias != null) {
|
||||
attr = alias;
|
||||
}
|
||||
Method attrMethod;
|
||||
Class type = getTypeMethod(null).getReturnType();
|
||||
|
||||
|
||||
@@ -148,6 +148,12 @@ public class Ps extends SigarCommandBase {
|
||||
|
||||
} catch (SigarException e) {}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
String[] args = sigar.getProcArgs(pid);
|
||||
name = args[0];
|
||||
} catch (SigarException e) {}
|
||||
}
|
||||
|
||||
info.add(name);
|
||||
|
||||
@@ -159,7 +165,7 @@ public class Ps extends SigarCommandBase {
|
||||
}
|
||||
|
||||
private static String getCpuTime(ProcTime time) {
|
||||
long t = (time.getUtime() + time.getStime());
|
||||
long t = (time.getUser() + time.getSys());
|
||||
return t/60 + ":" + t%60;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ public class SigarProcess implements SigarProcessMBean {
|
||||
}
|
||||
|
||||
public Long getTimeUser() {
|
||||
return getLongValue(procTime, "Utime");
|
||||
return getLongValue(procTime, "User");
|
||||
}
|
||||
|
||||
public Long getTimeSys() {
|
||||
return getLongValue(procTime, "Stime");
|
||||
return getLongValue(procTime, "Sys");
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,9 @@ public class TestInvoker extends SigarTestCase {
|
||||
{ "sigar:Type=LoadAverage", "2" },
|
||||
{ "sigar:Type=ProcMem,Arg=$$", "Size" },
|
||||
{ "sigar:Type=ProcMem,Arg=$$", "Vsize" },
|
||||
{ "sigar:Type=ProcTime,Arg=$$", "Sys" },
|
||||
{ "sigar:Type=ProcTime,Arg=$$", "User" },
|
||||
//test Utime/Stime backcompat.
|
||||
{ "sigar:Type=ProcTime,Arg=$$", "Stime" },
|
||||
{ "sigar:Type=ProcTime,Arg=$$", "Utime" },
|
||||
{ "sigar:Type=CpuPercList,Arg=0", "Idle" },
|
||||
@@ -32,7 +35,7 @@ public class TestInvoker extends SigarTestCase {
|
||||
private static final String[][] BROKEN_QUERIES = {
|
||||
{ "sigar:Type=BREAK", "Free" },
|
||||
{ "sigar:Type=Mem", "BREAK" },
|
||||
{ "sigar:Type=ProcTime,Arg=BREAK", "Stime" },
|
||||
{ "sigar:Type=ProcTime,Arg=BREAK", "Sys" },
|
||||
{ "sigar:Type=CpuPercList,Arg=1000", "Idle" },
|
||||
{ "sigar:Type=CpuPercList,Arg=BREAK", "Idle" },
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TestPTQL extends SigarTestCase {
|
||||
"Cred.Uid.gt=0,Cred.Uid.lt=1000", //range of users
|
||||
"Cred.Uid.eq=1003,Cred.Gid.eq=1003", //me
|
||||
"CredName.User.eq=dougm", //me
|
||||
"Time.Stime.gt=1000", //cpu hog
|
||||
"Time.Sys.gt=1000", //cpu hog
|
||||
"Fd.Total.gt=20", //lots of open files
|
||||
"Mem.Size.ge=10000000,Mem.Share.le=1000000", //memory hog
|
||||
"State.Name.eq=sshd,Cred.Uid.eq=0",
|
||||
@@ -60,7 +60,7 @@ public class TestPTQL extends SigarTestCase {
|
||||
"State.Name.eq=$2",
|
||||
"State.State.eq=read",
|
||||
"Args.x.eq=foo",
|
||||
"Time.Stime.gt=x",
|
||||
"Time.Sys.gt=x",
|
||||
"Pid.PidFile.ne=pid.file",
|
||||
"Pid.Pid.eq=foo",
|
||||
"Pid.Service.ne=Eventlog",
|
||||
|
||||
@@ -24,8 +24,8 @@ public class TestProcTime extends SigarTestCase {
|
||||
//XXX
|
||||
//assertTrue(procTime.getStartTime() < System.currentTimeMillis());
|
||||
|
||||
assertGtEqZeroTrace("Utime", procTime.getUtime());
|
||||
assertGtEqZeroTrace("User", procTime.getUser());
|
||||
|
||||
assertGtEqZeroTrace("Stime", procTime.getStime());
|
||||
assertGtEqZeroTrace("Sys", procTime.getSys());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user