+static void
+registerXidVstat(struct Vector *vec, unsigned long xid_l)
+{
+ xid_t xid = (xid_t) xid_l;
+ struct XidData *res;
+ struct vc_rlimit_stat limit[3];
+ struct vc_virt_stat vstat;
+ struct vc_sched_info sched;
+ int cpu;
+
+ res = Vector_search(vec, &xid, cmpData);
+ if (res!=0) {
+ WRITE_MSG(2, "Duplicate xid found?!\n");
+ return;
+ }
+ if (vc_virt_stat(xid, &vstat) == -1) {
+ perror("vc_virt_stat()");
+ return;
+ }
+ if (vc_rlimit_stat(xid, RLIMIT_NPROC, &limit[0]) == -1) {
+ perror("vc_rlimit_stat(RLIMIT_NRPOC)");
+ return;
+ }
+ if (vc_rlimit_stat(xid, RLIMIT_AS, &limit[1]) == -1) {
+ perror("vc_rlimit_stat(RLIMIT_AS)");
+ return;
+ }
+ if (vc_rlimit_stat(xid, RLIMIT_RSS, &limit[2]) == -1) {
+ perror("vc_rlimit_stat(RLIMIT_RSS)");
+ return;
+ }
+
+ res = Vector_insert(vec, &xid, cmpData);
+ res->xid = xid;
+
+ res->process_count = limit[0].value;
+ res->VmSize_total = limit[1].value * pagesize;
+ res->VmRSS_total = limit[2].value;
+ res->start_time_oldest= getUptime() - vstat.uptime/1000000;
+
+ res->utime_total = 0;
+ res->stime_total = 0;
+ // XXX: arbitrary CPU limit.
+ for (cpu = 0; cpu < 1024; cpu++) {
+ sched.cpu_id = cpu;
+ sched.bucket_id = 0;
+ if (vc_sched_info(xid, &sched) == -1)
+ break;
+
+ res->utime_total += sched.user_msec;
+ res->stime_total += sched.sys_msec;
+ }
+}
+