Yet another kstat_chain_update check. Added machine.cpu_stat_kstat[x] =
* open.c (glibtop_get_kstats): Yet another kstat_chain_update check. Added machine.cpu_stat_kstat[x] = NULL when processor x is not configured. * procdata.c (glibtop_get_proc_credentials_s): Read prcred structure from /proc. * procstate.c (glibtop_get_proc_state_s): Added ruid, rgid, has_cpu, processor and last_processor. * procuid.c (glibtop_get_proc_uid_s): Added priority, nice, suid, sgid, ngroups and groups. The last four will be filled only if our process has the authority to read prcred structure of another process. It's a bit untested for now. :-)
This commit is contained in:
@@ -71,3 +71,26 @@ glibtop_get_proc_data_usage_s (glibtop *server, struct prusage *prusage, pid_t p
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_credentials_s(glibtop *server, struct prcred *prcred, pid_t pid)
|
||||
{
|
||||
int fd;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
sprintf(buffer, "/proc/%d/prcred", (int)pid);
|
||||
if((fd = open(buffer, O_RDONLY)) < 0)
|
||||
{
|
||||
if(errno != EPERM)
|
||||
glibtop_warn_io_r(server, "open (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
if(pread(fd, prcred, sizeof(struct prcred), 0) != sizeof(struct prcred))
|
||||
{
|
||||
close(fd);
|
||||
glibtop_warn_io_r(server, "read (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user